Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 11348371: cc: Move WebCompositorOutputSurface and related classes into cc/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding6 Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/compositor_impl_android.h" 5 #include "content/browser/renderer_host/compositor_impl_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "cc/font_atlas.h" 14 #include "cc/font_atlas.h"
15 #include "cc/input_handler.h" 15 #include "cc/input_handler.h"
16 #include "cc/layer.h" 16 #include "cc/layer.h"
17 #include "cc/layer_tree_host.h" 17 #include "cc/layer_tree_host.h"
18 #include "cc/output_surface.h"
18 #include "cc/thread_impl.h" 19 #include "cc/thread_impl.h"
19 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 20 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
20 #include "content/browser/gpu/gpu_surface_tracker.h" 21 #include "content/browser/gpu/gpu_surface_tracker.h"
21 #include "content/browser/renderer_host/image_transport_factory_android.h" 22 #include "content/browser/renderer_host/image_transport_factory_android.h"
22 #include "content/common/gpu/client/gl_helper.h" 23 #include "content/common/gpu/client/gl_helper.h"
23 #include "content/common/gpu/client/gpu_channel_host.h" 24 #include "content/common/gpu/client/gpu_channel_host.h"
24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 25 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
25 #include "content/common/gpu/gpu_process_launch_causes.h" 26 #include "content/common/gpu/gpu_process_launch_causes.h"
26 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
27 #include "third_party/khronos/GLES2/gl2.h" 28 #include "third_party/khronos/GLES2/gl2.h"
28 #include "third_party/khronos/GLES2/gl2ext.h" 29 #include "third_party/khronos/GLES2/gl2ext.h"
29 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput Surface.h"
30 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
31 #include "ui/gfx/android/java_bitmap.h" 31 #include "ui/gfx/android/java_bitmap.h"
32 #include "webkit/glue/webthread_impl.h" 32 #include "webkit/glue/webthread_impl.h"
33 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 33 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
34 34
35 namespace gfx { 35 namespace gfx {
36 class JavaBitmap; 36 class JavaBitmap;
37 } 37 }
38 38
39 namespace { 39 namespace {
40 40
41 static bool g_initialized = false; 41 static bool g_initialized = false;
42 static webkit_glue::WebThreadImpl* g_impl_thread = NULL; 42 static webkit_glue::WebThreadImpl* g_impl_thread = NULL;
43 static bool g_use_direct_gl = false; 43 static bool g_use_direct_gl = false;
44 44
45 // Adapts a pure WebGraphicsContext3D into a WebCompositorOutputSurface. 45 // Adapts a pure WebGraphicsContext3D into a cc::OutputSurface.
46 class WebGraphicsContextToOutputSurfaceAdapter : 46 class WebGraphicsContextToOutputSurfaceAdapter : public cc::OutputSurface {
47 public WebKit::WebCompositorOutputSurface { 47 public:
48 public: 48 explicit WebGraphicsContextToOutputSurfaceAdapter(
49 explicit WebGraphicsContextToOutputSurfaceAdapter( 49 WebKit::WebGraphicsContext3D* context)
50 WebKit::WebGraphicsContext3D* context) 50 : context3d_(context),
51 : m_context3D(context) 51 client_(0) {
52 , m_client(0) 52 }
53 {
54 }
55 53
56 virtual bool bindToClient( 54 virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE {
57 WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE 55 DCHECK(client);
58 { 56 if (!context3d_->makeContextCurrent())
59 DCHECK(client); 57 return false;
60 if (!m_context3D->makeContextCurrent()) 58 client_ = client;
61 return false; 59 return true;
62 m_client = client; 60 }
63 return true;
64 }
65 61
66 virtual const Capabilities& capabilities() const OVERRIDE 62 virtual const struct Capabilities& Capabilities() const OVERRIDE {
67 { 63 return capabilities_;
68 return m_capabilities; 64 }
69 }
70 65
71 virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE 66 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE {
72 { 67 return context3d_.get();
73 return m_context3D.get(); 68 }
74 }
75 69
76 virtual void sendFrameToParentCompositor( 70 virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE {
77 const WebKit::WebCompositorFrame&) OVERRIDE 71 return NULL;
78 { 72 }
79 }
80 73
81 private: 74 virtual void SendFrameToParentCompositor(
82 scoped_ptr<WebKit::WebGraphicsContext3D> m_context3D; 75 const cc::CompositorFrame&) OVERRIDE {
83 Capabilities m_capabilities; 76 }
84 WebKit::WebCompositorOutputSurfaceClient* m_client; 77
78 private:
79 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
80 struct Capabilities capabilities_;
81 cc::OutputSurfaceClient* client_;
85 }; 82 };
86 83
87 } // anonymous namespace 84 } // anonymous namespace
88 85
89 namespace content { 86 namespace content {
90 87
91 // static 88 // static
92 Compositor* Compositor::Create(Client* client) { 89 Compositor* Compositor::Create(Client* client) {
93 return client ? new CompositorImpl(client) : NULL; 90 return client ? new CompositorImpl(client) : NULL;
94 } 91 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 void CompositorImpl::animate(double monotonicFrameBeginTime) { 268 void CompositorImpl::animate(double monotonicFrameBeginTime) {
272 } 269 }
273 270
274 void CompositorImpl::layout() { 271 void CompositorImpl::layout() {
275 } 272 }
276 273
277 void CompositorImpl::applyScrollAndScale(gfx::Vector2d scrollDelta, 274 void CompositorImpl::applyScrollAndScale(gfx::Vector2d scrollDelta,
278 float pageScale) { 275 float pageScale) {
279 } 276 }
280 277
281 scoped_ptr<WebKit::WebCompositorOutputSurface> 278 scoped_ptr<cc::OutputSurface> CompositorImpl::createOutputSurface() {
282 CompositorImpl::createOutputSurface() {
283 if (g_use_direct_gl) { 279 if (g_use_direct_gl) {
284 WebKit::WebGraphicsContext3D::Attributes attrs; 280 WebKit::WebGraphicsContext3D::Attributes attrs;
285 attrs.shareResources = false; 281 attrs.shareResources = false;
286 attrs.noAutomaticFlushes = true; 282 attrs.noAutomaticFlushes = true;
287 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessImpl> context( 283 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessImpl> context(
288 webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWindow( 284 webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWindow(
289 attrs, 285 attrs,
290 window_, 286 window_,
291 NULL)); 287 NULL));
292 return scoped_ptr<WebKit::WebCompositorOutputSurface>( 288 return scoped_ptr<cc::OutputSurface>(
293 new WebGraphicsContextToOutputSurfaceAdapter(context.release())); 289 new WebGraphicsContextToOutputSurfaceAdapter(context.release()));
294 } else { 290 } else {
295 DCHECK(window_ && surface_id_); 291 DCHECK(window_ && surface_id_);
296 WebKit::WebGraphicsContext3D::Attributes attrs; 292 WebKit::WebGraphicsContext3D::Attributes attrs;
297 attrs.shareResources = true; 293 attrs.shareResources = true;
298 attrs.noAutomaticFlushes = true; 294 attrs.noAutomaticFlushes = true;
299 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); 295 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
300 GURL url("chrome://gpu/Compositor::createContext3D"); 296 GURL url("chrome://gpu/Compositor::createContext3D");
301 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 297 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
302 new WebGraphicsContext3DCommandBufferImpl(surface_id_, 298 new WebGraphicsContext3DCommandBufferImpl(surface_id_,
303 url, 299 url,
304 factory, 300 factory,
305 weak_factory_.GetWeakPtr())); 301 weak_factory_.GetWeakPtr()));
306 if (!context->Initialize( 302 if (!context->Initialize(
307 attrs, 303 attrs,
308 false, 304 false,
309 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) { 305 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) {
310 LOG(ERROR) << "Failed to create 3D context for compositor."; 306 LOG(ERROR) << "Failed to create 3D context for compositor.";
311 return scoped_ptr<WebKit::WebCompositorOutputSurface>(); 307 return scoped_ptr<cc::OutputSurface>();
312 } 308 }
313 return scoped_ptr<WebKit::WebCompositorOutputSurface>( 309 return scoped_ptr<cc::OutputSurface>(
314 new WebGraphicsContextToOutputSurfaceAdapter(context.release())); 310 new WebGraphicsContextToOutputSurfaceAdapter(context.release()));
315 } 311 }
316 } 312 }
317 313
318 scoped_ptr<cc::InputHandler> CompositorImpl::createInputHandler() { 314 scoped_ptr<cc::InputHandler> CompositorImpl::createInputHandler() {
319 return scoped_ptr<cc::InputHandler>(); 315 return scoped_ptr<cc::InputHandler>();
320 } 316 }
321 317
322 void CompositorImpl::didRecreateOutputSurface(bool success) { 318 void CompositorImpl::didRecreateOutputSurface(bool success) {
323 } 319 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 case ANDROID_BITMAP_FORMAT_RGBA_8888: 395 case ANDROID_BITMAP_FORMAT_RGBA_8888:
400 return GL_UNSIGNED_BYTE; 396 return GL_UNSIGNED_BYTE;
401 break; 397 break;
402 case ANDROID_BITMAP_FORMAT_RGB_565: 398 case ANDROID_BITMAP_FORMAT_RGB_565:
403 default: 399 default:
404 return GL_UNSIGNED_SHORT_5_6_5; 400 return GL_UNSIGNED_SHORT_5_6_5;
405 } 401 }
406 } 402 }
407 403
408 } // namespace content 404 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | content/browser/renderer_host/image_transport_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698