Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ |
| 6 | #define GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ |
| 7 | |
| 8 | #include "base/callback.h" |
| 9 | #include "base/compiler_specific.h" |
| 10 | #include "gles2_impl_export.h" |
| 11 | #include "ui/gfx/native_widget_types.h" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 12 | #include "ui/gl/gl_surface.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 13 | #include "ui/gl/gpu_preference.h" |
| 14 | |
| 15 | namespace gfx { |
| 16 | class Size; |
| 17 | } |
| 18 | |
| 19 | namespace gpu { |
| 20 | |
| 21 | namespace gles2 { |
| 22 | class GLES2Implementation; |
| 23 | } |
| 24 | |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 25 | class GpuMemoryBufferFactory; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 26 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 27 | // The default uninitialized value is -1. |
| 28 | struct GLES2_IMPL_EXPORT 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 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 41 | class GLES2_IMPL_EXPORT GLInProcessContext { |
| 42 | public: |
| 43 | virtual ~GLInProcessContext() {} |
| 44 | |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 45 | // Must be called before any GLInProcessContext instances are created. |
| 46 | static void SetGpuMemoryBufferFactory(GpuMemoryBufferFactory* factory); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 47 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 48 | // Create a GLInProcessContext, if |is_offscreen| is true, renders to an |
| 49 | // offscreen context. |attrib_list| must be NULL or a NONE-terminated list |
| 50 | // of attribute/value pairs. |
| 51 | static GLInProcessContext* CreateContext( |
| 52 | bool is_offscreen, |
| 53 | gfx::AcceleratedWidget window, |
| 54 | const gfx::Size& size, |
| 55 | bool share_resources, |
| 56 | const char* allowed_extensions, |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 57 | const GLInProcessContextAttribs& attribs, |
| 58 | gfx::GpuPreference gpu_preference); |
| 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 share_resources, |
| 67 | const char* allowed_extensions, |
| 68 | const GLInProcessContextAttribs& attribs, |
| 69 | gfx::GpuPreference gpu_preference); |
| 70 | |
| 71 | virtual void SetContextLostCallback(const base::Closure& callback) = 0; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 72 | |
| 73 | virtual void SignalSyncPoint(unsigned sync_point, |
| 74 | const base::Closure& callback) = 0; |
| 75 | |
| 76 | virtual void SignalQuery(unsigned query, const base::Closure& callback) = 0; |
| 77 | |
| 78 | // Allows direct access to the GLES2 implementation so a GLInProcessContext |
| 79 | // can be used without making it current. |
| 80 | virtual gles2::GLES2Implementation* GetImplementation() = 0; |
| 81 | }; |
| 82 | |
| 83 | } // namespace gpu |
| 84 | |
| 85 | #endif // GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_ |