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

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: Created 8 years, 5 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/logging.h"
8 #include "base/memory/scoped_ptr.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 "content/public/browser/android/draw_delegate.h"
15 #include "ui/gfx/native_widget_types.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
17
18 #include <android/native_window_jni.h>
19
20 using content::BrowserGpuChannelHostFactory;
21
22 namespace {
23 class CmdBufferGraphicsContext : public content::GraphicsContext {
Satish 2012/07/27 09:49:24 code within namespace{} isn't indented to the righ
no sievers 2012/07/31 01:28:44 Done.
24 public:
25 CmdBufferGraphicsContext(WebGraphicsContext3DCommandBufferImpl* context,
26 int surface_id,
27 ANativeWindow* window,
28 int texture_id1,
29 int texture_id2)
30 : context_(context),
31 surface_id_(surface_id),
32 window_(window) {
33 texture_id_[0] = texture_id1;
34 texture_id_[1] = texture_id2;
35 }
36
37 virtual ~CmdBufferGraphicsContext() {
38 context_->makeContextCurrent();
39 context_->deleteTexture(texture_id_[0]);
40 context_->deleteTexture(texture_id_[1]);
41 context_->finish();
42 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get();
43 tracker->RemoveSurface(surface_id_);
44 ANativeWindow_release(window_);
45 }
46
47 virtual WebKit::WebGraphicsContext3D* GetContext3D() {
48 return context_.get();
49 }
50 virtual uint32 InsertSyncPoint() {
51 return context_->insertSyncPoint();
52 }
53 private:
54 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
55 int surface_id_;
56 ANativeWindow* window_;
57 int texture_id_[2];
58 };
59 } // anonymous namespace
Ted C 2012/07/27 20:31:15 two spaces between the } and //
no sievers 2012/07/31 01:28:44 Done.
60
61 namespace content {
62
63 GraphicsContext::GraphicsContext() {
64 }
65
66 GraphicsContext::~GraphicsContext() {
67 }
68
69 // static
70 GraphicsContext* GraphicsContext::CreateForUI(
71 ANativeWindow* window) {
72 DCHECK(window);
73 LOG(INFO) << "Creating context for window " << window;
Ted C 2012/07/27 20:31:15 remove?
no sievers 2012/07/31 01:28:44 Done.
74 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get();
75
76 ANativeWindow_acquire(window);
77 int surface_id = tracker->AddSurfaceForNativeWidget(window);
78
79 tracker->SetSurfaceHandle(
80 surface_id,
81 gfx::GLSurfaceHandle(gfx::kDummyPluginWindow, false));
82
83 WebKit::WebGraphicsContext3D::Attributes attrs;
84 attrs.shareResources = true;
85 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
86 GURL url("chrome://gpu/GpuProcessTransportHelper::CreateContext");
87 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
88 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
89 new WebGraphicsContext3DCommandBufferImpl(
90 surface_id,
91 url,
92 factory,
93 swap_client));
94 if (!context->Initialize(
Satish 2012/07/27 09:49:24 suggest using braces for if statements that span m
no sievers 2012/07/31 01:28:44 Done.
95 attrs,
96 false,
97 content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIA LIZE))
Ted C 2012/07/27 20:31:15 this is in fact the longest constant known to man.
no sievers 2012/07/31 01:28:44 Done.
98 return NULL;
99
100 context->makeContextCurrent();
101
102 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle(
103 gfx::kNullPluginWindow, true);
104 handle.parent_gpu_process_id = context->GetGPUProcessID();
105 handle.parent_client_id = context->GetChannelID();
106 handle.parent_context_id = context->GetContextID();
107 handle.parent_texture_id[0] = context->createTexture();
108 handle.parent_texture_id[1] = context->createTexture();
109 handle.sync_point = context->insertSyncPoint();
110
111 DrawDelegate::GetInstance()->SetDrawSurface(handle);
112
113 return new CmdBufferGraphicsContext(
114 context.release(), surface_id, window,
115 handle.parent_texture_id[0],
116 handle.parent_texture_id[1]);
117 }
118
119 } // namespace content
Ted C 2012/07/27 20:31:15 one more space here too
no sievers 2012/07/31 01:28:44 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698