| 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/gpu/renderer_gl_context.h" | 5 #include "content/renderer/gpu/renderer_gl_context.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 base::LINKER_INITIALIZED); | 148 base::LINKER_INITIALIZED); |
| 149 | 149 |
| 150 } // namespace anonymous | 150 } // namespace anonymous |
| 151 | 151 |
| 152 RendererGLContext::~RendererGLContext() { | 152 RendererGLContext::~RendererGLContext() { |
| 153 Destroy(); | 153 Destroy(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 RendererGLContext* RendererGLContext::CreateViewContext( | 156 RendererGLContext* RendererGLContext::CreateViewContext( |
| 157 GpuChannelHost* channel, | 157 GpuChannelHost* channel, |
| 158 gfx::PluginWindowHandle render_surface, | |
| 159 int render_view_id, | 158 int render_view_id, |
| 160 const char* allowed_extensions, | 159 const char* allowed_extensions, |
| 161 const int32* attrib_list, | 160 const int32* attrib_list, |
| 162 const GURL& active_url) { | 161 const GURL& active_url) { |
| 163 #if defined(ENABLE_GPU) | 162 #if defined(ENABLE_GPU) |
| 164 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel, NULL)); | 163 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel, NULL)); |
| 165 if (!context->Initialize( | 164 if (!context->Initialize( |
| 166 true, | 165 true, |
| 167 render_surface, | |
| 168 render_view_id, | 166 render_view_id, |
| 169 gfx::Size(), | 167 gfx::Size(), |
| 170 allowed_extensions, | 168 allowed_extensions, |
| 171 attrib_list, | 169 attrib_list, |
| 172 active_url)) | 170 active_url)) |
| 173 return NULL; | 171 return NULL; |
| 174 | 172 |
| 175 return context.release(); | 173 return context.release(); |
| 176 #else | 174 #else |
| 177 return NULL; | 175 return NULL; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 190 GpuChannelHost* channel, | 188 GpuChannelHost* channel, |
| 191 RendererGLContext* parent, | 189 RendererGLContext* parent, |
| 192 const gfx::Size& size, | 190 const gfx::Size& size, |
| 193 const char* allowed_extensions, | 191 const char* allowed_extensions, |
| 194 const int32* attrib_list, | 192 const int32* attrib_list, |
| 195 const GURL& active_url) { | 193 const GURL& active_url) { |
| 196 #if defined(ENABLE_GPU) | 194 #if defined(ENABLE_GPU) |
| 197 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel, parent)); | 195 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel, parent)); |
| 198 if (!context->Initialize( | 196 if (!context->Initialize( |
| 199 false, | 197 false, |
| 200 gfx::kNullPluginWindow, | |
| 201 0, | 198 0, |
| 202 size, | 199 size, |
| 203 allowed_extensions, | 200 allowed_extensions, |
| 204 attrib_list, | 201 attrib_list, |
| 205 active_url)) | 202 active_url)) |
| 206 return NULL; | 203 return NULL; |
| 207 | 204 |
| 208 return context.release(); | 205 return context.release(); |
| 209 #else | 206 #else |
| 210 return NULL; | 207 return NULL; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 command_buffer_(NULL), | 351 command_buffer_(NULL), |
| 355 gles2_helper_(NULL), | 352 gles2_helper_(NULL), |
| 356 transfer_buffer_id_(-1), | 353 transfer_buffer_id_(-1), |
| 357 gles2_implementation_(NULL), | 354 gles2_implementation_(NULL), |
| 358 last_error_(SUCCESS), | 355 last_error_(SUCCESS), |
| 359 frame_number_(0) { | 356 frame_number_(0) { |
| 360 DCHECK(channel); | 357 DCHECK(channel); |
| 361 } | 358 } |
| 362 | 359 |
| 363 bool RendererGLContext::Initialize(bool onscreen, | 360 bool RendererGLContext::Initialize(bool onscreen, |
| 364 gfx::PluginWindowHandle render_surface, | |
| 365 int render_view_id, | 361 int render_view_id, |
| 366 const gfx::Size& size, | 362 const gfx::Size& size, |
| 367 const char* allowed_extensions, | 363 const char* allowed_extensions, |
| 368 const int32* attrib_list, | 364 const int32* attrib_list, |
| 369 const GURL& active_url) { | 365 const GURL& active_url) { |
| 370 DCHECK(size.width() >= 0 && size.height() >= 0); | 366 DCHECK(size.width() >= 0 && size.height() >= 0); |
| 371 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", | 367 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", |
| 372 "on_screen", onscreen, "num_pixels", size.GetArea()); | 368 "on_screen", onscreen, "num_pixels", size.GetArea()); |
| 373 | 369 |
| 374 if (channel_->state() != GpuChannelHost::kConnected) | 370 if (channel_->state() != GpuChannelHost::kConnected) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 default: | 405 default: |
| 410 last_error_ = BAD_ATTRIBUTE; | 406 last_error_ = BAD_ATTRIBUTE; |
| 411 attribs.push_back(NONE); | 407 attribs.push_back(NONE); |
| 412 attrib_list = NULL; | 408 attrib_list = NULL; |
| 413 break; | 409 break; |
| 414 } | 410 } |
| 415 } | 411 } |
| 416 | 412 |
| 417 // Create a proxy to a command buffer in the GPU process. | 413 // Create a proxy to a command buffer in the GPU process. |
| 418 if (onscreen) { | 414 if (onscreen) { |
| 419 if (render_surface == gfx::kNullPluginWindow) { | 415 command_buffer_ = channel_->CreateViewCommandBuffer( |
| 420 LOG(ERROR) << "Invalid surface handle for onscreen context."; | 416 render_view_id, |
| 421 command_buffer_ = NULL; | 417 allowed_extensions, |
| 422 } else { | 418 attribs, |
| 423 command_buffer_ = channel_->CreateViewCommandBuffer( | 419 active_url); |
| 424 render_surface, | |
| 425 render_view_id, | |
| 426 allowed_extensions, | |
| 427 attribs, | |
| 428 active_url); | |
| 429 } | |
| 430 } else { | 420 } else { |
| 431 CommandBufferProxy* parent_command_buffer = | 421 CommandBufferProxy* parent_command_buffer = |
| 432 parent_.get() ? parent_->command_buffer_ : NULL; | 422 parent_.get() ? parent_->command_buffer_ : NULL; |
| 433 command_buffer_ = channel_->CreateOffscreenCommandBuffer( | 423 command_buffer_ = channel_->CreateOffscreenCommandBuffer( |
| 434 parent_command_buffer, | 424 parent_command_buffer, |
| 435 size, | 425 size, |
| 436 allowed_extensions, | 426 allowed_extensions, |
| 437 attribs, | 427 attribs, |
| 438 parent_texture_id_, | 428 parent_texture_id_, |
| 439 active_url); | 429 active_url); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 return false; | 567 return false; |
| 578 } | 568 } |
| 579 | 569 |
| 580 bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) { | 570 bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) { |
| 581 if (parent_.get()) { | 571 if (parent_.get()) { |
| 582 *child_to_parent_latch = child_to_parent_latch_; | 572 *child_to_parent_latch = child_to_parent_latch_; |
| 583 return true; | 573 return true; |
| 584 } | 574 } |
| 585 return false; | 575 return false; |
| 586 } | 576 } |
| OLD | NEW |