File: gl_bindings_skia_cmd_buffer.cc

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (263 lines) | stat: -rw-r--r-- 14,391 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"

#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"

using gpu::gles2::GLES2Interface;

namespace {
template <typename R, typename... Args>
std::function<R(Args...)> gles_bind(R (GLES2Interface::*func)(Args...),
                                    GLES2Interface* gles2Interface) {
  return [func, gles2Interface](Args... args) {
    return (gles2Interface->*func)(args...);
  };
}
}  // namespace

namespace skia_bindings {

sk_sp<GrGLInterface> CreateGLES2InterfaceBindings(GLES2Interface* impl) {
  // Until Chromium is passing the WebGL 2.0 conformance we're limiting Skia to
  // a GLES 2.0 interface (plus extensions).
  auto get_string_version_override = [impl](GLenum name) {
    if (name == GL_VERSION)
      return reinterpret_cast<const GLubyte*>("OpenGL ES 2.0 Chromium");
    return impl->GetString(name);
  };

  sk_sp<GrGLInterface> interface(new GrGLInterface);
  interface->fStandard = kGLES_GrGLStandard;
  interface->fExtensions.init(kGLES_GrGLStandard, get_string_version_override,
                              nullptr,
                              gles_bind(&GLES2Interface::GetIntegerv, impl));

  GrGLInterface::Functions* functions = &interface->fFunctions;
  functions->fActiveTexture = gles_bind(&GLES2Interface::ActiveTexture, impl);
  functions->fAttachShader = gles_bind(&GLES2Interface::AttachShader, impl);
  functions->fBindAttribLocation =
      gles_bind(&GLES2Interface::BindAttribLocation, impl);
  functions->fBindBuffer = gles_bind(&GLES2Interface::BindBuffer, impl);
  functions->fBindTexture = gles_bind(&GLES2Interface::BindTexture, impl);
  functions->fBindVertexArray =
      gles_bind(&GLES2Interface::BindVertexArrayOES, impl);
  functions->fBlendBarrier = gles_bind(&GLES2Interface::BlendBarrierKHR, impl);
  functions->fBlendColor = gles_bind(&GLES2Interface::BlendColor, impl);
  functions->fBlendEquation = gles_bind(&GLES2Interface::BlendEquation, impl);
  functions->fBlendFunc = gles_bind(&GLES2Interface::BlendFunc, impl);
  functions->fBufferData = gles_bind(&GLES2Interface::BufferData, impl);
  functions->fBufferSubData = gles_bind(&GLES2Interface::BufferSubData, impl);
  functions->fClear = gles_bind(&GLES2Interface::Clear, impl);
  functions->fClearColor = gles_bind(&GLES2Interface::ClearColor, impl);
  functions->fClearStencil = gles_bind(&GLES2Interface::ClearStencil, impl);
  functions->fColorMask = gles_bind(&GLES2Interface::ColorMask, impl);
  functions->fCompileShader = gles_bind(&GLES2Interface::CompileShader, impl);
  functions->fCompressedTexImage2D =
      gles_bind(&GLES2Interface::CompressedTexImage2D, impl);
  functions->fCompressedTexSubImage2D =
      gles_bind(&GLES2Interface::CompressedTexSubImage2D, impl);
  functions->fCopyTexSubImage2D =
      gles_bind(&GLES2Interface::CopyTexSubImage2D, impl);
  functions->fCreateProgram = gles_bind(&GLES2Interface::CreateProgram, impl);
  functions->fCreateShader = gles_bind(&GLES2Interface::CreateShader, impl);
  functions->fCullFace = gles_bind(&GLES2Interface::CullFace, impl);
  functions->fDeleteBuffers = gles_bind(&GLES2Interface::DeleteBuffers, impl);
  functions->fDeleteProgram = gles_bind(&GLES2Interface::DeleteProgram, impl);
  functions->fDeleteShader = gles_bind(&GLES2Interface::DeleteShader, impl);
  functions->fDeleteTextures = gles_bind(&GLES2Interface::DeleteTextures, impl);
  functions->fDeleteVertexArrays =
      gles_bind(&GLES2Interface::DeleteVertexArraysOES, impl);
  functions->fDepthMask = gles_bind(&GLES2Interface::DepthMask, impl);
  functions->fDisable = gles_bind(&GLES2Interface::Disable, impl);
  functions->fDisableVertexAttribArray =
      gles_bind(&GLES2Interface::DisableVertexAttribArray, impl);
  functions->fDiscardFramebuffer =
      gles_bind(&GLES2Interface::DiscardFramebufferEXT, impl);
  functions->fDrawArrays = gles_bind(&GLES2Interface::DrawArrays, impl);
  functions->fDrawElements = gles_bind(&GLES2Interface::DrawElements, impl);
  functions->fEnable = gles_bind(&GLES2Interface::Enable, impl);
  functions->fEnableVertexAttribArray =
      gles_bind(&GLES2Interface::EnableVertexAttribArray, impl);
  functions->fFinish = gles_bind(&GLES2Interface::Finish, impl);
  functions->fFlush = gles_bind(&GLES2Interface::Flush, impl);
  functions->fFrontFace = gles_bind(&GLES2Interface::FrontFace, impl);
  functions->fGenBuffers = gles_bind(&GLES2Interface::GenBuffers, impl);
  functions->fGenTextures = gles_bind(&GLES2Interface::GenTextures, impl);
  functions->fGenVertexArrays =
      gles_bind(&GLES2Interface::GenVertexArraysOES, impl);
  functions->fGetBufferParameteriv =
      gles_bind(&GLES2Interface::GetBufferParameteriv, impl);
  functions->fGetError = gles_bind(&GLES2Interface::GetError, impl);
  functions->fGetIntegerv = gles_bind(&GLES2Interface::GetIntegerv, impl);
  functions->fGetProgramInfoLog =
      gles_bind(&GLES2Interface::GetProgramInfoLog, impl);
  functions->fGetProgramiv = gles_bind(&GLES2Interface::GetProgramiv, impl);
  functions->fGetShaderInfoLog =
      gles_bind(&GLES2Interface::GetShaderInfoLog, impl);
  functions->fGetShaderiv = gles_bind(&GLES2Interface::GetShaderiv, impl);
  functions->fGetShaderPrecisionFormat =
      gles_bind(&GLES2Interface::GetShaderPrecisionFormat, impl);
  functions->fGetString = get_string_version_override;
  functions->fGetUniformLocation =
      gles_bind(&GLES2Interface::GetUniformLocation, impl);
  functions->fInsertEventMarker =
      gles_bind(&GLES2Interface::InsertEventMarkerEXT, impl);
  functions->fIsTexture = gles_bind(&GLES2Interface::IsTexture, impl);
  functions->fLineWidth = gles_bind(&GLES2Interface::LineWidth, impl);
  functions->fLinkProgram = gles_bind(&GLES2Interface::LinkProgram, impl);
  functions->fMapBufferSubData =
      gles_bind(&GLES2Interface::MapBufferSubDataCHROMIUM, impl);
  functions->fMapTexSubImage2D =
      gles_bind(&GLES2Interface::MapTexSubImage2DCHROMIUM, impl);
  functions->fPixelStorei = gles_bind(&GLES2Interface::PixelStorei, impl);
  functions->fPopGroupMarker =
      gles_bind(&GLES2Interface::PopGroupMarkerEXT, impl);
  functions->fPushGroupMarker =
      gles_bind(&GLES2Interface::PushGroupMarkerEXT, impl);
  functions->fReadPixels = gles_bind(&GLES2Interface::ReadPixels, impl);
  functions->fScissor = gles_bind(&GLES2Interface::Scissor, impl);
  functions->fShaderSource = gles_bind(&GLES2Interface::ShaderSource, impl);
  functions->fStencilFunc = gles_bind(&GLES2Interface::StencilFunc, impl);
  functions->fStencilFuncSeparate =
      gles_bind(&GLES2Interface::StencilFuncSeparate, impl);
  functions->fStencilMask = gles_bind(&GLES2Interface::StencilMask, impl);
  functions->fStencilMaskSeparate =
      gles_bind(&GLES2Interface::StencilMaskSeparate, impl);
  functions->fStencilOp = gles_bind(&GLES2Interface::StencilOp, impl);
  functions->fStencilOpSeparate =
      gles_bind(&GLES2Interface::StencilOpSeparate, impl);
  functions->fTexImage2D = gles_bind(&GLES2Interface::TexImage2D, impl);
  functions->fTexParameteri = gles_bind(&GLES2Interface::TexParameteri, impl);
  functions->fTexParameteriv = gles_bind(&GLES2Interface::TexParameteriv, impl);
  functions->fTexStorage2D = gles_bind(&GLES2Interface::TexStorage2DEXT, impl);
  functions->fTexSubImage2D = gles_bind(&GLES2Interface::TexSubImage2D, impl);
  functions->fUniform1f = gles_bind(&GLES2Interface::Uniform1f, impl);
  functions->fUniform1i = gles_bind(&GLES2Interface::Uniform1i, impl);
  functions->fUniform1fv = gles_bind(&GLES2Interface::Uniform1fv, impl);
  functions->fUniform1iv = gles_bind(&GLES2Interface::Uniform1iv, impl);
  functions->fUniform2f = gles_bind(&GLES2Interface::Uniform2f, impl);
  functions->fUniform2i = gles_bind(&GLES2Interface::Uniform2i, impl);
  functions->fUniform2fv = gles_bind(&GLES2Interface::Uniform2fv, impl);
  functions->fUniform2iv = gles_bind(&GLES2Interface::Uniform2iv, impl);
  functions->fUniform3f = gles_bind(&GLES2Interface::Uniform3f, impl);
  functions->fUniform3i = gles_bind(&GLES2Interface::Uniform3i, impl);
  functions->fUniform3fv = gles_bind(&GLES2Interface::Uniform3fv, impl);
  functions->fUniform3iv = gles_bind(&GLES2Interface::Uniform3iv, impl);
  functions->fUniform4f = gles_bind(&GLES2Interface::Uniform4f, impl);
  functions->fUniform4i = gles_bind(&GLES2Interface::Uniform4i, impl);
  functions->fUniform4fv = gles_bind(&GLES2Interface::Uniform4fv, impl);
  functions->fUniform4iv = gles_bind(&GLES2Interface::Uniform4iv, impl);
  functions->fUniformMatrix2fv =
      gles_bind(&GLES2Interface::UniformMatrix2fv, impl);
  functions->fUniformMatrix3fv =
      gles_bind(&GLES2Interface::UniformMatrix3fv, impl);
  functions->fUniformMatrix4fv =
      gles_bind(&GLES2Interface::UniformMatrix4fv, impl);
  functions->fUnmapBufferSubData =
      gles_bind(&GLES2Interface::UnmapBufferSubDataCHROMIUM, impl);
  functions->fUnmapTexSubImage2D =
      gles_bind(&GLES2Interface::UnmapTexSubImage2DCHROMIUM, impl);
  functions->fUseProgram = gles_bind(&GLES2Interface::UseProgram, impl);
  functions->fVertexAttrib1f = gles_bind(&GLES2Interface::VertexAttrib1f, impl);
  functions->fVertexAttrib2fv =
      gles_bind(&GLES2Interface::VertexAttrib2fv, impl);
  functions->fVertexAttrib3fv =
      gles_bind(&GLES2Interface::VertexAttrib3fv, impl);
  functions->fVertexAttrib4fv =
      gles_bind(&GLES2Interface::VertexAttrib4fv, impl);
  functions->fVertexAttribPointer =
      gles_bind(&GLES2Interface::VertexAttribPointer, impl);
  functions->fViewport = gles_bind(&GLES2Interface::Viewport, impl);
  functions->fBindFramebuffer =
      gles_bind(&GLES2Interface::BindFramebuffer, impl);
  functions->fBindRenderbuffer =
      gles_bind(&GLES2Interface::BindRenderbuffer, impl);
  functions->fCheckFramebufferStatus =
      gles_bind(&GLES2Interface::CheckFramebufferStatus, impl);
  functions->fDeleteFramebuffers =
      gles_bind(&GLES2Interface::DeleteFramebuffers, impl);
  functions->fDeleteRenderbuffers =
      gles_bind(&GLES2Interface::DeleteRenderbuffers, impl);
  functions->fFramebufferRenderbuffer =
      gles_bind(&GLES2Interface::FramebufferRenderbuffer, impl);
  functions->fFramebufferTexture2D =
      gles_bind(&GLES2Interface::FramebufferTexture2D, impl);
  functions->fFramebufferTexture2DMultisample =
      gles_bind(&GLES2Interface::FramebufferTexture2DMultisampleEXT, impl);
  functions->fGenFramebuffers =
      gles_bind(&GLES2Interface::GenFramebuffers, impl);
  functions->fGenRenderbuffers =
      gles_bind(&GLES2Interface::GenRenderbuffers, impl);
  functions->fGetFramebufferAttachmentParameteriv =
      gles_bind(&GLES2Interface::GetFramebufferAttachmentParameteriv, impl);
  functions->fGetRenderbufferParameteriv =
      gles_bind(&GLES2Interface::GetRenderbufferParameteriv, impl);
  functions->fRenderbufferStorage =
      gles_bind(&GLES2Interface::RenderbufferStorage, impl);
  functions->fRenderbufferStorageMultisample =
      gles_bind(&GLES2Interface::RenderbufferStorageMultisampleCHROMIUM, impl);
  functions->fRenderbufferStorageMultisampleES2EXT =
      gles_bind(&GLES2Interface::RenderbufferStorageMultisampleEXT, impl);
  functions->fBindFragDataLocation =
      gles_bind(&GLES2Interface::BindFragDataLocationEXT, impl);
  functions->fBindFragDataLocationIndexed =
      gles_bind(&GLES2Interface::BindFragDataLocationIndexedEXT, impl);
  functions->fBindUniformLocation =
      gles_bind(&GLES2Interface::BindUniformLocationCHROMIUM, impl);
  functions->fBlitFramebuffer =
      gles_bind(&GLES2Interface::BlitFramebufferCHROMIUM, impl);
  functions->fGenerateMipmap = gles_bind(&GLES2Interface::GenerateMipmap, impl);
  functions->fMatrixLoadf =
      gles_bind(&GLES2Interface::MatrixLoadfCHROMIUM, impl);
  functions->fMatrixLoadIdentity =
      gles_bind(&GLES2Interface::MatrixLoadIdentityCHROMIUM, impl);
  functions->fPathCommands =
      gles_bind(&GLES2Interface::PathCommandsCHROMIUM, impl);
  functions->fPathParameteri =
      gles_bind(&GLES2Interface::PathParameteriCHROMIUM, impl);
  functions->fPathParameterf =
      gles_bind(&GLES2Interface::PathParameterfCHROMIUM, impl);
  functions->fGenPaths = gles_bind(&GLES2Interface::GenPathsCHROMIUM, impl);
  functions->fIsPath = gles_bind(&GLES2Interface::IsPathCHROMIUM, impl);
  functions->fDeletePaths =
      gles_bind(&GLES2Interface::DeletePathsCHROMIUM, impl);
  functions->fPathStencilFunc =
      gles_bind(&GLES2Interface::PathStencilFuncCHROMIUM, impl);
  functions->fStencilFillPath =
      gles_bind(&GLES2Interface::StencilFillPathCHROMIUM, impl);
  functions->fStencilStrokePath =
      gles_bind(&GLES2Interface::StencilStrokePathCHROMIUM, impl);
  functions->fCoverFillPath =
      gles_bind(&GLES2Interface::CoverFillPathCHROMIUM, impl);
  functions->fCoverStrokePath =
      gles_bind(&GLES2Interface::CoverStrokePathCHROMIUM, impl);
  functions->fStencilThenCoverFillPath =
      gles_bind(&GLES2Interface::StencilThenCoverFillPathCHROMIUM, impl);
  functions->fStencilThenCoverStrokePath =
      gles_bind(&GLES2Interface::StencilThenCoverStrokePathCHROMIUM, impl);
  functions->fStencilFillPathInstanced =
      gles_bind(&GLES2Interface::StencilFillPathInstancedCHROMIUM, impl);
  functions->fStencilStrokePathInstanced =
      gles_bind(&GLES2Interface::StencilStrokePathInstancedCHROMIUM, impl);
  functions->fCoverFillPathInstanced =
      gles_bind(&GLES2Interface::CoverFillPathInstancedCHROMIUM, impl);
  functions->fCoverStrokePathInstanced =
      gles_bind(&GLES2Interface::CoverStrokePathInstancedCHROMIUM, impl);
  functions->fStencilThenCoverFillPathInstanced = gles_bind(
      &GLES2Interface::StencilThenCoverFillPathInstancedCHROMIUM, impl);
  functions->fStencilThenCoverStrokePathInstanced = gles_bind(
      &GLES2Interface::StencilThenCoverStrokePathInstancedCHROMIUM, impl);
  functions->fProgramPathFragmentInputGen =
      gles_bind(&GLES2Interface::ProgramPathFragmentInputGenCHROMIUM, impl);
  functions->fBindFragmentInputLocation =
      gles_bind(&GLES2Interface::BindFragmentInputLocationCHROMIUM, impl);
  functions->fCoverageModulation =
      gles_bind(&GLES2Interface::CoverageModulationCHROMIUM, impl);
  return interface;
}

}  // namespace skia_bindings