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

Side by Side Diff: content/browser/android/graphics_context.cc

Issue 10828356: Very basic Android browser-side compositing support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months 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/public/browser/android/graphics_context.h" 5 #include "content/browser/android/graphics_context.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/browser/android/draw_delegate_impl.h" 8 #include "content/browser/android/draw_delegate_impl.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/gpu/gpu_surface_tracker.h" 10 #include "content/browser/gpu/gpu_surface_tracker.h"
11 #include "content/common/gpu/client/gpu_channel_host.h" 11 #include "content/common/gpu/client/gpu_channel_host.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 "ui/gfx/native_widget_types.h" 14 #include "ui/gfx/native_widget_types.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
16 16
17 #include <android/native_window_jni.h> 17 #include <android/native_window_jni.h>
18 18
19 using content::BrowserGpuChannelHostFactory; 19 using content::BrowserGpuChannelHostFactory;
20 20
21 namespace { 21 namespace {
22 22
23 // GraphicsContext implementation using a gpu command buffer. 23 // GraphicsContext implementation using a gpu command buffer.
24 class CmdBufferGraphicsContext : public content::GraphicsContext { 24 class CmdBufferGraphicsContext : public content::GraphicsContext {
jam 2012/08/30 18:51:54 nit: now that this is not an interface, can this m
25 public: 25 public:
26 CmdBufferGraphicsContext(WebGraphicsContext3DCommandBufferImpl* context, 26 CmdBufferGraphicsContext(WebGraphicsContext3DCommandBufferImpl* context,
27 int surface_id, 27 int surface_id,
28 ANativeWindow* window, 28 ANativeWindow* window,
29 int texture_id1, 29 int texture_id1,
30 int texture_id2) 30 int texture_id2)
31 : context_(context), 31 : context_(context),
32 surface_id_(surface_id), 32 surface_id_(surface_id),
33 window_(window) { 33 window_(window) {
34 texture_id_[0] = texture_id1; 34 texture_id_[0] = texture_id1;
35 texture_id_[1] = texture_id2; 35 texture_id_[1] = texture_id2;
36 } 36 }
37 37
38 virtual ~CmdBufferGraphicsContext() { 38 virtual ~CmdBufferGraphicsContext() {
39 context_->makeContextCurrent(); 39 context_->makeContextCurrent();
40 context_->deleteTexture(texture_id_[0]); 40 context_->deleteTexture(texture_id_[0]);
41 context_->deleteTexture(texture_id_[1]); 41 context_->deleteTexture(texture_id_[1]);
42 context_->finish(); 42 context_->finish();
43 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); 43 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get();
44 tracker->RemoveSurface(surface_id_); 44 tracker->RemoveSurface(surface_id_);
45 ANativeWindow_release(window_); 45 ANativeWindow_release(window_);
46 } 46 }
47 47
48 virtual WebKit::WebGraphicsContext3D* GetContext3D() { 48 virtual uint32 InsertSyncPoint() OVERRIDE {
49 return context_.get(); 49 return context_->insertSyncPoint();
50 } 50 }
51 virtual uint32 InsertSyncPoint() { 51
52 return context_->insertSyncPoint(); 52 virtual int GetSurfaceID() OVERRIDE {
53 return surface_id_;
53 } 54 }
54 55
55 private: 56 private:
56 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_; 57 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
57 int surface_id_; 58 int surface_id_;
58 ANativeWindow* window_; 59 ANativeWindow* window_;
59 int texture_id_[2]; 60 int texture_id_[2];
60 }; 61 };
61 62
62 } // anonymous namespace 63 } // anonymous namespace
(...skipping 13 matching lines...) Expand all
76 surface_id, 77 surface_id,
77 gfx::GLSurfaceHandle(gfx::kDummyPluginWindow, false)); 78 gfx::GLSurfaceHandle(gfx::kDummyPluginWindow, false));
78 79
79 WebKit::WebGraphicsContext3D::Attributes attrs; 80 WebKit::WebGraphicsContext3D::Attributes attrs;
80 attrs.shareResources = true; 81 attrs.shareResources = true;
81 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); 82 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
82 GURL url("chrome://gpu/GpuProcessTransportHelper::CreateContext"); 83 GURL url("chrome://gpu/GpuProcessTransportHelper::CreateContext");
83 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; 84 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
84 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 85 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
85 new WebGraphicsContext3DCommandBufferImpl( 86 new WebGraphicsContext3DCommandBufferImpl(
86 surface_id, 87 0,
87 url, 88 url,
88 factory, 89 factory,
89 swap_client)); 90 swap_client));
90 if (!context->Initialize( 91 if (!context->Initialize(
91 attrs, 92 attrs,
92 false, 93 false,
93 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) { 94 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) {
94 return NULL; 95 return NULL;
95 } 96 }
96 97
(...skipping 10 matching lines...) Expand all
107 108
108 DrawDelegateImpl::GetInstance()->SetDrawSurface(handle); 109 DrawDelegateImpl::GetInstance()->SetDrawSurface(handle);
109 110
110 return new CmdBufferGraphicsContext( 111 return new CmdBufferGraphicsContext(
111 context.release(), surface_id, window, 112 context.release(), surface_id, window,
112 handle.parent_texture_id[0], 113 handle.parent_texture_id[0],
113 handle.parent_texture_id[1]); 114 handle.parent_texture_id[1]);
114 } 115 }
115 116
116 } // namespace content 117 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698