Performance histograms for extension content verification
[chromium-blink-merge.git] / gpu / command_buffer / client / gl_in_process_context.h
blobc1478b11135f8a94c52e812f3ac315b4d8e52b24
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.
5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "gl_in_process_context_export.h"
11 #include "gpu/command_buffer/service/in_process_command_buffer.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/gl/gl_surface.h"
14 #include "ui/gl/gpu_preference.h"
16 namespace gfx {
17 class Size;
20 #if defined(OS_ANDROID)
21 namespace gfx {
22 class SurfaceTexture;
24 #endif
26 namespace gpu {
28 namespace gles2 {
29 class GLES2Implementation;
32 // The default uninitialized value is -1.
33 struct GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContextAttribs {
34 GLInProcessContextAttribs();
36 int32 alpha_size;
37 int32 blue_size;
38 int32 green_size;
39 int32 red_size;
40 int32 depth_size;
41 int32 stencil_size;
42 int32 samples;
43 int32 sample_buffers;
44 int32 fail_if_major_perf_caveat;
45 int32 lose_context_when_out_of_memory;
48 class GL_IN_PROCESS_CONTEXT_EXPORT GLInProcessContext {
49 public:
50 virtual ~GLInProcessContext() {}
52 // Create a GLInProcessContext, if |is_offscreen| is true, renders to an
53 // offscreen context. |attrib_list| must be NULL or a NONE-terminated list
54 // of attribute/value pairs.
55 // TODO(boliu): Fix all callsites to use Create and remove this.
56 static GLInProcessContext* CreateContext(
57 bool is_offscreen,
58 gfx::AcceleratedWidget window,
59 const gfx::Size& size,
60 bool share_resources,
61 const GLInProcessContextAttribs& attribs,
62 gfx::GpuPreference gpu_preference);
64 // If |surface| is not NULL, then it must match |is_offscreen| and |size|,
65 // |window| must be gfx::kNullAcceleratedWidget, and the command buffer
66 // service must run on the same thread as this client because GLSurface is
67 // not thread safe. If |surface| is NULL, then the other parameters are used
68 // to correctly create a surface.
69 // Only one of |share_context| and |use_global_share_group| can be used at
70 // the same time.
71 static GLInProcessContext* Create(
72 scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
73 scoped_refptr<gfx::GLSurface> surface,
74 bool is_offscreen,
75 gfx::AcceleratedWidget window,
76 const gfx::Size& size,
77 GLInProcessContext* share_context,
78 bool use_global_share_group,
79 const GLInProcessContextAttribs& attribs,
80 gfx::GpuPreference gpu_preference);
82 virtual void SetContextLostCallback(const base::Closure& callback) = 0;
84 // Allows direct access to the GLES2 implementation so a GLInProcessContext
85 // can be used without making it current.
86 virtual gles2::GLES2Implementation* GetImplementation() = 0;
88 #if defined(OS_ANDROID)
89 virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(
90 uint32 stream_id) = 0;
91 #endif
94 } // namespace gpu
96 #endif // GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_