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

Side by Side Diff: ui/gfx/surface/accelerated_surface_mac.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
« no previous file with comments | « ui/gfx/surface/accelerated_surface_mac.h ('k') | views/widget/native_widget_wayland.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/gfx/surface/accelerated_surface_mac.h" 5 #include "ui/gfx/surface/accelerated_surface_mac.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/scoped_cftyperef.h" 8 #include "base/mac/scoped_cftyperef.h"
9 #include "ui/gfx/gl/gl_bindings.h" 9 #include "ui/gfx/gl/gl_bindings.h"
10 #include "ui/gfx/gl/gl_context.h" 10 #include "ui/gfx/gl/gl_context.h"
11 #include "ui/gfx/gl/gl_implementation.h" 11 #include "ui/gfx/gl/gl_implementation.h"
12 #include "ui/gfx/gl/gl_surface.h" 12 #include "ui/gfx/gl/gl_surface.h"
13 #include "ui/gfx/gl/scoped_make_current.h" 13 #include "ui/gfx/gl/scoped_make_current.h"
14 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/surface/io_surface_support_mac.h" 15 #include "ui/gfx/surface/io_surface_support_mac.h"
16 16
17 AcceleratedSurface::AcceleratedSurface() 17 AcceleratedSurface::AcceleratedSurface()
18 : io_surface_id_(0), 18 : io_surface_id_(0),
19 allocate_fbo_(false), 19 allocate_fbo_(false),
20 texture_(0), 20 texture_(0),
21 fbo_(0), 21 fbo_(0),
22 depth_stencil_renderbuffer_(0) { 22 depth_stencil_renderbuffer_(0) {
23 } 23 }
24 24
25 AcceleratedSurface::~AcceleratedSurface() {} 25 AcceleratedSurface::~AcceleratedSurface() {}
26 26
27 bool AcceleratedSurface::Initialize(gfx::GLContext* share_context, 27 bool AcceleratedSurface::Initialize(
28 bool allocate_fbo) { 28 gfx::GLContext* share_context,
29 bool allocate_fbo,
30 gfx::GpuPreference gpu_preference) {
29 allocate_fbo_ = allocate_fbo; 31 allocate_fbo_ = allocate_fbo;
30 32
31 // Ensure GL is initialized before trying to create an offscreen GL context. 33 // Ensure GL is initialized before trying to create an offscreen GL context.
32 if (!gfx::GLSurface::InitializeOneOff()) 34 if (!gfx::GLSurface::InitializeOneOff())
33 return false; 35 return false;
34 36
35 // Drawing to IOSurfaces via OpenGL only works with desktop GL and 37 // Drawing to IOSurfaces via OpenGL only works with desktop GL and
36 // not with the OSMesa software renderer. 38 // not with the OSMesa software renderer.
37 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) 39 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
38 return false; 40 return false;
39 41
40 gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( 42 gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(
41 false, gfx::Size(1, 1)); 43 false, gfx::Size(1, 1));
42 if (!gl_surface_.get()) { 44 if (!gl_surface_.get()) {
43 Destroy(); 45 Destroy();
44 return false; 46 return false;
45 } 47 }
46 48
47 gfx::GLShareGroup* share_group = 49 gfx::GLShareGroup* share_group =
48 share_context ? share_context->share_group() : NULL; 50 share_context ? share_context->share_group() : NULL;
49 51
50 gl_context_ = gfx::GLContext::CreateGLContext(share_group, 52 gl_context_ = gfx::GLContext::CreateGLContext(
51 gl_surface_.get()); 53 share_group,
54 gl_surface_.get(),
55 gpu_preference);
52 if (!gl_context_.get()) { 56 if (!gl_context_.get()) {
53 Destroy(); 57 Destroy();
54 return false; 58 return false;
55 } 59 }
56 60
57 // Now we're ready to handle SetSurfaceSize calls, which will 61 // Now we're ready to handle SetSurfaceSize calls, which will
58 // allocate and/or reallocate the IOSurface and associated offscreen 62 // allocate and/or reallocate the IOSurface and associated offscreen
59 // OpenGL structures for rendering. 63 // OpenGL structures for rendering.
60 return true; 64 return true;
61 } 65 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 374 }
371 return transport_dib_->handle(); 375 return transport_dib_->handle();
372 } 376 }
373 377
374 void AcceleratedSurface::SetTransportDIBAllocAndFree( 378 void AcceleratedSurface::SetTransportDIBAllocAndFree(
375 Callback2<size_t, TransportDIB::Handle*>::Type* allocator, 379 Callback2<size_t, TransportDIB::Handle*>::Type* allocator,
376 Callback1<TransportDIB::Id>::Type* deallocator) { 380 Callback1<TransportDIB::Id>::Type* deallocator) {
377 dib_alloc_callback_.reset(allocator); 381 dib_alloc_callback_.reset(allocator);
378 dib_free_callback_.reset(deallocator); 382 dib_free_callback_.reset(deallocator);
379 } 383 }
OLDNEW
« no previous file with comments | « ui/gfx/surface/accelerated_surface_mac.h ('k') | views/widget/native_widget_wayland.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698