Commit d9e23a08 authored by boliu's avatar boliu Committed by Commit bot

Move AW renderer compositor context to gpu thread

Use TexSubImage2D instead of TexImage2D to avoid orphaning
EGLImage
Create the renderer compositor context on the gpu thread.

BUG=448168, 259924

Committed: https://crrev.com/a4baed454be2bb165cb12eb7df432e9138e746e6
Cr-Commit-Position: refs/heads/master@{#313846}

Review URL: https://codereview.chromium.org/769703005

Cr-Commit-Position: refs/heads/master@{#314705}
parent 0c7c18bf
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "content/browser/android/in_process/synchronous_compositor_factory_impl.h" #include "content/browser/android/in_process/synchronous_compositor_factory_impl.h"
#include "base/command_line.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "content/browser/android/in_process/synchronous_compositor_external_begin_frame_source.h" #include "content/browser/android/in_process/synchronous_compositor_external_begin_frame_source.h"
#include "content/browser/android/in_process/synchronous_compositor_impl.h" #include "content/browser/android/in_process/synchronous_compositor_impl.h"
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
#include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h"
#include "gpu/command_buffer/client/gl_in_process_context.h" #include "gpu/command_buffer/client/gl_in_process_context.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "ui/gl/android/surface_texture.h" #include "ui/gl/android/surface_texture.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/gl/gl_surface_stub.h" #include "ui/gl/gl_surface_stub.h"
...@@ -64,7 +66,8 @@ scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext( ...@@ -64,7 +66,8 @@ scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext(
scoped_ptr<gpu::GLInProcessContext> CreateContext( scoped_ptr<gpu::GLInProcessContext> CreateContext(
scoped_refptr<gpu::InProcessCommandBuffer::Service> service, scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { const gpu::GLInProcessContextSharedMemoryLimits& mem_limits,
bool is_offscreen) {
const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
gpu::gles2::ContextCreationAttribHelper in_process_attribs; gpu::gles2::ContextCreationAttribHelper in_process_attribs;
WebGraphicsContext3DImpl::ConvertAttributes( WebGraphicsContext3DImpl::ConvertAttributes(
...@@ -74,7 +77,7 @@ scoped_ptr<gpu::GLInProcessContext> CreateContext( ...@@ -74,7 +77,7 @@ scoped_ptr<gpu::GLInProcessContext> CreateContext(
scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create(
service, service,
NULL /* surface */, NULL /* surface */,
false /* is_offscreen */, is_offscreen,
gfx::kNullAcceleratedWidget, gfx::kNullAcceleratedWidget,
gfx::Size(1, 1), gfx::Size(1, 1),
NULL /* share_context */, NULL /* share_context */,
...@@ -219,7 +222,7 @@ scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: ...@@ -219,7 +222,7 @@ scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
// pipeline is only one frame deep. // pipeline is only one frame deep.
mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024;
return webkit::gpu::ContextProviderInProcess::Create( return webkit::gpu::ContextProviderInProcess::Create(
WrapContext(CreateContext(service_, mem_limits)), WrapContext(CreateContext(nullptr, mem_limits, true)),
"Child-Compositor"); "Child-Compositor");
} }
...@@ -288,9 +291,10 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() { ...@@ -288,9 +291,10 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() {
if (!video_context_provider_.get()) { if (!video_context_provider_.get()) {
DCHECK(service_.get()); DCHECK(service_.get());
video_context_provider_ = new VideoContextProvider( // This needs to run in on-screen |service_| context due to SurfaceTexture
CreateContext(service_, // limitations.
gpu::GLInProcessContextSharedMemoryLimits())); video_context_provider_ = new VideoContextProvider(CreateContext(
service_, gpu::GLInProcessContextSharedMemoryLimits(), false));
} }
return video_context_provider_; return video_context_provider_;
} }
......
...@@ -77,13 +77,16 @@ bool AllowTransferThreadForGpu() { ...@@ -77,13 +77,16 @@ bool AllowTransferThreadForGpu() {
AsyncPixelTransferManager* AsyncPixelTransferManager::Create( AsyncPixelTransferManager* AsyncPixelTransferManager::Create(
gfx::GLContext* context) { gfx::GLContext* context) {
DCHECK(context->IsCurrent(NULL)); DCHECK(context->IsCurrent(NULL));
base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
// Threaded mailbox uses EGLImage which conflicts with EGL uploader. // Threaded mailbox uses EGLImage which conflicts with EGL uploader.
// The spec only allows one EGL image per sibling group, but currently the // The spec only allows one EGL image per sibling group, but currently the
// image handle cannot be shared between the threaded mailbox code and // image handle cannot be shared between the threaded mailbox code and
// AsyncPixelTransferManagerEGL. // AsyncPixelTransferManagerEGL.
bool uses_threaded_mailboxes = bool uses_threaded_mailboxes =
base::CommandLine::ForCurrentProcess()->HasSwitch( cl->HasSwitch(switches::kEnableThreadedTextureMailboxes);
switches::kEnableThreadedTextureMailboxes); // TexImage2D orphans the EGLImage used for threaded mailbox sharing.
bool use_teximage2d_over_texsubimage2d = !uses_threaded_mailboxes;
switch (gfx::GetGLImplementation()) { switch (gfx::GetGLImplementation()) {
case gfx::kGLImplementationEGLGLES2: case gfx::kGLImplementationEGLGLES2:
DCHECK(context); DCHECK(context);
...@@ -93,15 +96,16 @@ AsyncPixelTransferManager* AsyncPixelTransferManager::Create( ...@@ -93,15 +96,16 @@ AsyncPixelTransferManager* AsyncPixelTransferManager::Create(
context->HasExtension("EGL_KHR_image_base") && context->HasExtension("EGL_KHR_image_base") &&
context->HasExtension("EGL_KHR_gl_texture_2D_image") && context->HasExtension("EGL_KHR_gl_texture_2D_image") &&
context->HasExtension("GL_OES_EGL_image") && context->HasExtension("GL_OES_EGL_image") &&
!uses_threaded_mailboxes && !uses_threaded_mailboxes && AllowTransferThreadForGpu()) {
AllowTransferThreadForGpu()) {
TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateWithThread"); TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateWithThread");
return new AsyncPixelTransferManagerEGL; return new AsyncPixelTransferManagerEGL;
} }
return new AsyncPixelTransferManagerIdle; return new AsyncPixelTransferManagerIdle(
use_teximage2d_over_texsubimage2d);
case gfx::kGLImplementationOSMesaGL: { case gfx::kGLImplementationOSMesaGL: {
TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateIdle"); TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateIdle");
return new AsyncPixelTransferManagerIdle; return new AsyncPixelTransferManagerIdle(
use_teximage2d_over_texsubimage2d);
} }
case gfx::kGLImplementationMockGL: case gfx::kGLImplementationMockGL:
return new AsyncPixelTransferManagerStub; return new AsyncPixelTransferManagerStub;
......
...@@ -183,9 +183,8 @@ void AsyncPixelTransferDelegateIdle::PerformAsyncTexSubImage2D( ...@@ -183,9 +183,8 @@ void AsyncPixelTransferDelegateIdle::PerformAsyncTexSubImage2D(
base::TimeTicks begin_time(base::TimeTicks::Now()); base::TimeTicks begin_time(base::TimeTicks::Now());
gfx::ScopedTextureBinder texture_binder(tex_params.target, texture_id_); gfx::ScopedTextureBinder texture_binder(tex_params.target, texture_id_);
// If it's a full texture update, use glTexImage2D as it's faster. if (shared_state_->use_teximage2d_over_texsubimage2d &&
// TODO(epenner): Make this configurable (http://crbug.com/259924) tex_params.xoffset == 0 &&
if (tex_params.xoffset == 0 &&
tex_params.yoffset == 0 && tex_params.yoffset == 0 &&
tex_params.target == define_params_.target && tex_params.target == define_params_.target &&
tex_params.level == define_params_.level && tex_params.level == define_params_.level &&
...@@ -234,8 +233,11 @@ AsyncPixelTransferManagerIdle::Task::Task( ...@@ -234,8 +233,11 @@ AsyncPixelTransferManagerIdle::Task::Task(
AsyncPixelTransferManagerIdle::Task::~Task() {} AsyncPixelTransferManagerIdle::Task::~Task() {}
AsyncPixelTransferManagerIdle::SharedState::SharedState() AsyncPixelTransferManagerIdle::SharedState::SharedState(
: texture_upload_count(0) {} bool use_teximage2d_over_texsubimage2d)
: use_teximage2d_over_texsubimage2d(use_teximage2d_over_texsubimage2d),
texture_upload_count(0) {
}
AsyncPixelTransferManagerIdle::SharedState::~SharedState() {} AsyncPixelTransferManagerIdle::SharedState::~SharedState() {}
...@@ -250,8 +252,9 @@ void AsyncPixelTransferManagerIdle::SharedState::ProcessNotificationTasks() { ...@@ -250,8 +252,9 @@ void AsyncPixelTransferManagerIdle::SharedState::ProcessNotificationTasks() {
} }
} }
AsyncPixelTransferManagerIdle::AsyncPixelTransferManagerIdle() AsyncPixelTransferManagerIdle::AsyncPixelTransferManagerIdle(
: shared_state_() { bool use_teximage2d_over_texsubimage2d)
: shared_state_(use_teximage2d_over_texsubimage2d) {
} }
AsyncPixelTransferManagerIdle::~AsyncPixelTransferManagerIdle() {} AsyncPixelTransferManagerIdle::~AsyncPixelTransferManagerIdle() {}
......
...@@ -13,7 +13,8 @@ namespace gpu { ...@@ -13,7 +13,8 @@ namespace gpu {
class AsyncPixelTransferManagerIdle : public AsyncPixelTransferManager { class AsyncPixelTransferManagerIdle : public AsyncPixelTransferManager {
public: public:
AsyncPixelTransferManagerIdle(); explicit AsyncPixelTransferManagerIdle(
bool use_teximage2d_over_texsubimage2d);
~AsyncPixelTransferManagerIdle() override; ~AsyncPixelTransferManagerIdle() override;
// AsyncPixelTransferManager implementation: // AsyncPixelTransferManager implementation:
...@@ -43,10 +44,11 @@ class AsyncPixelTransferManagerIdle : public AsyncPixelTransferManager { ...@@ -43,10 +44,11 @@ class AsyncPixelTransferManagerIdle : public AsyncPixelTransferManager {
// State shared between Managers and Delegates. // State shared between Managers and Delegates.
struct SharedState { struct SharedState {
SharedState(); explicit SharedState(bool use_teximage2d_over_texsubimage2d);
~SharedState(); ~SharedState();
void ProcessNotificationTasks(); void ProcessNotificationTasks();
const bool use_teximage2d_over_texsubimage2d;
int texture_upload_count; int texture_upload_count;
base::TimeDelta total_texture_upload_time; base::TimeDelta total_texture_upload_time;
std::list<Task> tasks; std::list<Task> tasks;
......
...@@ -28,7 +28,7 @@ AsyncPixelTransferManager* AsyncPixelTransferManager::Create( ...@@ -28,7 +28,7 @@ AsyncPixelTransferManager* AsyncPixelTransferManager::Create(
case gfx::kGLImplementationOSMesaGL: case gfx::kGLImplementationOSMesaGL:
case gfx::kGLImplementationDesktopGL: case gfx::kGLImplementationDesktopGL:
case gfx::kGLImplementationEGLGLES2: case gfx::kGLImplementationEGLGLES2:
return new AsyncPixelTransferManagerIdle; return new AsyncPixelTransferManagerIdle(true);
case gfx::kGLImplementationMockGL: case gfx::kGLImplementationMockGL:
return new AsyncPixelTransferManagerStub; return new AsyncPixelTransferManagerStub;
default: default:
......
...@@ -18,7 +18,7 @@ AsyncPixelTransferManager* AsyncPixelTransferManager::Create( ...@@ -18,7 +18,7 @@ AsyncPixelTransferManager* AsyncPixelTransferManager::Create(
case gfx::kGLImplementationOSMesaGL: case gfx::kGLImplementationOSMesaGL:
case gfx::kGLImplementationDesktopGL: case gfx::kGLImplementationDesktopGL:
case gfx::kGLImplementationAppleGL: case gfx::kGLImplementationAppleGL:
return new AsyncPixelTransferManagerIdle; return new AsyncPixelTransferManagerIdle(true);
case gfx::kGLImplementationMockGL: case gfx::kGLImplementationMockGL:
return new AsyncPixelTransferManagerStub; return new AsyncPixelTransferManagerStub;
default: default:
......
...@@ -18,7 +18,7 @@ AsyncPixelTransferManager* AsyncPixelTransferManager::Create( ...@@ -18,7 +18,7 @@ AsyncPixelTransferManager* AsyncPixelTransferManager::Create(
case gfx::kGLImplementationOSMesaGL: case gfx::kGLImplementationOSMesaGL:
case gfx::kGLImplementationDesktopGL: case gfx::kGLImplementationDesktopGL:
case gfx::kGLImplementationEGLGLES2: case gfx::kGLImplementationEGLGLES2:
return new AsyncPixelTransferManagerIdle; return new AsyncPixelTransferManagerIdle(true);
case gfx::kGLImplementationMockGL: case gfx::kGLImplementationMockGL:
return new AsyncPixelTransferManagerStub; return new AsyncPixelTransferManagerStub;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment