| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 const char* allowed_extensions, | 88 const char* allowed_extensions, |
| 89 const int32* attrib_list, | 89 const int32* attrib_list, |
| 90 const GURL& active_url) { | 90 const GURL& active_url) { |
| 91 #if defined(ENABLE_GPU) | 91 #if defined(ENABLE_GPU) |
| 92 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 92 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); |
| 93 if (!context->Initialize( | 93 if (!context->Initialize( |
| 94 true, | 94 true, |
| 95 render_view_id, | 95 render_view_id, |
| 96 gfx::Size(), | 96 gfx::Size(), |
| 97 share_resources, | 97 share_resources, |
| 98 false, | |
| 99 share_group, | 98 share_group, |
| 100 allowed_extensions, | 99 allowed_extensions, |
| 101 attrib_list, | 100 attrib_list, |
| 102 active_url)) | 101 active_url)) |
| 103 return NULL; | 102 return NULL; |
| 104 | 103 |
| 105 return context.release(); | 104 return context.release(); |
| 106 #else | 105 #else |
| 107 return NULL; | 106 return NULL; |
| 108 #endif | 107 #endif |
| (...skipping 15 matching lines...) Expand all Loading... |
| 124 const char* allowed_extensions, | 123 const char* allowed_extensions, |
| 125 const int32* attrib_list, | 124 const int32* attrib_list, |
| 126 const GURL& active_url) { | 125 const GURL& active_url) { |
| 127 #if defined(ENABLE_GPU) | 126 #if defined(ENABLE_GPU) |
| 128 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 127 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); |
| 129 if (!context->Initialize( | 128 if (!context->Initialize( |
| 130 false, | 129 false, |
| 131 0, | 130 0, |
| 132 size, | 131 size, |
| 133 share_resources, | 132 share_resources, |
| 134 false, | |
| 135 share_group, | 133 share_group, |
| 136 allowed_extensions, | 134 allowed_extensions, |
| 137 attrib_list, | 135 attrib_list, |
| 138 active_url)) | 136 active_url)) |
| 139 return NULL; | 137 return NULL; |
| 140 | 138 |
| 141 return context.release(); | 139 return context.release(); |
| 142 #else | 140 #else |
| 143 return NULL; | 141 return NULL; |
| 144 #endif | 142 #endif |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 gles2_implementation_(NULL), | 301 gles2_implementation_(NULL), |
| 304 last_error_(SUCCESS), | 302 last_error_(SUCCESS), |
| 305 frame_number_(0) { | 303 frame_number_(0) { |
| 306 DCHECK(channel); | 304 DCHECK(channel); |
| 307 } | 305 } |
| 308 | 306 |
| 309 bool RendererGLContext::Initialize(bool onscreen, | 307 bool RendererGLContext::Initialize(bool onscreen, |
| 310 int render_view_id, | 308 int render_view_id, |
| 311 const gfx::Size& size, | 309 const gfx::Size& size, |
| 312 bool share_resources, | 310 bool share_resources, |
| 313 bool bind_generates_resource, | |
| 314 RendererGLContext* share_group, | 311 RendererGLContext* share_group, |
| 315 const char* allowed_extensions, | 312 const char* allowed_extensions, |
| 316 const int32* attrib_list, | 313 const int32* attrib_list, |
| 317 const GURL& active_url) { | 314 const GURL& active_url) { |
| 318 DCHECK(size.width() >= 0 && size.height() >= 0); | 315 DCHECK(size.width() >= 0 && size.height() >= 0); |
| 319 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", | 316 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", |
| 320 "on_screen", onscreen, "num_pixels", size.GetArea()); | 317 "on_screen", onscreen, "num_pixels", size.GetArea()); |
| 321 | 318 |
| 322 if (channel_->state() != GpuChannelHost::kConnected) | 319 if (channel_->state() != GpuChannelHost::kConnected) |
| 323 return false; | 320 return false; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 Destroy(); | 415 Destroy(); |
| 419 return false; | 416 return false; |
| 420 } | 417 } |
| 421 | 418 |
| 422 // Create the object exposing the OpenGL API. | 419 // Create the object exposing the OpenGL API. |
| 423 gles2_implementation_ = new gpu::gles2::GLES2Implementation( | 420 gles2_implementation_ = new gpu::gles2::GLES2Implementation( |
| 424 gles2_helper_, | 421 gles2_helper_, |
| 425 transfer_buffer.size, | 422 transfer_buffer.size, |
| 426 transfer_buffer.ptr, | 423 transfer_buffer.ptr, |
| 427 transfer_buffer_id_, | 424 transfer_buffer_id_, |
| 428 share_resources, | 425 share_resources); |
| 429 bind_generates_resource); | |
| 430 | 426 |
| 431 size_ = size; | 427 size_ = size; |
| 432 | 428 |
| 433 return true; | 429 return true; |
| 434 } | 430 } |
| 435 | 431 |
| 436 void RendererGLContext::Destroy() { | 432 void RendererGLContext::Destroy() { |
| 437 TRACE_EVENT0("gpu", "RendererGLContext::Destroy"); | 433 TRACE_EVENT0("gpu", "RendererGLContext::Destroy"); |
| 438 SetParent(NULL); | 434 SetParent(NULL); |
| 439 | 435 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 void RendererGLContext::OnContextLost() { | 469 void RendererGLContext::OnContextLost() { |
| 474 if (context_lost_callback_.get()) { | 470 if (context_lost_callback_.get()) { |
| 475 RendererGLContext::ContextLostReason reason = kUnknown; | 471 RendererGLContext::ContextLostReason reason = kUnknown; |
| 476 if (command_buffer_) { | 472 if (command_buffer_) { |
| 477 reason = ConvertReason( | 473 reason = ConvertReason( |
| 478 command_buffer_->GetLastState().context_lost_reason); | 474 command_buffer_->GetLastState().context_lost_reason); |
| 479 } | 475 } |
| 480 context_lost_callback_->Run(reason); | 476 context_lost_callback_->Run(reason); |
| 481 } | 477 } |
| 482 } | 478 } |
| OLD | NEW |