Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ |
| 6 #define GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "gles2_impl_export.h" | 10 #include "gles2_impl_export.h" |
| 11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 12 #include "ui/gl/gl_surface.h" | |
| 12 #include "ui/gl/gpu_preference.h" | 13 #include "ui/gl/gpu_preference.h" |
| 13 | 14 |
| 14 namespace gfx { | 15 namespace gfx { |
| 15 class Size; | 16 class Size; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace gpu { | 19 namespace gpu { |
| 19 | 20 |
| 20 namespace gles2 { | 21 namespace gles2 { |
| 21 class GLES2Implementation; | 22 class GLES2Implementation; |
| 22 } | 23 } |
| 23 | 24 |
| 24 class GpuMemoryBufferFactory; | 25 class GpuMemoryBufferFactory; |
| 25 | 26 |
| 27 // The default uninitialize value is -1. | |
|
piman
2013/08/07 00:35:29
typo: "uninitialized"
boliu
2013/08/07 02:58:48
Done.
| |
| 28 struct GLInProcessContextAttribs { | |
| 29 GLInProcessContextAttribs(); | |
| 30 | |
| 31 int32 alpha_size; | |
| 32 int32 blue_size; | |
| 33 int32 green_size; | |
| 34 int32 red_size; | |
| 35 int32 depth_size; | |
| 36 int32 stencil_size; | |
| 37 int32 samples; | |
| 38 int32 sample_buffers; | |
| 39 }; | |
| 40 | |
| 26 class GLES2_IMPL_EXPORT GLInProcessContext { | 41 class GLES2_IMPL_EXPORT GLInProcessContext { |
| 27 public: | 42 public: |
| 28 virtual ~GLInProcessContext() {} | 43 virtual ~GLInProcessContext() {} |
| 29 | 44 |
| 30 // Must be called before any GLInProcessContext instances are created. | 45 // Must be called before any GLInProcessContext instances are created. |
| 31 static void SetGpuMemoryBufferFactory(GpuMemoryBufferFactory* factory); | 46 static void SetGpuMemoryBufferFactory(GpuMemoryBufferFactory* factory); |
| 32 | 47 |
| 33 // GLInProcessContext configuration attributes. These are the same as used by | |
| 34 // EGL. Attributes are matched using a closest fit algorithm. | |
| 35 enum Attribute { | |
| 36 ALPHA_SIZE = 0x3021, | |
| 37 BLUE_SIZE = 0x3022, | |
| 38 GREEN_SIZE = 0x3023, | |
| 39 RED_SIZE = 0x3024, | |
| 40 DEPTH_SIZE = 0x3025, | |
| 41 STENCIL_SIZE = 0x3026, | |
| 42 SAMPLES = 0x3031, | |
| 43 SAMPLE_BUFFERS = 0x3032, | |
| 44 NONE = 0x3038 // Attrib list = terminator | |
| 45 }; | |
| 46 | |
| 47 // Create a GLInProcessContext, if |is_offscreen| is true, renders to an | 48 // Create a GLInProcessContext, if |is_offscreen| is true, renders to an |
| 48 // offscreen context. |attrib_list| must be NULL or a NONE-terminated list | 49 // offscreen context. |attrib_list| must be NULL or a NONE-terminated list |
| 49 // of attribute/value pairs. | 50 // of attribute/value pairs. |
| 50 static GLInProcessContext* CreateContext( | 51 static GLInProcessContext* CreateContext( |
| 51 bool is_offscreen, | 52 bool is_offscreen, |
| 52 gfx::AcceleratedWidget window, | 53 gfx::AcceleratedWidget window, |
| 53 const gfx::Size& size, | 54 const gfx::Size& size, |
| 54 bool share_resources, | 55 bool share_resources, |
| 55 const char* allowed_extensions, | 56 const char* allowed_extensions, |
| 56 const int32* attrib_list, | 57 const GLInProcessContextAttribs& attribs, |
| 57 gfx::GpuPreference gpu_preference, | 58 gfx::GpuPreference gpu_preference); |
| 58 const base::Closure& callback); | 59 |
| 60 // Create context with the provided GLSurface. All other arguments match | |
| 61 // CreateContext factory above. Can only be called if the command buffer | |
| 62 // service runs on the same thread as this client because GLSurface is not | |
| 63 // thread safe. | |
| 64 static GLInProcessContext* CreateWithSurface( | |
| 65 scoped_refptr<gfx::GLSurface> surface, | |
| 66 bool is_offscreen, | |
|
no sievers
2013/08/07 01:52:38
is_offscreen and size should now be derived from G
boliu
2013/08/07 02:58:48
Done.
| |
| 67 const gfx::Size& size, | |
| 68 bool share_resources, | |
| 69 const char* allowed_extensions, | |
| 70 const GLInProcessContextAttribs& attribs, | |
| 71 gfx::GpuPreference gpu_preference); | |
| 72 | |
| 73 virtual void SetContextLostCallback(const base::Closure& callback) = 0; | |
| 59 | 74 |
| 60 virtual void SignalSyncPoint(unsigned sync_point, | 75 virtual void SignalSyncPoint(unsigned sync_point, |
| 61 const base::Closure& callback) = 0; | 76 const base::Closure& callback) = 0; |
| 62 | 77 |
| 63 virtual void SignalQuery(unsigned query, const base::Closure& callback) = 0; | 78 virtual void SignalQuery(unsigned query, const base::Closure& callback) = 0; |
| 64 | 79 |
| 65 // Allows direct access to the GLES2 implementation so a GLInProcessContext | 80 // Allows direct access to the GLES2 implementation so a GLInProcessContext |
| 66 // can be used without making it current. | 81 // can be used without making it current. |
| 67 virtual gles2::GLES2Implementation* GetImplementation() = 0; | 82 virtual gles2::GLES2Implementation* GetImplementation() = 0; |
| 68 }; | 83 }; |
| 69 | 84 |
| 70 } // namespace gpu | 85 } // namespace gpu |
| 71 | 86 |
| 72 #endif // GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ | 87 #endif // GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ |
| OLD | NEW |