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