Chromium Code Reviews| Index: content/browser/renderer_host/compositor_impl_android.cc |
| diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc |
| index 94ab1393c847f00e27463f931fdf3503a3250741..4c7da89bb2f49d7fb71e1f9704f92581d9c9ef0f 100644 |
| --- a/content/browser/renderer_host/compositor_impl_android.cc |
| +++ b/content/browser/renderer_host/compositor_impl_android.cc |
| @@ -358,6 +358,46 @@ bool CompositorImpl::CopyTextureToBitmap(WebKit::WebGLId texture_id, |
| return true; |
| } |
| +static scoped_ptr<WebKit::WebGraphicsContext3D> CreateInProcessViewContext( |
| + const WebKit::WebGraphicsContext3D::Attributes attributes |
| + ANativeWindow* window) { |
| + using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
| + return WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( |
| + attributes, window).PassAs<WebKit::WebGraphicsContext3D>(); |
| +} |
| + |
| +static scoped_ptr<WebKit::WebGraphicsContext3D> CreateGpuProcessViewContext( |
| + const WebKit::WebGraphicsContext3D::Attributes attributes |
| + int surface_id) { |
| + GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); |
| + GURL url("chrome://gpu/Compositor::createContext3D"); |
| + scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| + new WebGraphicsContext3DCommandBufferImpl(surface_id_, |
| + url, |
| + factory, |
| + weak_factory_.GetWeakPtr())); |
| + static const size_t kBytesPerPixel = 4; |
| + gfx::DeviceDisplayInfo display_info; |
| + size_t full_screen_texture_size_in_bytes = |
| + display_info.GetDisplayHeight() * |
| + display_info.GetDisplayWidth() * |
| + kBytesPerPixel; |
| + if (!context->Initialize( |
| + attrs, |
| + false, |
| + CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE, |
| + 64 * 1024, // command buffer size |
| + std::min(full_screen_texture_size_in_bytes, |
| + kDefaultStartTransferBufferSize), |
| + kDefaultMinTransferBufferSize, |
| + std::min(3 * full_screen_texture_size_in_bytes, |
| + kDefaultMaxTransferBufferSize))) { |
| + LOG(ERROR) << "Failed to create 3D context for compositor."; |
| + return scoped_ptr<WebKit::WebGraphicsContext3D>(); |
| + } |
| + return context.PassAs<WebKit::WebGraphicsContext3D>(); |
| +} |
| + |
| scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( |
| bool fallback) { |
| WebKit::WebGraphicsContext3D::Attributes attrs; |
| @@ -365,47 +405,29 @@ scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( |
| attrs.noAutomaticFlushes = true; |
| if (g_use_direct_gl) { |
| - scoped_ptr<WebKit::WebGraphicsContext3D> context( |
| - webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl:: |
| - CreateViewContext(attrs, window_)); |
| - if (!window_) { |
| - return scoped_ptr<cc::OutputSurface>( |
| - new DirectOutputSurface(context.Pass())); |
| - } |
| + scoped_refptr<webkit::gpu::ContextProviderInProcess> context_provider = |
| + webkit::gpu::ContextProviderInProcess::Create( |
| + base::Bind(&CreateInProcessViewContext, attrs, window_)); |
| + |
| + scoped_ptr<cc::OutputSurface> output_surface; |
| + if (!window_) |
| + output_surface.reset(new DirectOutputSurface(context_provider)); |
| + else |
| + output_surface.reset(new cc::OutputSurface(context_provider)); |
| + return output_surface.Pass(); |
| + } |
| - return make_scoped_ptr(new cc::OutputSurface(context.Pass())); |
| - } else { |
| - DCHECK(window_ && surface_id_); |
| - GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); |
| - GURL url("chrome://gpu/Compositor::createContext3D"); |
| - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| - new WebGraphicsContext3DCommandBufferImpl(surface_id_, |
| - url, |
| - factory, |
| - weak_factory_.GetWeakPtr())); |
| - static const size_t kBytesPerPixel = 4; |
| - gfx::DeviceDisplayInfo display_info; |
| - size_t full_screen_texture_size_in_bytes = |
| - display_info.GetDisplayHeight() * |
| - display_info.GetDisplayWidth() * |
| - kBytesPerPixel; |
| - if (!context->Initialize( |
| - attrs, |
| - false, |
| - CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE, |
| - 64 * 1024, // command buffer size |
| - std::min(full_screen_texture_size_in_bytes, |
| - kDefaultStartTransferBufferSize), |
| - kDefaultMinTransferBufferSize, |
| - std::min(3 * full_screen_texture_size_in_bytes, |
| - kDefaultMaxTransferBufferSize))) { |
| - LOG(ERROR) << "Failed to create 3D context for compositor."; |
| - return scoped_ptr<cc::OutputSurface>(); |
| - } |
| - return scoped_ptr<cc::OutputSurface>( |
| - new OutputSurfaceWithoutParent( |
| - context.PassAs<WebKit::WebGraphicsContext3D>())); |
| + DCHECK(window_ && surface_id_); |
| + |
| + scoped_refptr<ContextProviderCommandBuffer> context_provider = |
| + ContextProviderCommandBuffer::Create( |
| + base::Bind(&CreateGpuProcessViewContext, attrs, surface_id_)); |
| + if (!context_provider.get()) { |
| + LOG(ERROR) << "Failed to create 3D context for compositor."; |
| + return scoped_ptr<cc::OutputSurface>(); |
| } |
| + return scoped_ptr<cc::OutputSurface>( |
|
no sievers
2013/08/14 20:41:05
Do you need to adjust the constructors for OutputS
danakj
2013/08/14 20:59:35
Oh yes, thanks. Can't get local android checkout t
danakj
2013/08/14 21:06:47
Done.
|
| + new OutputSurfaceWithoutParent(context_provider)); |
| } |
| void CompositorImpl::OnLostResources() { |