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