Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / ui / gl / gl_gl_api_implementation.h
blobaff59265c9fd78223914a004bdf411e522790470
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 UI_GL_GL_GL_API_IMPLEMENTATION_H_
6 #define UI_GL_GL_GL_API_IMPLEMENTATION_H_
8 #include "base/compiler_specific.h"
9 #include "ui/gl/gl_bindings.h"
11 namespace gpu {
12 namespace gles2 {
13 class GLES2Decoder;
16 namespace gfx {
18 class GLContext;
19 class GLSurface;
21 void InitializeStaticGLBindingsGL();
22 void InitializeDynamicGLBindingsGL(GLContext* context);
23 void InitializeDebugGLBindingsGL();
24 void InitializeNullDrawGLBindingsGL();
25 // TODO(danakj): Remove this when all test suites are using null-draw.
26 bool HasInitializedNullDrawGLBindingsGL();
27 bool SetNullDrawGLBindingsEnabledGL(bool enabled);
28 void ClearGLBindingsGL();
29 void SetGLToRealGLApi();
30 void SetGLApi(GLApi* api);
31 void SetGLApiToNoContext();
33 class GLApiBase : public GLApi {
34 public:
35 // Include the auto-generated part of this class. We split this because
36 // it means we can easily edit the non-auto generated parts right here in
37 // this file instead of having to edit some template or the code generator.
38 #include "gl_bindings_api_autogen_gl.h"
40 protected:
41 GLApiBase();
42 virtual ~GLApiBase();
43 void InitializeBase(DriverGL* driver);
44 void SignalFlush();
46 DriverGL* driver_;
49 // Implemenents the GL API by calling directly into the driver.
50 class RealGLApi : public GLApiBase {
51 public:
52 RealGLApi();
53 virtual ~RealGLApi();
54 void Initialize(DriverGL* driver);
56 private:
57 virtual void glFinishFn() OVERRIDE;
58 virtual void glFlushFn() OVERRIDE;
61 // Inserts a TRACE for every GL call.
62 class TraceGLApi : public GLApi {
63 public:
64 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { }
65 virtual ~TraceGLApi();
67 // Include the auto-generated part of this class. We split this because
68 // it means we can easily edit the non-auto generated parts right here in
69 // this file instead of having to edit some template or the code generator.
70 #include "gl_bindings_api_autogen_gl.h"
72 private:
73 GLApi* gl_api_;
76 // Catches incorrect usage when GL calls are made without a current context.
77 class NoContextGLApi : public GLApi {
78 public:
79 NoContextGLApi();
80 virtual ~NoContextGLApi();
82 // Include the auto-generated part of this class. We split this because
83 // it means we can easily edit the non-auto generated parts right here in
84 // this file instead of having to edit some template or the code generator.
85 #include "gl_bindings_api_autogen_gl.h"
88 // Implementents the GL API using co-operative state restoring.
89 // Assumes there is only one real GL context and that multiple virtual contexts
90 // are implemented above it. Restores the needed state from the current context.
91 class VirtualGLApi : public GLApiBase {
92 public:
93 VirtualGLApi();
94 virtual ~VirtualGLApi();
95 void Initialize(DriverGL* driver, GLContext* real_context);
97 // Sets the current virutal context.
98 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface);
100 void OnReleaseVirtuallyCurrent(GLContext* virtual_context);
102 private:
103 // Overridden functions from GLApiBase
104 virtual const GLubyte* glGetStringFn(GLenum name) OVERRIDE;
105 virtual void glFinishFn() OVERRIDE;
106 virtual void glFlushFn() OVERRIDE;
108 // The real context we're running on.
109 GLContext* real_context_;
111 // The current virtual context.
112 GLContext* current_context_;
114 // The supported extensions being advertised for this virtual context.
115 std::string extensions_;
118 } // namespace gfx
120 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_