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 "gles2_impl_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"
20 #if defined(OS_ANDROID)
29 class GLES2Implementation;
32 // The default uninitialized value is -1.
33 struct GLES2_IMPL_EXPORT GLInProcessContextAttribs {
34 GLInProcessContextAttribs();
44 int32 fail_if_major_perf_caveat;
47 class GLES2_IMPL_EXPORT GLInProcessContext {
49 virtual ~GLInProcessContext() {}
51 // Create a GLInProcessContext, if |is_offscreen| is true, renders to an
52 // offscreen context. |attrib_list| must be NULL or a NONE-terminated list
53 // of attribute/value pairs.
54 static GLInProcessContext* CreateContext(
56 gfx::AcceleratedWidget window,
57 const gfx::Size& size,
59 const GLInProcessContextAttribs& attribs,
60 gfx::GpuPreference gpu_preference);
62 // Create context with the provided GLSurface. All other arguments match
63 // CreateContext factory above. Can only be called if the command buffer
64 // service runs on the same thread as this client because GLSurface is not
66 static GLInProcessContext* CreateWithSurface(
67 scoped_refptr<gfx::GLSurface> surface,
68 scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
69 GLInProcessContext* share_context,
70 const GLInProcessContextAttribs& attribs,
71 gfx::GpuPreference gpu_preference);
73 virtual void SetContextLostCallback(const base::Closure& callback) = 0;
75 // Allows direct access to the GLES2 implementation so a GLInProcessContext
76 // can be used without making it current.
77 virtual gles2::GLES2Implementation* GetImplementation() = 0;
79 #if defined(OS_ANDROID)
80 virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(
81 uint32 stream_id) = 0;
87 #endif // GPU_COMMAND_BUFFER_CLIENT_GL_IN_PROCESS_CONTEXT_H_