OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 APP_SURFACE_ACCELERATED_SURFACE_MAC_H_ | 5 #ifndef APP_SURFACE_ACCELERATED_SURFACE_MAC_H_ |
6 #define APP_SURFACE_ACCELERATED_SURFACE_MAC_H_ | 6 #define APP_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 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 void Destroy(); | 51 void Destroy(); |
52 | 52 |
53 // These methods are used only once the accelerated surface is initialized. | 53 // These methods are used only once the accelerated surface is initialized. |
54 | 54 |
55 // Sets the accelerated surface to the given size, creating a new one if | 55 // Sets the accelerated surface to the given size, creating a new one if |
56 // the height or width changes. Returns a unique id of the IOSurface to | 56 // the height or width changes. Returns a unique id of the IOSurface to |
57 // which the surface is bound, or 0 if no changes were made or an error | 57 // which the surface is bound, or 0 if no changes were made or an error |
58 // occurred. MakeCurrent() will have been called on the new surface. | 58 // occurred. MakeCurrent() will have been called on the new surface. |
59 uint64 SetSurfaceSize(const gfx::Size& size); | 59 uint64 SetSurfaceSize(const gfx::Size& size); |
60 | 60 |
| 61 // Returns the id of this surface's IOSruface, or 0 for |
| 62 // transport DIB surfaces. |
| 63 uint64 GetSurfaceId(); |
| 64 |
61 // Sets the GL context to be the current one for drawing. Returns true if | 65 // Sets the GL context to be the current one for drawing. Returns true if |
62 // it succeeded. | 66 // it succeeded. |
63 bool MakeCurrent(); | 67 bool MakeCurrent(); |
64 // Clear the surface to be transparent. Assumes the caller has already called | 68 // Clear the surface to be transparent. Assumes the caller has already called |
65 // MakeCurrent(). | 69 // MakeCurrent(). |
66 void Clear(const gfx::Rect& rect); | 70 void Clear(const gfx::Rect& rect); |
67 // Call after making changes to the surface which require a visual update. | 71 // Call after making changes to the surface which require a visual update. |
68 // Makes the rendering show up in other processes. Assumes the caller has | 72 // Makes the rendering show up in other processes. Assumes the caller has |
69 // already called MakeCurrent(). | 73 // already called MakeCurrent(). |
70 // | 74 // |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // speaking, we do not need to allocate a GL context all of the | 128 // speaking, we do not need to allocate a GL context all of the |
125 // time. We only need one if (a) we are using the IOSurface code | 129 // time. We only need one if (a) we are using the IOSurface code |
126 // path, or (b) if we are allocating an FBO internally. | 130 // path, or (b) if we are allocating an FBO internally. |
127 scoped_ptr<gfx::GLContext> gl_context_; | 131 scoped_ptr<gfx::GLContext> gl_context_; |
128 // Either |io_surface_| or |transport_dib_| is a valid pointer, but not both. | 132 // Either |io_surface_| or |transport_dib_| is a valid pointer, but not both. |
129 // |io_surface_| is non-NULL if the IOSurface APIs are supported (Mac OS X | 133 // |io_surface_| is non-NULL if the IOSurface APIs are supported (Mac OS X |
130 // 10.6 and later). | 134 // 10.6 and later). |
131 // TODO(dspringer,kbr): Should the GPU backing store be encapsulated in its | 135 // TODO(dspringer,kbr): Should the GPU backing store be encapsulated in its |
132 // own class so all this implementation detail is hidden? | 136 // own class so all this implementation detail is hidden? |
133 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; | 137 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; |
| 138 |
| 139 // The id of |io_surface_| or 0 if that's NULL. |
| 140 uint64 io_surface_id_; |
| 141 |
134 // TODO(dspringer): If we end up keeping this TransportDIB mechanism, this | 142 // TODO(dspringer): If we end up keeping this TransportDIB mechanism, this |
135 // should really be a scoped_ptr_malloc<>, with a deallocate functor that | 143 // should really be a scoped_ptr_malloc<>, with a deallocate functor that |
136 // runs |dib_free_callback_|. I was not able to figure out how to | 144 // runs |dib_free_callback_|. I was not able to figure out how to |
137 // make this work (or even compile). | 145 // make this work (or even compile). |
138 scoped_ptr<TransportDIB> transport_dib_; | 146 scoped_ptr<TransportDIB> transport_dib_; |
139 gfx::Size surface_size_; | 147 gfx::Size surface_size_; |
140 // TODO(kbr): the FBO management should not be in this class at all. | 148 // TODO(kbr): the FBO management should not be in this class at all. |
141 // However, if it is factored out, care needs to be taken to not | 149 // However, if it is factored out, care needs to be taken to not |
142 // introduce another copy of the color data on the GPU; the direct | 150 // introduce another copy of the color data on the GPU; the direct |
143 // binding of the internal texture to the IOSurface saves a copy. | 151 // binding of the internal texture to the IOSurface saves a copy. |
144 bool allocate_fbo_; | 152 bool allocate_fbo_; |
145 // If the IOSurface code path is being used, then this texture | 153 // If the IOSurface code path is being used, then this texture |
146 // object is always allocated. Otherwise, it is only allocated if | 154 // object is always allocated. Otherwise, it is only allocated if |
147 // the user requests an FBO be allocated. | 155 // the user requests an FBO be allocated. |
148 GLuint texture_; | 156 GLuint texture_; |
149 // The FBO and renderbuffer are only allocated if allocate_fbo_ is | 157 // The FBO and renderbuffer are only allocated if allocate_fbo_ is |
150 // true. | 158 // true. |
151 GLuint fbo_; | 159 GLuint fbo_; |
152 GLuint depth_stencil_renderbuffer_; | 160 GLuint depth_stencil_renderbuffer_; |
153 // Allocate a TransportDIB in the renderer. | 161 // Allocate a TransportDIB in the renderer. |
154 scoped_ptr<Callback2<size_t, TransportDIB::Handle*>::Type> | 162 scoped_ptr<Callback2<size_t, TransportDIB::Handle*>::Type> |
155 dib_alloc_callback_; | 163 dib_alloc_callback_; |
156 scoped_ptr<Callback1<TransportDIB::Id>::Type> dib_free_callback_; | 164 scoped_ptr<Callback1<TransportDIB::Id>::Type> dib_free_callback_; |
157 }; | 165 }; |
158 | 166 |
159 #endif // APP_SURFACE_ACCELERATED_SURFACE_MAC_H_ | 167 #endif // APP_SURFACE_ACCELERATED_SURFACE_MAC_H_ |
OLD | NEW |