| Index: content/browser/android/in_process/synchronous_compositor_factory_impl.cc
|
| diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
|
| index 3e5df8b7d6cf21cdfe635ab4ca44c6826ac24a63..96ff883ada8d823429dfd620c77f7a7a476a7415 100644
|
| --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
|
| +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
|
| @@ -32,32 +32,38 @@ blink::WebGraphicsContext3D::Attributes GetDefaultAttribs() {
|
|
|
| using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
|
|
|
| -scoped_ptr<gpu::GLInProcessContext> CreateContextWithAttributes(
|
| - scoped_refptr<gfx::GLSurface> surface,
|
| - scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
|
| - gpu::GLInProcessContext* share_context,
|
| +scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext(
|
| const blink::WebGraphicsContext3D::Attributes& attributes) {
|
| const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
|
|
|
| - if (!surface)
|
| - surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1));
|
| -
|
| gpu::GLInProcessContextAttribs in_process_attribs;
|
| WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
|
| attributes, &in_process_attribs);
|
| in_process_attribs.lose_context_when_out_of_memory = 1;
|
| +
|
| scoped_ptr<gpu::GLInProcessContext> context(
|
| - gpu::GLInProcessContext::CreateWithSurface(
|
| - surface, service, share_context, in_process_attribs, gpu_preference));
|
| + gpu::GLInProcessContext::CreateContext(true /* is_offscreen */,
|
| + gfx::kNullAcceleratedWidget,
|
| + gfx::Size(1, 1),
|
| + false /* share_resources */,
|
| + in_process_attribs,
|
| + gpu_preference));
|
| return context.Pass();
|
| }
|
|
|
| scoped_ptr<gpu::GLInProcessContext> CreateContext(
|
| - scoped_refptr<gfx::GLSurface> surface,
|
| + gfx::GLSurface* surface,
|
| scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
|
| gpu::GLInProcessContext* share_context) {
|
| - return CreateContextWithAttributes(
|
| - surface, service, share_context, GetDefaultAttribs());
|
| + const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
|
| + gpu::GLInProcessContextAttribs in_process_attribs;
|
| + WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
|
| + GetDefaultAttribs(), &in_process_attribs);
|
| + in_process_attribs.lose_context_when_out_of_memory = 1;
|
| + scoped_ptr<gpu::GLInProcessContext> context(
|
| + gpu::GLInProcessContext::CreateWithSurface(
|
| + surface, service, share_context, in_process_attribs, gpu_preference));
|
| + return context.Pass();
|
| }
|
|
|
| scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext(
|
| @@ -107,8 +113,7 @@ class VideoContextProvider
|
| using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
|
|
|
| SynchronousCompositorFactoryImpl::SynchronousCompositorFactoryImpl()
|
| - : wrapped_gl_context_for_compositor_thread_(NULL),
|
| - num_hardware_compositors_(0) {
|
| + : num_hardware_compositors_(0) {
|
| SynchronousCompositorFactory::SetInstance(this);
|
| }
|
|
|
| @@ -137,7 +142,7 @@ scoped_refptr<ContextProviderWebContext> SynchronousCompositorFactoryImpl::
|
| if ((!offscreen_context_for_main_thread_.get() ||
|
| offscreen_context_for_main_thread_->DestroyedOnMainThread())) {
|
| scoped_ptr<gpu::GLInProcessContext> context =
|
| - CreateContext(NULL, NULL, NULL);
|
| + CreateOffscreenContext(GetDefaultAttribs());
|
| offscreen_context_for_main_thread_ =
|
| webkit::gpu::ContextProviderInProcess::Create(
|
| WrapContext(context.Pass()),
|
| @@ -152,42 +157,20 @@ scoped_refptr<ContextProviderWebContext> SynchronousCompositorFactoryImpl::
|
| return offscreen_context_for_main_thread_;
|
| }
|
|
|
| -// This is called on the renderer compositor impl thread (InitializeHwDraw) in
|
| -// order to support Android WebView synchronously enable and disable hardware
|
| -// mode multiple times in the same task.
|
| -scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
|
| - GetOffscreenContextProviderForCompositorThread() {
|
| - DCHECK(service_);
|
| - bool failed = false;
|
| - if (!offscreen_context_for_compositor_thread_.get() ||
|
| - offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) {
|
| - scoped_ptr<gpu::GLInProcessContext> context =
|
| - CreateContext(new gfx::GLSurfaceStub, service_, NULL);
|
| - wrapped_gl_context_for_compositor_thread_ = context.get();
|
| - offscreen_context_for_compositor_thread_ =
|
| - webkit::gpu::ContextProviderInProcess::Create(
|
| - WrapContext(context.Pass()),
|
| - "Compositor-Offscreen-compositor-thread");
|
| - failed = !offscreen_context_for_compositor_thread_.get() ||
|
| - !offscreen_context_for_compositor_thread_->BindToCurrentThread();
|
| - }
|
| - if (failed) {
|
| - offscreen_context_for_compositor_thread_ = NULL;
|
| - wrapped_gl_context_for_compositor_thread_ = NULL;
|
| - }
|
| - return offscreen_context_for_compositor_thread_;
|
| +void SynchronousCompositorFactoryImpl::EnsureShareContextCreated() {
|
| + if (!share_context_.get())
|
| + share_context_ = CreateContext(new gfx::GLSurfaceStub, service_, NULL);
|
| }
|
|
|
| scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
|
| CreateOnscreenContextProviderForCompositorThread(
|
| - scoped_refptr<gfx::GLSurface> surface) {
|
| + gfx::GLSurface* surface) {
|
| DCHECK(surface);
|
| DCHECK(service_);
|
| - DCHECK(wrapped_gl_context_for_compositor_thread_);
|
|
|
| + EnsureShareContextCreated();
|
| return webkit::gpu::ContextProviderInProcess::Create(
|
| - WrapContext(CreateContext(
|
| - surface, service_, wrapped_gl_context_for_compositor_thread_)),
|
| + WrapContext(CreateContext(surface, service_, share_context_.get())),
|
| "Compositor-Onscreen");
|
| }
|
|
|
| @@ -205,8 +188,7 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int view_id) {
|
| blink::WebGraphicsContext3D*
|
| SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
|
| const blink::WebGraphicsContext3D::Attributes& attributes) {
|
| - return WrapContext(CreateContextWithAttributes(NULL, NULL, NULL, attributes))
|
| - .release();
|
| + return WrapContext(CreateOffscreenContext(attributes)).release();
|
| }
|
|
|
| void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() {
|
| @@ -235,12 +217,12 @@ SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() {
|
| // will fail creation when all compositors release hardware draw.
|
| if (CanCreateMainThreadContext() && !video_context_provider_) {
|
| DCHECK(service_);
|
| - DCHECK(wrapped_gl_context_for_compositor_thread_);
|
| + DCHECK(share_context_.get());
|
|
|
| video_context_provider_ = new VideoContextProvider(
|
| CreateContext(new gfx::GLSurfaceStub,
|
| service_,
|
| - wrapped_gl_context_for_compositor_thread_));
|
| + share_context_.get()));
|
| }
|
| return video_context_provider_;
|
| }
|
|
|