OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/renderer_gl_context.h" | 5 #include "content/renderer/renderer_gl_context.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 base::LINKER_INITIALIZED); | 149 base::LINKER_INITIALIZED); |
150 | 150 |
151 } // namespace anonymous | 151 } // namespace anonymous |
152 | 152 |
153 RendererGLContext::~RendererGLContext() { | 153 RendererGLContext::~RendererGLContext() { |
154 Destroy(); | 154 Destroy(); |
155 } | 155 } |
156 | 156 |
157 RendererGLContext* RendererGLContext::CreateViewContext( | 157 RendererGLContext* RendererGLContext::CreateViewContext( |
158 GpuChannelHost* channel, | 158 GpuChannelHost* channel, |
| 159 gfx::PluginWindowHandle render_surface, |
159 int render_view_id, | 160 int render_view_id, |
160 const char* allowed_extensions, | 161 const char* allowed_extensions, |
161 const int32* attrib_list, | 162 const int32* attrib_list, |
162 const GURL& active_url) { | 163 const GURL& active_url) { |
163 #if defined(ENABLE_GPU) | 164 #if defined(ENABLE_GPU) |
164 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel, NULL)); | 165 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel, NULL)); |
165 if (!context->Initialize( | 166 if (!context->Initialize( |
166 true, | 167 true, |
| 168 render_surface, |
167 render_view_id, | 169 render_view_id, |
168 gfx::Size(), | 170 gfx::Size(), |
169 allowed_extensions, | 171 allowed_extensions, |
170 attrib_list, | 172 attrib_list, |
171 active_url)) | 173 active_url)) |
172 return NULL; | 174 return NULL; |
173 | 175 |
174 return context.release(); | 176 return context.release(); |
175 #else | 177 #else |
176 return NULL; | 178 return NULL; |
(...skipping 12 matching lines...) Expand all Loading... |
189 GpuChannelHost* channel, | 191 GpuChannelHost* channel, |
190 RendererGLContext* parent, | 192 RendererGLContext* parent, |
191 const gfx::Size& size, | 193 const gfx::Size& size, |
192 const char* allowed_extensions, | 194 const char* allowed_extensions, |
193 const int32* attrib_list, | 195 const int32* attrib_list, |
194 const GURL& active_url) { | 196 const GURL& active_url) { |
195 #if defined(ENABLE_GPU) | 197 #if defined(ENABLE_GPU) |
196 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel, parent)); | 198 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel, parent)); |
197 if (!context->Initialize( | 199 if (!context->Initialize( |
198 false, | 200 false, |
| 201 gfx::kNullPluginWindow, |
199 0, | 202 0, |
200 size, | 203 size, |
201 allowed_extensions, | 204 allowed_extensions, |
202 attrib_list, | 205 attrib_list, |
203 active_url)) | 206 active_url)) |
204 return NULL; | 207 return NULL; |
205 | 208 |
206 return context.release(); | 209 return context.release(); |
207 #else | 210 #else |
208 return NULL; | 211 return NULL; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 latch_transfer_buffer_id_(-1), | 362 latch_transfer_buffer_id_(-1), |
360 command_buffer_(NULL), | 363 command_buffer_(NULL), |
361 gles2_helper_(NULL), | 364 gles2_helper_(NULL), |
362 transfer_buffer_id_(-1), | 365 transfer_buffer_id_(-1), |
363 gles2_implementation_(NULL), | 366 gles2_implementation_(NULL), |
364 last_error_(SUCCESS) { | 367 last_error_(SUCCESS) { |
365 DCHECK(channel); | 368 DCHECK(channel); |
366 } | 369 } |
367 | 370 |
368 bool RendererGLContext::Initialize(bool onscreen, | 371 bool RendererGLContext::Initialize(bool onscreen, |
| 372 gfx::PluginWindowHandle render_surface, |
369 int render_view_id, | 373 int render_view_id, |
370 const gfx::Size& size, | 374 const gfx::Size& size, |
371 const char* allowed_extensions, | 375 const char* allowed_extensions, |
372 const int32* attrib_list, | 376 const int32* attrib_list, |
373 const GURL& active_url) { | 377 const GURL& active_url) { |
374 DCHECK(size.width() >= 0 && size.height() >= 0); | 378 DCHECK(size.width() >= 0 && size.height() >= 0); |
375 | 379 |
376 if (channel_->state() != GpuChannelHost::kConnected) | 380 if (channel_->state() != GpuChannelHost::kConnected) |
377 return false; | 381 return false; |
378 | 382 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 default: | 415 default: |
412 last_error_ = BAD_ATTRIBUTE; | 416 last_error_ = BAD_ATTRIBUTE; |
413 attribs.push_back(NONE); | 417 attribs.push_back(NONE); |
414 attrib_list = NULL; | 418 attrib_list = NULL; |
415 break; | 419 break; |
416 } | 420 } |
417 } | 421 } |
418 | 422 |
419 // Create a proxy to a command buffer in the GPU process. | 423 // Create a proxy to a command buffer in the GPU process. |
420 if (onscreen) { | 424 if (onscreen) { |
421 command_buffer_ = channel_->CreateViewCommandBuffer( | 425 if (render_surface == gfx::kNullPluginWindow) { |
422 render_view_id, | 426 LOG(ERROR) << "Invalid surface handle for onscreen context."; |
423 allowed_extensions, | 427 command_buffer_ = NULL; |
424 attribs, | 428 } else { |
425 active_url); | 429 command_buffer_ = channel_->CreateViewCommandBuffer( |
| 430 render_surface, |
| 431 render_view_id, |
| 432 allowed_extensions, |
| 433 attribs, |
| 434 active_url); |
| 435 } |
426 } else { | 436 } else { |
427 CommandBufferProxy* parent_command_buffer = | 437 CommandBufferProxy* parent_command_buffer = |
428 parent_.get() ? parent_->command_buffer_ : NULL; | 438 parent_.get() ? parent_->command_buffer_ : NULL; |
429 command_buffer_ = channel_->CreateOffscreenCommandBuffer( | 439 command_buffer_ = channel_->CreateOffscreenCommandBuffer( |
430 parent_command_buffer, | 440 parent_command_buffer, |
431 size, | 441 size, |
432 allowed_extensions, | 442 allowed_extensions, |
433 attribs, | 443 attribs, |
434 parent_texture_id_, | 444 parent_texture_id_, |
435 active_url); | 445 active_url); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 584 } |
575 | 585 |
576 bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) { | 586 bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) { |
577 if (parent_.get()) { | 587 if (parent_.get()) { |
578 *child_to_parent_latch = child_to_parent_latch_; | 588 *child_to_parent_latch = child_to_parent_latch_; |
579 return true; | 589 return true; |
580 } | 590 } |
581 return false; | 591 return false; |
582 } | 592 } |
583 | 593 |
OLD | NEW |