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