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

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

Issue 10823051: ContentShell rendering support on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address jam's comments Created 8 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/browser/android/graphics_context.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "content/browser/android/draw_delegate_impl.h"
9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
10 #include "content/browser/gpu/gpu_surface_tracker.h"
11 #include "content/common/gpu/client/gpu_channel_host.h"
12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
13 #include "content/common/gpu/gpu_process_launch_causes.h"
14 #include "ui/gfx/native_widget_types.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
16
17 #include <android/native_window_jni.h>
18
19 using content::BrowserGpuChannelHostFactory;
20
21 namespace {
22
23 // GraphicsContext implementation using a gpu command buffer.
24 class CmdBufferGraphicsContext : public content::GraphicsContext {
25 public:
26 CmdBufferGraphicsContext(WebGraphicsContext3DCommandBufferImpl* context,
27 int surface_id,
28 ANativeWindow* window,
29 int texture_id1,
30 int texture_id2)
31 : context_(context),
32 surface_id_(surface_id),
33 window_(window) {
34 texture_id_[0] = texture_id1;
35 texture_id_[1] = texture_id2;
36 }
37
38 virtual ~CmdBufferGraphicsContext() {
39 context_->makeContextCurrent();
40 context_->deleteTexture(texture_id_[0]);
41 context_->deleteTexture(texture_id_[1]);
42 context_->finish();
43 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get();
44 tracker->RemoveSurface(surface_id_);
45 ANativeWindow_release(window_);
46 }
47
48 virtual WebKit::WebGraphicsContext3D* GetContext3D() {
49 return context_.get();
50 }
51 virtual uint32 InsertSyncPoint() {
52 return context_->insertSyncPoint();
53 }
54
55 private:
56 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
57 int surface_id_;
58 ANativeWindow* window_;
59 int texture_id_[2];
60 };
61
62 } // anonymous namespace
63
64 namespace content {
65
66 // static
67 GraphicsContext* GraphicsContext::CreateForUI(
68 ANativeWindow* window) {
69 DCHECK(window);
70 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get();
71
72 ANativeWindow_acquire(window);
73 int surface_id = tracker->AddSurfaceForNativeWidget(window);
74
75 tracker->SetSurfaceHandle(
76 surface_id,
77 gfx::GLSurfaceHandle(gfx::kDummyPluginWindow, false));
78
79 WebKit::WebGraphicsContext3D::Attributes attrs;
80 attrs.shareResources = true;
81 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
82 GURL url("chrome://gpu/GpuProcessTransportHelper::CreateContext");
83 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
84 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
85 new WebGraphicsContext3DCommandBufferImpl(
86 surface_id,
87 url,
88 factory,
89 swap_client));
90 if (!context->Initialize(
91 attrs,
92 false,
93 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) {
94 return NULL;
95 }
96
97 context->makeContextCurrent();
98
99 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle(
100 gfx::kNullPluginWindow, true);
101 handle.parent_gpu_process_id = context->GetGPUProcessID();
102 handle.parent_client_id = context->GetChannelID();
103 handle.parent_context_id = context->GetContextID();
104 handle.parent_texture_id[0] = context->createTexture();
105 handle.parent_texture_id[1] = context->createTexture();
106 handle.sync_point = context->insertSyncPoint();
107
108 DrawDelegateImpl::GetInstance()->SetDrawSurface(handle);
109
110 return new CmdBufferGraphicsContext(
111 context.release(), surface_id, window,
112 handle.parent_texture_id[0],
113 handle.parent_texture_id[1]);
114 }
115
116 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/draw_delegate_impl.cc ('k') | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698