blob: 09f8140ee0e87e34fc7452aabd2f8b365309eaf2 [file] [log] [blame]
Ben Murdocheb525c52013-07-10 11:40:50 +01001// 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 Murdochbb1529c2013-08-08 10:24:53 +010012#include "ui/gl/gl_surface.h"
Ben Murdocheb525c52013-07-10 11:40:50 +010013#include "ui/gl/gpu_preference.h"
14
15namespace gfx {
16class Size;
17}
18
19namespace gpu {
20
21namespace gles2 {
22class GLES2Implementation;
23}
24
Ben Murdoch558790d2013-07-30 15:19:42 +010025class GpuMemoryBufferFactory;
Ben Murdocheb525c52013-07-10 11:40:50 +010026
Ben Murdochbb1529c2013-08-08 10:24:53 +010027// The default uninitialized value is -1.
28struct 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 Murdocheb525c52013-07-10 11:40:50 +010041class GLES2_IMPL_EXPORT GLInProcessContext {
42 public:
43 virtual ~GLInProcessContext() {}
44
Ben Murdoch558790d2013-07-30 15:19:42 +010045 // Must be called before any GLInProcessContext instances are created.
46 static void SetGpuMemoryBufferFactory(GpuMemoryBufferFactory* factory);
Ben Murdocheb525c52013-07-10 11:40:50 +010047
Ben Murdocheb525c52013-07-10 11:40:50 +010048 // 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 Murdochbb1529c2013-08-08 10:24:53 +010057 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 Murdocheb525c52013-07-10 11:40:50 +010072
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_