| 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 |
| 11 #include "app/gfx/gl/gl_context.h" | 11 #include "app/gfx/gl/gl_context.h" |
| 12 #include "app/surface/transport_dib.h" | 12 #include "app/surface/transport_dib.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/scoped_cftyperef.h" | 14 #include "base/mac/scoped_cftyperef.h" |
| 15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 16 #include "gfx/rect.h" | 16 #include "gfx/rect.h" |
| 17 #include "gfx/size.h" | 17 #include "gfx/size.h" |
| 18 | 18 |
| 19 // Should not include GL headers in a header file. Forward declare these types | 19 // Should not include GL headers in a header file. Forward declare these types |
| 20 // instead. | 20 // instead. |
| 21 typedef struct _CGLContextObject* CGLContextObj; | 21 typedef struct _CGLContextObject* CGLContextObj; |
| 22 typedef unsigned int GLenum; | 22 typedef unsigned int GLenum; |
| 23 typedef unsigned int GLuint; | 23 typedef unsigned int GLuint; |
| 24 | 24 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // to the shared region (IOSurface or TransportDIB). Strictly | 123 // to the shared region (IOSurface or TransportDIB). Strictly |
| 124 // speaking, we do not need to allocate a GL context all of the | 124 // 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 | 125 // time. We only need one if (a) we are using the IOSurface code |
| 126 // path, or (b) if we are allocating an FBO internally. | 126 // path, or (b) if we are allocating an FBO internally. |
| 127 scoped_ptr<gfx::GLContext> gl_context_; | 127 scoped_ptr<gfx::GLContext> gl_context_; |
| 128 // Either |io_surface_| or |transport_dib_| is a valid pointer, but not both. | 128 // 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 | 129 // |io_surface_| is non-NULL if the IOSurface APIs are supported (Mac OS X |
| 130 // 10.6 and later). | 130 // 10.6 and later). |
| 131 // TODO(dspringer,kbr): Should the GPU backing store be encapsulated in its | 131 // TODO(dspringer,kbr): Should the GPU backing store be encapsulated in its |
| 132 // own class so all this implementation detail is hidden? | 132 // own class so all this implementation detail is hidden? |
| 133 scoped_cftyperef<CFTypeRef> io_surface_; | 133 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; |
| 134 // TODO(dspringer): If we end up keeping this TransportDIB mechanism, this | 134 // TODO(dspringer): If we end up keeping this TransportDIB mechanism, this |
| 135 // should really be a scoped_ptr_malloc<>, with a deallocate functor that | 135 // 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 | 136 // runs |dib_free_callback_|. I was not able to figure out how to |
| 137 // make this work (or even compile). | 137 // make this work (or even compile). |
| 138 scoped_ptr<TransportDIB> transport_dib_; | 138 scoped_ptr<TransportDIB> transport_dib_; |
| 139 gfx::Size surface_size_; | 139 gfx::Size surface_size_; |
| 140 // TODO(kbr): the FBO management should not be in this class at all. | 140 // 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 | 141 // 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 | 142 // introduce another copy of the color data on the GPU; the direct |
| 143 // binding of the internal texture to the IOSurface saves a copy. | 143 // binding of the internal texture to the IOSurface saves a copy. |
| 144 bool allocate_fbo_; | 144 bool allocate_fbo_; |
| 145 // If the IOSurface code path is being used, then this texture | 145 // If the IOSurface code path is being used, then this texture |
| 146 // object is always allocated. Otherwise, it is only allocated if | 146 // object is always allocated. Otherwise, it is only allocated if |
| 147 // the user requests an FBO be allocated. | 147 // the user requests an FBO be allocated. |
| 148 GLuint texture_; | 148 GLuint texture_; |
| 149 // The FBO and renderbuffer are only allocated if allocate_fbo_ is | 149 // The FBO and renderbuffer are only allocated if allocate_fbo_ is |
| 150 // true. | 150 // true. |
| 151 GLuint fbo_; | 151 GLuint fbo_; |
| 152 GLuint depth_stencil_renderbuffer_; | 152 GLuint depth_stencil_renderbuffer_; |
| 153 // Allocate a TransportDIB in the renderer. | 153 // Allocate a TransportDIB in the renderer. |
| 154 scoped_ptr<Callback2<size_t, TransportDIB::Handle*>::Type> | 154 scoped_ptr<Callback2<size_t, TransportDIB::Handle*>::Type> |
| 155 dib_alloc_callback_; | 155 dib_alloc_callback_; |
| 156 scoped_ptr<Callback1<TransportDIB::Id>::Type> dib_free_callback_; | 156 scoped_ptr<Callback1<TransportDIB::Id>::Type> dib_free_callback_; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 #endif // APP_SURFACE_ACCELERATED_SURFACE_MAC_H_ | 159 #endif // APP_SURFACE_ACCELERATED_SURFACE_MAC_H_ |
| OLD | NEW |