| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/image_transport_factory_android.h" | 5 #include "content/browser/renderer_host/image_transport_factory_android.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 10 #include "content/browser/renderer_host/compositor_impl_android.h" | 10 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 11 #include "content/common/gpu/client/gl_helper.h" | 11 #include "content/common/gpu/client/gl_helper.h" |
| 12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 13 #include "content/common/gpu/gpu_process_launch_causes.h" | 13 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 15 #include "third_party/khronos/GLES2/gl2.h" | 15 #include "third_party/khronos/GLES2/gl2.h" |
| 16 #include "ui/gfx/android/device_display_info.h" |
| 16 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 17 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | 23 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
| 23 | 24 |
| 24 static ImageTransportFactoryAndroid* g_factory = NULL; | 25 static ImageTransportFactoryAndroid* g_factory = NULL; |
| 25 | 26 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 CmdBufferImageTransportFactory::CmdBufferImageTransportFactory() { | 94 CmdBufferImageTransportFactory::CmdBufferImageTransportFactory() { |
| 94 WebKit::WebGraphicsContext3D::Attributes attrs; | 95 WebKit::WebGraphicsContext3D::Attributes attrs; |
| 95 attrs.shareResources = true; | 96 attrs.shareResources = true; |
| 96 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); | 97 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); |
| 97 GURL url("chrome://gpu/ImageTransportFactoryAndroid"); | 98 GURL url("chrome://gpu/ImageTransportFactoryAndroid"); |
| 98 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; | 99 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; |
| 99 context_.reset(new WebGraphicsContext3DCommandBufferImpl(0, // offscreen | 100 context_.reset(new WebGraphicsContext3DCommandBufferImpl(0, // offscreen |
| 100 url, | 101 url, |
| 101 factory, | 102 factory, |
| 102 swap_client)); | 103 swap_client)); |
| 103 context_->InitializeWithDefaultBufferSizes( | 104 static const size_t kBytesPerPixel = 4; |
| 105 gfx::DeviceDisplayInfo display_info; |
| 106 size_t full_screen_texture_size_in_bytes = |
| 107 display_info.GetDisplayHeight() * |
| 108 display_info.GetDisplayWidth() * |
| 109 kBytesPerPixel; |
| 110 context_->Initialize( |
| 104 attrs, | 111 attrs, |
| 105 false, | 112 false, |
| 106 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE); | 113 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE, |
| 114 64 * 1024, // command buffer size |
| 115 std::min(full_screen_texture_size_in_bytes, |
| 116 kDefaultStartTransferBufferSize), |
| 117 kDefaultMinTransferBufferSize, |
| 118 std::min(3 * full_screen_texture_size_in_bytes, |
| 119 kDefaultMaxTransferBufferSize)); |
| 107 | 120 |
| 108 if (context_->makeContextCurrent()) | 121 if (context_->makeContextCurrent()) |
| 109 context_->pushGroupMarkerEXT( | 122 context_->pushGroupMarkerEXT( |
| 110 base::StringPrintf("CmdBufferImageTransportFactory-%p", this).c_str()); | 123 base::StringPrintf("CmdBufferImageTransportFactory-%p", this).c_str()); |
| 111 } | 124 } |
| 112 | 125 |
| 113 CmdBufferImageTransportFactory::~CmdBufferImageTransportFactory() { | 126 CmdBufferImageTransportFactory::~CmdBufferImageTransportFactory() { |
| 114 } | 127 } |
| 115 | 128 |
| 116 uint32_t CmdBufferImageTransportFactory::InsertSyncPoint() { | 129 uint32_t CmdBufferImageTransportFactory::InsertSyncPoint() { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return g_factory; | 200 return g_factory; |
| 188 } | 201 } |
| 189 | 202 |
| 190 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() { | 203 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() { |
| 191 } | 204 } |
| 192 | 205 |
| 193 ImageTransportFactoryAndroid::~ImageTransportFactoryAndroid() { | 206 ImageTransportFactoryAndroid::~ImageTransportFactoryAndroid() { |
| 194 } | 207 } |
| 195 | 208 |
| 196 } // namespace content | 209 } // namespace content |
| OLD | NEW |