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

Side by Side Diff: ui/gfx/surface/accelerated_surface_mac.h

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 #ifndef UI_GFX_SURFACE_ACCELERATED_SURFACE_MAC_H_ 5 #ifndef UI_GFX_SURFACE_ACCELERATED_SURFACE_MAC_H_
6 #define UI_GFX_SURFACE_ACCELERATED_SURFACE_MAC_H_ 6 #define UI_GFX_SURFACE_ACCELERATED_SURFACE_MAC_H_
7 #pragma once 7 #pragma once
8 8
9 #include <CoreFoundation/CoreFoundation.h> 9 #include <CoreFoundation/CoreFoundation.h>
10 10
11 #include "base/callback_old.h" 11 #include "base/callback_old.h"
12 #include "base/mac/scoped_cftyperef.h" 12 #include "base/mac/scoped_cftyperef.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "ui/gfx/gl/gl_context.h"
15 #include "ui/gfx/gl/gl_surface.h"
16 #include "ui/gfx/gl/gpu_preference.h"
14 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h" 18 #include "ui/gfx/size.h"
16 #include "ui/gfx/gl/gl_context.h"
17 #include "ui/gfx/gl/gl_surface.h"
18 #include "ui/gfx/surface/surface_export.h" 19 #include "ui/gfx/surface/surface_export.h"
19 #include "ui/gfx/surface/transport_dib.h" 20 #include "ui/gfx/surface/transport_dib.h"
20 21
21 // Should not include GL headers in a header file. Forward declare these types 22 // Should not include GL headers in a header file. Forward declare these types
22 // instead. 23 // instead.
23 typedef struct _CGLContextObject* CGLContextObj; 24 typedef struct _CGLContextObject* CGLContextObj;
24 typedef unsigned int GLenum; 25 typedef unsigned int GLenum;
25 typedef unsigned int GLuint; 26 typedef unsigned int GLuint;
26 27
27 namespace gfx { 28 namespace gfx {
(...skipping 11 matching lines...) Expand all
39 virtual ~AcceleratedSurface(); 40 virtual ~AcceleratedSurface();
40 41
41 // Set up internal buffers. |share_context|, if non-NULL, is a context 42 // Set up internal buffers. |share_context|, if non-NULL, is a context
42 // with which the internally created OpenGL context shares textures and 43 // with which the internally created OpenGL context shares textures and
43 // other resources. |allocate_fbo| indicates whether or not this surface 44 // other resources. |allocate_fbo| indicates whether or not this surface
44 // should allocate an offscreen frame buffer object (FBO) internally. If 45 // should allocate an offscreen frame buffer object (FBO) internally. If
45 // not, then the user is expected to allocate one. NOTE that allocating 46 // not, then the user is expected to allocate one. NOTE that allocating
46 // an FBO internally does NOT work properly with client code which uses 47 // an FBO internally does NOT work properly with client code which uses
47 // OpenGL (i.e., via GLES2 command buffers), because the GLES2 48 // OpenGL (i.e., via GLES2 command buffers), because the GLES2
48 // implementation does not know to bind the accelerated surface's 49 // implementation does not know to bind the accelerated surface's
49 // internal FBO when the default FBO is bound. Returns false upon 50 // internal FBO when the default FBO is bound. |gpu_preference| indicates
51 // the GPU preference for the internally allocated GLContext. If
52 // |share_context| is non-NULL, then on platforms supporting dual GPUs,
53 // its GPU preference must match the passed one. Returns false upon
50 // failure. 54 // failure.
51 bool Initialize(gfx::GLContext* share_context, bool allocate_fbo); 55 bool Initialize(gfx::GLContext* share_context,
56 bool allocate_fbo,
57 gfx::GpuPreference gpu_preference);
52 // Tear down. Must be called before destructor to prevent leaks. 58 // Tear down. Must be called before destructor to prevent leaks.
53 void Destroy(); 59 void Destroy();
54 60
55 // These methods are used only once the accelerated surface is initialized. 61 // These methods are used only once the accelerated surface is initialized.
56 62
57 // Sets the accelerated surface to the given size, creating a new one if 63 // Sets the accelerated surface to the given size, creating a new one if
58 // the height or width changes. Returns a unique id of the IOSurface to 64 // the height or width changes. Returns a unique id of the IOSurface to
59 // which the surface is bound, or 0 if no changes were made or an error 65 // which the surface is bound, or 0 if no changes were made or an error
60 // occurred. MakeCurrent() will have been called on the new surface. 66 // occurred. MakeCurrent() will have been called on the new surface.
61 uint64 SetSurfaceSize(const gfx::Size& size); 67 uint64 SetSurfaceSize(const gfx::Size& size);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // true. 174 // true.
169 GLuint fbo_; 175 GLuint fbo_;
170 GLuint depth_stencil_renderbuffer_; 176 GLuint depth_stencil_renderbuffer_;
171 // Allocate a TransportDIB in the renderer. 177 // Allocate a TransportDIB in the renderer.
172 scoped_ptr<Callback2<size_t, TransportDIB::Handle*>::Type> 178 scoped_ptr<Callback2<size_t, TransportDIB::Handle*>::Type>
173 dib_alloc_callback_; 179 dib_alloc_callback_;
174 scoped_ptr<Callback1<TransportDIB::Id>::Type> dib_free_callback_; 180 scoped_ptr<Callback1<TransportDIB::Id>::Type> dib_free_callback_;
175 }; 181 };
176 182
177 #endif // UI_GFX_SURFACE_ACCELERATED_SURFACE_MAC_H_ 183 #endif // UI_GFX_SURFACE_ACCELERATED_SURFACE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698