| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #endif | 72 #endif |
| 73 | 73 |
| 74 } // namespace anonymous | 74 } // namespace anonymous |
| 75 | 75 |
| 76 RendererGLContext::~RendererGLContext() { | 76 RendererGLContext::~RendererGLContext() { |
| 77 Destroy(); | 77 Destroy(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 RendererGLContext* RendererGLContext::CreateViewContext( | 80 RendererGLContext* RendererGLContext::CreateViewContext( |
| 81 GpuChannelHost* channel, | 81 GpuChannelHost* channel, |
| 82 int render_view_id, | 82 int32 surface_id, |
| 83 RendererGLContext* share_group, | 83 RendererGLContext* share_group, |
| 84 const char* allowed_extensions, | 84 const char* allowed_extensions, |
| 85 const int32* attrib_list, | 85 const int32* attrib_list, |
| 86 const GURL& active_url, | 86 const GURL& active_url, |
| 87 gfx::GpuPreference gpu_preference) { | 87 gfx::GpuPreference gpu_preference) { |
| 88 #if defined(ENABLE_GPU) | 88 #if defined(ENABLE_GPU) |
| 89 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 89 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); |
| 90 if (!context->Initialize( | 90 if (!context->Initialize( |
| 91 true, | 91 true, |
| 92 render_view_id, | 92 surface_id, |
| 93 gfx::Size(), | 93 gfx::Size(), |
| 94 share_group, | 94 share_group, |
| 95 allowed_extensions, | 95 allowed_extensions, |
| 96 attrib_list, | 96 attrib_list, |
| 97 active_url, | 97 active_url, |
| 98 gpu_preference)) | 98 gpu_preference)) |
| 99 return NULL; | 99 return NULL; |
| 100 | 100 |
| 101 return context.release(); | 101 return context.release(); |
| 102 #else | 102 #else |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 command_buffer_(NULL), | 282 command_buffer_(NULL), |
| 283 gles2_helper_(NULL), | 283 gles2_helper_(NULL), |
| 284 transfer_buffer_id_(-1), | 284 transfer_buffer_id_(-1), |
| 285 gles2_implementation_(NULL), | 285 gles2_implementation_(NULL), |
| 286 last_error_(SUCCESS), | 286 last_error_(SUCCESS), |
| 287 frame_number_(0) { | 287 frame_number_(0) { |
| 288 DCHECK(channel); | 288 DCHECK(channel); |
| 289 } | 289 } |
| 290 | 290 |
| 291 bool RendererGLContext::Initialize(bool onscreen, | 291 bool RendererGLContext::Initialize(bool onscreen, |
| 292 int render_view_id, | 292 int32 surface_id, |
| 293 const gfx::Size& size, | 293 const gfx::Size& size, |
| 294 RendererGLContext* share_group, | 294 RendererGLContext* share_group, |
| 295 const char* allowed_extensions, | 295 const char* allowed_extensions, |
| 296 const int32* attrib_list, | 296 const int32* attrib_list, |
| 297 const GURL& active_url, | 297 const GURL& active_url, |
| 298 gfx::GpuPreference gpu_preference) { | 298 gfx::GpuPreference gpu_preference) { |
| 299 DCHECK(CalledOnValidThread()); | 299 DCHECK(CalledOnValidThread()); |
| 300 DCHECK(size.width() >= 0 && size.height() >= 0); | 300 DCHECK(size.width() >= 0 && size.height() >= 0); |
| 301 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", | 301 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", |
| 302 "on_screen", onscreen, "num_pixels", size.GetArea()); | 302 "on_screen", onscreen, "num_pixels", size.GetArea()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 attrib_list = NULL; | 341 attrib_list = NULL; |
| 342 break; | 342 break; |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 | 345 |
| 346 // Create a proxy to a command buffer in the GPU process. | 346 // Create a proxy to a command buffer in the GPU process. |
| 347 if (onscreen) { | 347 if (onscreen) { |
| 348 TRACE_EVENT0("gpu", | 348 TRACE_EVENT0("gpu", |
| 349 "RendererGLContext::Initialize::CreateViewCommandBuffer"); | 349 "RendererGLContext::Initialize::CreateViewCommandBuffer"); |
| 350 command_buffer_ = channel_->CreateViewCommandBuffer( | 350 command_buffer_ = channel_->CreateViewCommandBuffer( |
| 351 render_view_id, | 351 surface_id, |
| 352 share_group ? share_group->command_buffer_ : NULL, | 352 share_group ? share_group->command_buffer_ : NULL, |
| 353 allowed_extensions, | 353 allowed_extensions, |
| 354 attribs, | 354 attribs, |
| 355 active_url, | 355 active_url, |
| 356 gpu_preference); | 356 gpu_preference); |
| 357 } else { | 357 } else { |
| 358 command_buffer_ = channel_->CreateOffscreenCommandBuffer( | 358 command_buffer_ = channel_->CreateOffscreenCommandBuffer( |
| 359 size, | 359 size, |
| 360 share_group ? share_group->command_buffer_ : NULL, | 360 share_group ? share_group->command_buffer_ : NULL, |
| 361 allowed_extensions, | 361 allowed_extensions, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 void RendererGLContext::OnContextLost() { | 456 void RendererGLContext::OnContextLost() { |
| 457 if (!context_lost_callback_.is_null()) { | 457 if (!context_lost_callback_.is_null()) { |
| 458 RendererGLContext::ContextLostReason reason = kUnknown; | 458 RendererGLContext::ContextLostReason reason = kUnknown; |
| 459 if (command_buffer_) { | 459 if (command_buffer_) { |
| 460 reason = ConvertReason( | 460 reason = ConvertReason( |
| 461 command_buffer_->GetLastState().context_lost_reason); | 461 command_buffer_->GetLastState().context_lost_reason); |
| 462 } | 462 } |
| 463 context_lost_callback_.Run(reason); | 463 context_lost_callback_.Run(reason); |
| 464 } | 464 } |
| 465 } | 465 } |
| OLD | NEW |