6175cc556ad284f9522cacbd9ced80c7796798d1
[platform/framework/web/crosswalk.git] / src / gpu / command_buffer / client / gl_in_process_context.h
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 "gl_in_process_context_export.h"
11 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
12 #include "gpu/command_buffer/service/in_process_command_buffer.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gl/gl_surface.h"
15 #include "ui/gl/gpu_preference.h"
16
17 namespace gfx {
18 class Size;
19 }
20
21 #if defined(OS_ANDROID)
22 namespace gfx {
23 class SurfaceTexture;
24 }
25 #endif
26
27 namespace gpu {
28
29 namespace gles2 {
30 class GLES2Implementation;
31 }
32
33 class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
34  public:
35   virtual ~GLInProcessContext() {}
36
37   // Create a GLInProcessContext, if |is_offscreen| is true, renders to an
38   // offscreen context. |attrib_list| must be NULL or a NONE-terminated list
39   // of attribute/value pairs.
40   // If |surface| is not NULL, then it must match |is_offscreen| and |size|,
41   // |window| must be gfx::kNullAcceleratedWidget, and the command buffer
42   // service must run on the same thread as this client because GLSurface is
43   // not thread safe. If |surface| is NULL, then the other parameters are used
44   // to correctly create a surface.
45   // Only one of |share_context| and |use_global_share_group| can be used at
46   // the same time.
47   static GLInProcessContext* Create(
48       scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
49       scoped_refptr<gfx::GLSurface> surface,
50       bool is_offscreen,
51       gfx::AcceleratedWidget window,
52       const gfx::Size& size,
53       GLInProcessContext* share_context,
54       bool use_global_share_group,
55       const gpu::gles2::ContextCreationAttribHelper& attribs,
56       gfx::GpuPreference gpu_preference);
57
58   virtual void SetContextLostCallback(const base::Closure& callback) = 0;
59
60   // Allows direct access to the GLES2 implementation so a GLInProcessContext
61   // can be used without making it current.
62   virtual gles2::GLES2Implementation* GetImplementation() = 0;
63
64 #if defined(OS_ANDROID)
65   virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(
66       uint32 stream_id) = 0;
67 #endif
68 };
69
70 }  // namespace gpu
71
72 #endif  // GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_