Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/renderer/gpu/renderer_gl_context.cc

Issue 8233027: Support dynamic switching between integrated and discrete GPUs on Mac OS X. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 RendererGLContext::~RendererGLContext() { 78 RendererGLContext::~RendererGLContext() {
79 Destroy(); 79 Destroy();
80 } 80 }
81 81
82 RendererGLContext* RendererGLContext::CreateViewContext( 82 RendererGLContext* RendererGLContext::CreateViewContext(
83 GpuChannelHost* channel, 83 GpuChannelHost* channel,
84 int render_view_id, 84 int render_view_id,
85 RendererGLContext* share_group, 85 RendererGLContext* share_group,
86 const char* allowed_extensions, 86 const char* allowed_extensions,
87 const int32* attrib_list, 87 const int32* attrib_list,
88 const GURL& active_url) { 88 const GURL& active_url,
89 gfx::GpuPreference gpu_preference) {
89 #if defined(ENABLE_GPU) 90 #if defined(ENABLE_GPU)
90 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); 91 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel));
91 if (!context->Initialize( 92 if (!context->Initialize(
92 true, 93 true,
93 render_view_id, 94 render_view_id,
94 gfx::Size(), 95 gfx::Size(),
95 share_group, 96 share_group,
96 allowed_extensions, 97 allowed_extensions,
97 attrib_list, 98 attrib_list,
98 active_url)) 99 active_url,
100 gpu_preference))
99 return NULL; 101 return NULL;
100 102
101 return context.release(); 103 return context.release();
102 #else 104 #else
103 return NULL; 105 return NULL;
104 #endif 106 #endif
105 } 107 }
106 108
107 RendererGLContext* RendererGLContext::CreateOffscreenContext( 109 RendererGLContext* RendererGLContext::CreateOffscreenContext(
108 GpuChannelHost* channel, 110 GpuChannelHost* channel,
109 const gfx::Size& size, 111 const gfx::Size& size,
110 RendererGLContext* share_group, 112 RendererGLContext* share_group,
111 const char* allowed_extensions, 113 const char* allowed_extensions,
112 const int32* attrib_list, 114 const int32* attrib_list,
113 const GURL& active_url) { 115 const GURL& active_url,
116 gfx::GpuPreference gpu_preference) {
114 #if defined(ENABLE_GPU) 117 #if defined(ENABLE_GPU)
115 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); 118 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel));
116 if (!context->Initialize( 119 if (!context->Initialize(
117 false, 120 false,
118 0, 121 0,
119 size, 122 size,
120 share_group, 123 share_group,
121 allowed_extensions, 124 allowed_extensions,
122 attrib_list, 125 attrib_list,
123 active_url)) 126 active_url,
127 gpu_preference))
124 return NULL; 128 return NULL;
125 129
126 return context.release(); 130 return context.release();
127 #else 131 #else
128 return NULL; 132 return NULL;
129 #endif 133 #endif
130 } 134 }
131 135
132 bool RendererGLContext::SetParent(RendererGLContext* new_parent) { 136 bool RendererGLContext::SetParent(RendererGLContext* new_parent) {
133 if (parent_.get() == new_parent) 137 if (parent_.get() == new_parent)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 frame_number_(0) { 287 frame_number_(0) {
284 DCHECK(channel); 288 DCHECK(channel);
285 } 289 }
286 290
287 bool RendererGLContext::Initialize(bool onscreen, 291 bool RendererGLContext::Initialize(bool onscreen,
288 int render_view_id, 292 int render_view_id,
289 const gfx::Size& size, 293 const gfx::Size& size,
290 RendererGLContext* share_group, 294 RendererGLContext* share_group,
291 const char* allowed_extensions, 295 const char* allowed_extensions,
292 const int32* attrib_list, 296 const int32* attrib_list,
293 const GURL& active_url) { 297 const GURL& active_url,
298 gfx::GpuPreference gpu_preference) {
294 DCHECK(CalledOnValidThread()); 299 DCHECK(CalledOnValidThread());
295 DCHECK(size.width() >= 0 && size.height() >= 0); 300 DCHECK(size.width() >= 0 && size.height() >= 0);
296 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", 301 TRACE_EVENT2("gpu", "RendererGLContext::Initialize",
297 "on_screen", onscreen, "num_pixels", size.GetArea()); 302 "on_screen", onscreen, "num_pixels", size.GetArea());
298 303
299 if (channel_->state() != GpuChannelHost::kConnected) 304 if (channel_->state() != GpuChannelHost::kConnected)
300 return false; 305 return false;
301 306
302 // Ensure the gles2 library is initialized first in a thread safe way. 307 // Ensure the gles2 library is initialized first in a thread safe way.
303 g_gles2_initializer.Get(); 308 g_gles2_initializer.Get();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 345
341 // Create a proxy to a command buffer in the GPU process. 346 // Create a proxy to a command buffer in the GPU process.
342 if (onscreen) { 347 if (onscreen) {
343 TRACE_EVENT0("gpu", 348 TRACE_EVENT0("gpu",
344 "RendererGLContext::Initialize::CreateViewCommandBuffer"); 349 "RendererGLContext::Initialize::CreateViewCommandBuffer");
345 command_buffer_ = channel_->CreateViewCommandBuffer( 350 command_buffer_ = channel_->CreateViewCommandBuffer(
346 render_view_id, 351 render_view_id,
347 share_group ? share_group->command_buffer_ : NULL, 352 share_group ? share_group->command_buffer_ : NULL,
348 allowed_extensions, 353 allowed_extensions,
349 attribs, 354 attribs,
350 active_url); 355 active_url,
356 gpu_preference);
351 } else { 357 } else {
352 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 358 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
353 size, 359 size,
354 share_group ? share_group->command_buffer_ : NULL, 360 share_group ? share_group->command_buffer_ : NULL,
355 allowed_extensions, 361 allowed_extensions,
356 attribs, 362 attribs,
357 active_url); 363 active_url,
364 gpu_preference);
358 } 365 }
359 if (!command_buffer_) { 366 if (!command_buffer_) {
360 Destroy(); 367 Destroy();
361 return false; 368 return false;
362 } 369 }
363 370
364 { 371 {
365 TRACE_EVENT0("gpu", 372 TRACE_EVENT0("gpu",
366 "RendererGLContext::Initialize::InitializeCommandBuffer"); 373 "RendererGLContext::Initialize::InitializeCommandBuffer");
367 // Initiaize the command buffer. 374 // Initiaize the command buffer.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 void RendererGLContext::OnContextLost() { 456 void RendererGLContext::OnContextLost() {
450 if (!context_lost_callback_.is_null()) { 457 if (!context_lost_callback_.is_null()) {
451 RendererGLContext::ContextLostReason reason = kUnknown; 458 RendererGLContext::ContextLostReason reason = kUnknown;
452 if (command_buffer_) { 459 if (command_buffer_) {
453 reason = ConvertReason( 460 reason = ConvertReason(
454 command_buffer_->GetLastState().context_lost_reason); 461 command_buffer_->GetLastState().context_lost_reason);
455 } 462 }
456 context_lost_callback_.Run(reason); 463 context_lost_callback_.Run(reason);
457 } 464 }
458 } 465 }
OLDNEW
« no previous file with comments | « content/renderer/gpu/renderer_gl_context.h ('k') | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698