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

Side by Side Diff: chrome/renderer/ggl/ggl.cc

Issue 3067026: Initial port of accelerated compositor to Mac OS X 10.6. Reused... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome/renderer/ggl/ggl.h ('k') | chrome/renderer/gpu_channel_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "base/ref_counted.h" 7 #include "base/ref_counted.h"
8 #include "base/singleton.h" 8 #include "base/singleton.h"
9 #include "base/thread_local.h" 9 #include "base/thread_local.h"
10 #include "base/weak_ptr.h" 10 #include "base/weak_ptr.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } // namespace anonymous 52 } // namespace anonymous
53 53
54 // Manages a GL context. 54 // Manages a GL context.
55 class Context : public base::SupportsWeakPtr<Context> { 55 class Context : public base::SupportsWeakPtr<Context> {
56 public: 56 public:
57 Context(GpuChannelHost* channel, Context* parent); 57 Context(GpuChannelHost* channel, Context* parent);
58 ~Context(); 58 ~Context();
59 59
60 // Initialize a GGL context that can be used in association with a a GPU 60 // Initialize a GGL context that can be used in association with a a GPU
61 // channel acquired from a RenderWidget or RenderView. 61 // channel acquired from a RenderWidget or RenderView.
62 bool Initialize(gfx::NativeViewId view, const gfx::Size& size); 62 bool Initialize(gfx::NativeViewId view,
63 int render_view_id,
64 const gfx::Size& size);
65
66 #if defined(OS_MACOSX)
67 // Asynchronously resizes an onscreen frame buffer.
68 void ResizeOnscreen(const gfx::Size& size);
69 #endif
63 70
64 // Asynchronously resizes an offscreen frame buffer. 71 // Asynchronously resizes an offscreen frame buffer.
65 void ResizeOffscreen(const gfx::Size& size); 72 void ResizeOffscreen(const gfx::Size& size);
66 73
67 // For an offscreen frame buffer context, return the frame buffer ID with 74 // For an offscreen frame buffer context, return the frame buffer ID with
68 // respect to the parent. 75 // respect to the parent.
69 uint32 parent_texture_id() const { 76 uint32 parent_texture_id() const {
70 return parent_texture_id_; 77 return parent_texture_id_;
71 } 78 }
72 79
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 gles2_helper_(NULL), 114 gles2_helper_(NULL),
108 transfer_buffer_id_(0), 115 transfer_buffer_id_(0),
109 gles2_implementation_(NULL) { 116 gles2_implementation_(NULL) {
110 DCHECK(channel); 117 DCHECK(channel);
111 } 118 }
112 119
113 Context::~Context() { 120 Context::~Context() {
114 Destroy(); 121 Destroy();
115 } 122 }
116 123
117 bool Context::Initialize(gfx::NativeViewId view, const gfx::Size& size) { 124 bool Context::Initialize(gfx::NativeViewId view,
125 int render_view_id,
126 const gfx::Size& size) {
118 DCHECK(size.width() >= 0 && size.height() >= 0); 127 DCHECK(size.width() >= 0 && size.height() >= 0);
119 128
120 if (channel_->state() != GpuChannelHost::CONNECTED) 129 if (channel_->state() != GpuChannelHost::CONNECTED)
121 return false; 130 return false;
122 131
123 // Ensure the gles2 library is initialized first in a thread safe way. 132 // Ensure the gles2 library is initialized first in a thread safe way.
124 Singleton<GLES2Initializer>::get(); 133 Singleton<GLES2Initializer>::get();
125 134
126 // Allocate a frame buffer ID with respect to the parent. 135 // Allocate a frame buffer ID with respect to the parent.
127 if (parent_.get()) { 136 if (parent_.get()) {
128 // Flush any remaining commands in the parent context to make sure the 137 // Flush any remaining commands in the parent context to make sure the
129 // texture id accounting stays consistent. 138 // texture id accounting stays consistent.
130 int32 token = parent_->gles2_helper_->InsertToken(); 139 int32 token = parent_->gles2_helper_->InsertToken();
131 parent_->gles2_helper_->WaitForToken(token); 140 parent_->gles2_helper_->WaitForToken(token);
132 parent_texture_id_ = parent_->gles2_implementation_->MakeTextureId(); 141 parent_texture_id_ = parent_->gles2_implementation_->MakeTextureId();
133 } 142 }
134 143
135 // Create a proxy to a command buffer in the GPU process. 144 // Create a proxy to a command buffer in the GPU process.
136 if (view) { 145 if (view) {
137 command_buffer_ = channel_->CreateViewCommandBuffer(view); 146 command_buffer_ =
147 channel_->CreateViewCommandBuffer(view, render_view_id);
138 } else { 148 } else {
139 CommandBufferProxy* parent_command_buffer = 149 CommandBufferProxy* parent_command_buffer =
140 parent_.get() ? parent_->command_buffer_ : NULL; 150 parent_.get() ? parent_->command_buffer_ : NULL;
141 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 151 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
142 parent_command_buffer, 152 parent_command_buffer,
143 size, 153 size,
144 parent_texture_id_); 154 parent_texture_id_);
145 } 155 }
146 if (!command_buffer_) { 156 if (!command_buffer_) {
147 Destroy(); 157 Destroy();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 gles2_implementation_ = new gpu::gles2::GLES2Implementation( 192 gles2_implementation_ = new gpu::gles2::GLES2Implementation(
183 gles2_helper_, 193 gles2_helper_,
184 transfer_buffer.size, 194 transfer_buffer.size,
185 transfer_buffer.ptr, 195 transfer_buffer.ptr,
186 transfer_buffer_id_, 196 transfer_buffer_id_,
187 false); 197 false);
188 198
189 return true; 199 return true;
190 } 200 }
191 201
202 #if defined(OS_MACOSX)
203 void Context::ResizeOnscreen(const gfx::Size& size) {
204 DCHECK(size.width() > 0 && size.height() > 0);
205 command_buffer_->SetWindowSize(size);
206 }
207 #endif
208
192 void Context::ResizeOffscreen(const gfx::Size& size) { 209 void Context::ResizeOffscreen(const gfx::Size& size) {
193 DCHECK(size.width() > 0 && size.height() > 0); 210 DCHECK(size.width() > 0 && size.height() > 0);
194 command_buffer_->ResizeOffscreenFrameBuffer(size); 211 command_buffer_->ResizeOffscreenFrameBuffer(size);
195 } 212 }
196 213
197 void Context::Destroy() { 214 void Context::Destroy() {
198 if (parent_.get() && parent_texture_id_ != 0) 215 if (parent_.get() && parent_texture_id_ != 0)
199 parent_->gles2_implementation_->FreeTextureId(parent_texture_id_); 216 parent_->gles2_implementation_->FreeTextureId(parent_texture_id_);
200 217
201 delete gles2_implementation_; 218 delete gles2_implementation_;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 274 }
258 } 275 }
259 276
260 // TODO(gman): Remove This 277 // TODO(gman): Remove This
261 void Context::DisableShaderTranslation() { 278 void Context::DisableShaderTranslation() {
262 gles2_implementation_->CommandBufferEnable(PEPPER3D_SKIP_GLSL_TRANSLATION); 279 gles2_implementation_->CommandBufferEnable(PEPPER3D_SKIP_GLSL_TRANSLATION);
263 } 280 }
264 281
265 #endif // ENABLE_GPU 282 #endif // ENABLE_GPU
266 283
267 Context* CreateViewContext(GpuChannelHost* channel, gfx::NativeViewId view) { 284 Context* CreateViewContext(GpuChannelHost* channel,
285 gfx::NativeViewId view,
286 int render_view_id) {
268 #if defined(ENABLE_GPU) 287 #if defined(ENABLE_GPU)
269 scoped_ptr<Context> context(new Context(channel, NULL)); 288 scoped_ptr<Context> context(new Context(channel, NULL));
270 if (!context->Initialize(view, gfx::Size())) 289 if (!context->Initialize(view, render_view_id, gfx::Size()))
271 return NULL; 290 return NULL;
272 291
273 return context.release(); 292 return context.release();
274 #else 293 #else
275 return NULL; 294 return NULL;
276 #endif 295 #endif
277 } 296 }
278 297
298 #if defined(OS_MACOSX)
299 void ResizeOnscreenContext(Context* context, const gfx::Size& size) {
300 #if defined(ENABLE_GPU)
301 context->ResizeOnscreen(size);
302 #endif
303 }
304 #endif
305
279 Context* CreateOffscreenContext(GpuChannelHost* channel, 306 Context* CreateOffscreenContext(GpuChannelHost* channel,
280 Context* parent, 307 Context* parent,
281 const gfx::Size& size) { 308 const gfx::Size& size) {
282 #if defined(ENABLE_GPU) 309 #if defined(ENABLE_GPU)
283 scoped_ptr<Context> context(new Context(channel, parent)); 310 scoped_ptr<Context> context(new Context(channel, parent));
284 if (!context->Initialize(0, size)) 311 if (!context->Initialize(0, 0, size))
285 return NULL; 312 return NULL;
286 313
287 return context.release(); 314 return context.release();
288 #else 315 #else
289 return NULL; 316 return NULL;
290 #endif 317 #endif
291 } 318 }
292 319
293 void ResizeOffscreenContext(Context* context, const gfx::Size& size) { 320 void ResizeOffscreenContext(Context* context, const gfx::Size& size) {
294 #if defined(ENABLE_GPU) 321 #if defined(ENABLE_GPU)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 387
361 // TODO(gman): Remove This 388 // TODO(gman): Remove This
362 void DisableShaderTranslation(Context* context) { 389 void DisableShaderTranslation(Context* context) {
363 #if defined(ENABLE_GPU) 390 #if defined(ENABLE_GPU)
364 if (context) { 391 if (context) {
365 context->DisableShaderTranslation(); 392 context->DisableShaderTranslation();
366 } 393 }
367 #endif 394 #endif
368 } 395 }
369 } // namespace ggl 396 } // namespace ggl
OLDNEW
« no previous file with comments | « chrome/renderer/ggl/ggl.h ('k') | chrome/renderer/gpu_channel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698