| Differences between
and this patch
- a/Source/WebCore/ChangeLog +1147 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2021-11-26  Kimmo Kinnunen  <kkinnunen@apple.com>
2
3
        GraphicsContextGL should have ANGLE-specific subclass
4
        https://bugs.webkit.org/show_bug.cgi?id=233522
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Add GraphicsContextGLANGLE, rename all relevant GraphicsContextGLOpenGL symbols to this.
9
        Leave the implementations in their respective files for ease of review. Also,
10
        some of the symbols might be moved to GraphicsContextGLANGLE subclasses (GraphicsContextGLCocoa
11
        and GraphicsContextGLTextureMapper ANGLE flavor).
12
13
        GraphicsContextGLOpenGL now means "GraphicsContextGL implemented with OpenGL and OpenGLES".
14
15
        GraphicsContextGLANGLE means "GraphicsContextGL implemented with ANGLE".
16
17
        Move GraphicsContextGLOpenGLCommon.cpp into GraphicsContextGLOpenGL.cpp, these now refer to
18
        just the OpenGL implemetation.
19
20
        Duplicate "rendering result" and "compositing result" functions from GraphicsContextGLOpenGL.cpp
21
        into GraphicsContextGLANGLE.cpp. These are fairly repetitive functions that most likely will
22
        change in the future for ANGLE backend, so the interim duplicated code should not be a big issue.
23
24
        This is part of work trying to reduce the ifdef use in GraphicsContextGLOpenGL, in order to make
25
        WebGL easier to maintain correctly.
26
27
        No new tests, a refactor.
28
29
        * CMakeLists.txt:
30
        * Headers.cmake:
31
        * PlatformMac.cmake:
32
        * Sources.txt:
33
        * SourcesCocoa.txt:
34
        * WebCore.xcodeproj/project.pbxproj:
35
        * platform/graphics/GraphicsContextGL.cpp:
36
        (WebCore::GraphicsContextGL::create): Deleted.
37
        * platform/graphics/GraphicsContextGL.h:
38
        * platform/graphics/GraphicsContextGLState.h: Added.
39
        (WebCore::GraphicsContextGLState::currentBoundTexture const):
40
        (WebCore::GraphicsContextGLState::boundTexture const):
41
        (WebCore::GraphicsContextGLState::currentBoundTarget const):
42
        (WebCore::GraphicsContextGLState::boundTarget const):
43
        (WebCore::GraphicsContextGLState::setBoundTexture):
44
        * platform/graphics/angle/ExtensionsGLANGLE.cpp:
45
        (WebCore::ExtensionsGLANGLE::ExtensionsGLANGLE):
46
        * platform/graphics/angle/ExtensionsGLANGLE.h:
47
        * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
48
        (WebCore::GraphicsContextGLANGLE::drawingBufferTextureTarget):
49
        (WebCore::GraphicsContextGLANGLE::drawingBufferTextureTargetQueryForDrawingTarget):
50
        (WebCore::GraphicsContextGLANGLE::EGLDrawingBufferTextureTargetForDrawingTarget):
51
        (WebCore::GraphicsContextGLANGLE::releaseThreadResources):
52
        (WebCore::GraphicsContextGLANGLE::readPixelsForPaintResults):
53
        (WebCore::GraphicsContextGLANGLE::validateAttributes):
54
        (WebCore::GraphicsContextGLANGLE::reshapeFBOs):
55
        (WebCore::GraphicsContextGLANGLE::attachDepthAndStencilBufferIfNeeded):
56
        (WebCore::GraphicsContextGLANGLE::resolveMultisamplingIfNecessary):
57
        (WebCore::GraphicsContextGLANGLE::renderbufferStorage):
58
        (WebCore::GraphicsContextGLANGLE::getIntegerv):
59
        (WebCore::GraphicsContextGLANGLE::getShaderPrecisionFormat):
60
        (WebCore::GraphicsContextGLANGLE::texImage2D):
61
        (WebCore::GraphicsContextGLANGLE::texSubImage2D):
62
        (WebCore::GraphicsContextGLANGLE::compressedTexImage2D):
63
        (WebCore::GraphicsContextGLANGLE::compressedTexSubImage2D):
64
        (WebCore::GraphicsContextGLANGLE::depthRange):
65
        (WebCore::GraphicsContextGLANGLE::clearDepth):
66
        (WebCore::GraphicsContextGLANGLE::getExtensions):
67
        (WebCore::GraphicsContextGLANGLE::readnPixels):
68
        (WebCore::GraphicsContextGLANGLE::readnPixelsImpl):
69
        (WebCore::GraphicsContextGLANGLE::validateDepthStencil):
70
        (WebCore::GraphicsContextGLANGLE::prepareTexture):
71
        (WebCore::GraphicsContextGLANGLE::prepareTextureImpl):
72
        (WebCore::GraphicsContextGLANGLE::readRenderingResults):
73
        (WebCore::GraphicsContextGLANGLE::reshape):
74
        (WebCore::GraphicsContextGLANGLE::activeTexture):
75
        (WebCore::GraphicsContextGLANGLE::attachShader):
76
        (WebCore::GraphicsContextGLANGLE::bindAttribLocation):
77
        (WebCore::GraphicsContextGLANGLE::bindBuffer):
78
        (WebCore::GraphicsContextGLANGLE::bindFramebuffer):
79
        (WebCore::GraphicsContextGLANGLE::bindRenderbuffer):
80
        (WebCore::GraphicsContextGLANGLE::bindTexture):
81
        (WebCore::GraphicsContextGLANGLE::blendColor):
82
        (WebCore::GraphicsContextGLANGLE::blendEquation):
83
        (WebCore::GraphicsContextGLANGLE::blendEquationSeparate):
84
        (WebCore::GraphicsContextGLANGLE::blendFunc):
85
        (WebCore::GraphicsContextGLANGLE::blendFuncSeparate):
86
        (WebCore::GraphicsContextGLANGLE::bufferData):
87
        (WebCore::GraphicsContextGLANGLE::bufferSubData):
88
        (WebCore::GraphicsContextGLANGLE::getBufferSubData):
89
        (WebCore::GraphicsContextGLANGLE::copyBufferSubData):
90
        (WebCore::GraphicsContextGLANGLE::getInternalformativ):
91
        (WebCore::GraphicsContextGLANGLE::renderbufferStorageMultisample):
92
        (WebCore::GraphicsContextGLANGLE::texStorage2D):
93
        (WebCore::GraphicsContextGLANGLE::texStorage3D):
94
        (WebCore::GraphicsContextGLANGLE::texImage3D):
95
        (WebCore::GraphicsContextGLANGLE::texSubImage3D):
96
        (WebCore::GraphicsContextGLANGLE::compressedTexImage3D):
97
        (WebCore::GraphicsContextGLANGLE::compressedTexSubImage3D):
98
        (WebCore::GraphicsContextGLANGLE::getActiveUniforms):
99
        (WebCore::GraphicsContextGLANGLE::checkFramebufferStatus):
100
        (WebCore::GraphicsContextGLANGLE::clearColor):
101
        (WebCore::GraphicsContextGLANGLE::clear):
102
        (WebCore::GraphicsContextGLANGLE::clearStencil):
103
        (WebCore::GraphicsContextGLANGLE::colorMask):
104
        (WebCore::GraphicsContextGLANGLE::compileShader):
105
        (WebCore::GraphicsContextGLANGLE::compileShaderDirect):
106
        (WebCore::GraphicsContextGLANGLE::texImage2DDirect):
107
        (WebCore::GraphicsContextGLANGLE::copyTexImage2D):
108
        (WebCore::GraphicsContextGLANGLE::copyTexSubImage2D):
109
        (WebCore::GraphicsContextGLANGLE::cullFace):
110
        (WebCore::GraphicsContextGLANGLE::depthFunc):
111
        (WebCore::GraphicsContextGLANGLE::depthMask):
112
        (WebCore::GraphicsContextGLANGLE::detachShader):
113
        (WebCore::GraphicsContextGLANGLE::disable):
114
        (WebCore::GraphicsContextGLANGLE::disableVertexAttribArray):
115
        (WebCore::GraphicsContextGLANGLE::drawArrays):
116
        (WebCore::GraphicsContextGLANGLE::drawElements):
117
        (WebCore::GraphicsContextGLANGLE::enable):
118
        (WebCore::GraphicsContextGLANGLE::enableVertexAttribArray):
119
        (WebCore::GraphicsContextGLANGLE::finish):
120
        (WebCore::GraphicsContextGLANGLE::flush):
121
        (WebCore::GraphicsContextGLANGLE::framebufferRenderbuffer):
122
        (WebCore::GraphicsContextGLANGLE::framebufferTexture2D):
123
        (WebCore::GraphicsContextGLANGLE::frontFace):
124
        (WebCore::GraphicsContextGLANGLE::generateMipmap):
125
        (WebCore::GraphicsContextGLANGLE::getActiveAttribImpl):
126
        (WebCore::GraphicsContextGLANGLE::getActiveAttrib):
127
        (WebCore::GraphicsContextGLANGLE::getActiveUniformImpl):
128
        (WebCore::GraphicsContextGLANGLE::getActiveUniform):
129
        (WebCore::GraphicsContextGLANGLE::getAttachedShaders):
130
        (WebCore::GraphicsContextGLANGLE::getAttribLocation):
131
        (WebCore::GraphicsContextGLANGLE::getAttribLocationDirect):
132
        (WebCore::GraphicsContextGLANGLE::moveErrorsToSyntheticErrorList):
133
        (WebCore::GraphicsContextGLANGLE::getError):
134
        (WebCore::GraphicsContextGLANGLE::getString):
135
        (WebCore::GraphicsContextGLANGLE::hint):
136
        (WebCore::GraphicsContextGLANGLE::isBuffer):
137
        (WebCore::GraphicsContextGLANGLE::isEnabled):
138
        (WebCore::GraphicsContextGLANGLE::isFramebuffer):
139
        (WebCore::GraphicsContextGLANGLE::isProgram):
140
        (WebCore::GraphicsContextGLANGLE::isRenderbuffer):
141
        (WebCore::GraphicsContextGLANGLE::isShader):
142
        (WebCore::GraphicsContextGLANGLE::isTexture):
143
        (WebCore::GraphicsContextGLANGLE::lineWidth):
144
        (WebCore::GraphicsContextGLANGLE::linkProgram):
145
        (WebCore::GraphicsContextGLANGLE::pixelStorei):
146
        (WebCore::GraphicsContextGLANGLE::polygonOffset):
147
        (WebCore::GraphicsContextGLANGLE::sampleCoverage):
148
        (WebCore::GraphicsContextGLANGLE::scissor):
149
        (WebCore::GraphicsContextGLANGLE::shaderSource):
150
        (WebCore::GraphicsContextGLANGLE::stencilFunc):
151
        (WebCore::GraphicsContextGLANGLE::stencilFuncSeparate):
152
        (WebCore::GraphicsContextGLANGLE::stencilMask):
153
        (WebCore::GraphicsContextGLANGLE::stencilMaskSeparate):
154
        (WebCore::GraphicsContextGLANGLE::stencilOp):
155
        (WebCore::GraphicsContextGLANGLE::stencilOpSeparate):
156
        (WebCore::GraphicsContextGLANGLE::texParameterf):
157
        (WebCore::GraphicsContextGLANGLE::texParameteri):
158
        (WebCore::GraphicsContextGLANGLE::uniform1f):
159
        (WebCore::GraphicsContextGLANGLE::uniform1fv):
160
        (WebCore::GraphicsContextGLANGLE::uniform2f):
161
        (WebCore::GraphicsContextGLANGLE::uniform2fv):
162
        (WebCore::GraphicsContextGLANGLE::uniform3f):
163
        (WebCore::GraphicsContextGLANGLE::uniform3fv):
164
        (WebCore::GraphicsContextGLANGLE::uniform4f):
165
        (WebCore::GraphicsContextGLANGLE::uniform4fv):
166
        (WebCore::GraphicsContextGLANGLE::uniform1i):
167
        (WebCore::GraphicsContextGLANGLE::uniform1iv):
168
        (WebCore::GraphicsContextGLANGLE::uniform2i):
169
        (WebCore::GraphicsContextGLANGLE::uniform2iv):
170
        (WebCore::GraphicsContextGLANGLE::uniform3i):
171
        (WebCore::GraphicsContextGLANGLE::uniform3iv):
172
        (WebCore::GraphicsContextGLANGLE::uniform4i):
173
        (WebCore::GraphicsContextGLANGLE::uniform4iv):
174
        (WebCore::GraphicsContextGLANGLE::uniformMatrix2fv):
175
        (WebCore::GraphicsContextGLANGLE::uniformMatrix3fv):
176
        (WebCore::GraphicsContextGLANGLE::uniformMatrix4fv):
177
        (WebCore::GraphicsContextGLANGLE::useProgram):
178
        (WebCore::GraphicsContextGLANGLE::validateProgram):
179
        (WebCore::GraphicsContextGLANGLE::vertexAttrib1f):
180
        (WebCore::GraphicsContextGLANGLE::vertexAttrib1fv):
181
        (WebCore::GraphicsContextGLANGLE::vertexAttrib2f):
182
        (WebCore::GraphicsContextGLANGLE::vertexAttrib2fv):
183
        (WebCore::GraphicsContextGLANGLE::vertexAttrib3f):
184
        (WebCore::GraphicsContextGLANGLE::vertexAttrib3fv):
185
        (WebCore::GraphicsContextGLANGLE::vertexAttrib4f):
186
        (WebCore::GraphicsContextGLANGLE::vertexAttrib4fv):
187
        (WebCore::GraphicsContextGLANGLE::vertexAttribPointer):
188
        (WebCore::GraphicsContextGLANGLE::vertexAttribIPointer):
189
        (WebCore::GraphicsContextGLANGLE::viewport):
190
        (WebCore::GraphicsContextGLANGLE::createVertexArray):
191
        (WebCore::GraphicsContextGLANGLE::deleteVertexArray):
192
        (WebCore::GraphicsContextGLANGLE::isVertexArray):
193
        (WebCore::GraphicsContextGLANGLE::bindVertexArray):
194
        (WebCore::GraphicsContextGLANGLE::getBooleanv):
195
        (WebCore::GraphicsContextGLANGLE::getBufferParameteri):
196
        (WebCore::GraphicsContextGLANGLE::getFloatv):
197
        (WebCore::GraphicsContextGLANGLE::getInteger64):
198
        (WebCore::GraphicsContextGLANGLE::getInteger64i):
199
        (WebCore::GraphicsContextGLANGLE::getFramebufferAttachmentParameteri):
200
        (WebCore::GraphicsContextGLANGLE::getProgrami):
201
        (WebCore::GraphicsContextGLANGLE::getUnmangledInfoLog):
202
        (WebCore::GraphicsContextGLANGLE::getProgramInfoLog):
203
        (WebCore::GraphicsContextGLANGLE::getRenderbufferParameteri):
204
        (WebCore::GraphicsContextGLANGLE::getShaderi):
205
        (WebCore::GraphicsContextGLANGLE::getShaderInfoLog):
206
        (WebCore::GraphicsContextGLANGLE::getShaderSource):
207
        (WebCore::GraphicsContextGLANGLE::getTexParameterf):
208
        (WebCore::GraphicsContextGLANGLE::getTexParameteri):
209
        (WebCore::GraphicsContextGLANGLE::getUniformfv):
210
        (WebCore::GraphicsContextGLANGLE::getUniformiv):
211
        (WebCore::GraphicsContextGLANGLE::getUniformuiv):
212
        (WebCore::GraphicsContextGLANGLE::getUniformLocation):
213
        (WebCore::GraphicsContextGLANGLE::getVertexAttribOffset):
214
        (WebCore::GraphicsContextGLANGLE::createBuffer):
215
        (WebCore::GraphicsContextGLANGLE::createFramebuffer):
216
        (WebCore::GraphicsContextGLANGLE::createProgram):
217
        (WebCore::GraphicsContextGLANGLE::createRenderbuffer):
218
        (WebCore::GraphicsContextGLANGLE::createShader):
219
        (WebCore::GraphicsContextGLANGLE::createTexture):
220
        (WebCore::GraphicsContextGLANGLE::deleteBuffer):
221
        (WebCore::GraphicsContextGLANGLE::deleteFramebuffer):
222
        (WebCore::GraphicsContextGLANGLE::deleteProgram):
223
        (WebCore::GraphicsContextGLANGLE::deleteRenderbuffer):
224
        (WebCore::GraphicsContextGLANGLE::deleteShader):
225
        (WebCore::GraphicsContextGLANGLE::deleteTexture):
226
        (WebCore::GraphicsContextGLANGLE::synthesizeGLError):
227
        (WebCore::GraphicsContextGLANGLE::forceContextLost):
228
        (WebCore::GraphicsContextGLANGLE::recycleContext):
229
        (WebCore::GraphicsContextGLANGLE::dispatchContextChangedNotification):
230
        (WebCore::GraphicsContextGLANGLE::drawArraysInstanced):
231
        (WebCore::GraphicsContextGLANGLE::drawElementsInstanced):
232
        (WebCore::GraphicsContextGLANGLE::vertexAttribDivisor):
233
        (WebCore::GraphicsContextGLANGLE::getUniformBlockIndex):
234
        (WebCore::GraphicsContextGLANGLE::getActiveUniformBlockName):
235
        (WebCore::GraphicsContextGLANGLE::uniformBlockBinding):
236
        (WebCore::GraphicsContextGLANGLE::createQuery):
237
        (WebCore::GraphicsContextGLANGLE::beginQuery):
238
        (WebCore::GraphicsContextGLANGLE::endQuery):
239
        (WebCore::GraphicsContextGLANGLE::getQueryObjectui):
240
        (WebCore::GraphicsContextGLANGLE::createTransformFeedback):
241
        (WebCore::GraphicsContextGLANGLE::deleteTransformFeedback):
242
        (WebCore::GraphicsContextGLANGLE::isTransformFeedback):
243
        (WebCore::GraphicsContextGLANGLE::bindTransformFeedback):
244
        (WebCore::GraphicsContextGLANGLE::beginTransformFeedback):
245
        (WebCore::GraphicsContextGLANGLE::endTransformFeedback):
246
        (WebCore::GraphicsContextGLANGLE::transformFeedbackVaryings):
247
        (WebCore::GraphicsContextGLANGLE::getTransformFeedbackVarying):
248
        (WebCore::GraphicsContextGLANGLE::bindBufferBase):
249
        (WebCore::GraphicsContextGLANGLE::blitFramebuffer):
250
        (WebCore::GraphicsContextGLANGLE::framebufferTextureLayer):
251
        (WebCore::GraphicsContextGLANGLE::invalidateFramebuffer):
252
        (WebCore::GraphicsContextGLANGLE::invalidateSubFramebuffer):
253
        (WebCore::GraphicsContextGLANGLE::readBuffer):
254
        (WebCore::GraphicsContextGLANGLE::copyTexSubImage3D):
255
        (WebCore::GraphicsContextGLANGLE::getFragDataLocation):
256
        (WebCore::GraphicsContextGLANGLE::uniform1ui):
257
        (WebCore::GraphicsContextGLANGLE::uniform2ui):
258
        (WebCore::GraphicsContextGLANGLE::uniform3ui):
259
        (WebCore::GraphicsContextGLANGLE::uniform4ui):
260
        (WebCore::GraphicsContextGLANGLE::uniform1uiv):
261
        (WebCore::GraphicsContextGLANGLE::uniform2uiv):
262
        (WebCore::GraphicsContextGLANGLE::uniform3uiv):
263
        (WebCore::GraphicsContextGLANGLE::uniform4uiv):
264
        (WebCore::GraphicsContextGLANGLE::uniformMatrix2x3fv):
265
        (WebCore::GraphicsContextGLANGLE::uniformMatrix3x2fv):
266
        (WebCore::GraphicsContextGLANGLE::uniformMatrix2x4fv):
267
        (WebCore::GraphicsContextGLANGLE::uniformMatrix4x2fv):
268
        (WebCore::GraphicsContextGLANGLE::uniformMatrix3x4fv):
269
        (WebCore::GraphicsContextGLANGLE::uniformMatrix4x3fv):
270
        (WebCore::GraphicsContextGLANGLE::vertexAttribI4i):
271
        (WebCore::GraphicsContextGLANGLE::vertexAttribI4iv):
272
        (WebCore::GraphicsContextGLANGLE::vertexAttribI4ui):
273
        (WebCore::GraphicsContextGLANGLE::vertexAttribI4uiv):
274
        (WebCore::GraphicsContextGLANGLE::drawRangeElements):
275
        (WebCore::GraphicsContextGLANGLE::drawBuffers):
276
        (WebCore::GraphicsContextGLANGLE::clearBufferiv):
277
        (WebCore::GraphicsContextGLANGLE::clearBufferuiv):
278
        (WebCore::GraphicsContextGLANGLE::clearBufferfv):
279
        (WebCore::GraphicsContextGLANGLE::clearBufferfi):
280
        (WebCore::GraphicsContextGLANGLE::deleteQuery):
281
        (WebCore::GraphicsContextGLANGLE::isQuery):
282
        (WebCore::GraphicsContextGLANGLE::getQuery):
283
        (WebCore::GraphicsContextGLANGLE::createSampler):
284
        (WebCore::GraphicsContextGLANGLE::deleteSampler):
285
        (WebCore::GraphicsContextGLANGLE::isSampler):
286
        (WebCore::GraphicsContextGLANGLE::bindSampler):
287
        (WebCore::GraphicsContextGLANGLE::samplerParameteri):
288
        (WebCore::GraphicsContextGLANGLE::samplerParameterf):
289
        (WebCore::GraphicsContextGLANGLE::getSamplerParameterf):
290
        (WebCore::GraphicsContextGLANGLE::getSamplerParameteri):
291
        (WebCore::GraphicsContextGLANGLE::fenceSync):
292
        (WebCore::GraphicsContextGLANGLE::isSync):
293
        (WebCore::GraphicsContextGLANGLE::deleteSync):
294
        (WebCore::GraphicsContextGLANGLE::clientWaitSync):
295
        (WebCore::GraphicsContextGLANGLE::waitSync):
296
        (WebCore::GraphicsContextGLANGLE::getSynci):
297
        (WebCore::GraphicsContextGLANGLE::pauseTransformFeedback):
298
        (WebCore::GraphicsContextGLANGLE::resumeTransformFeedback):
299
        (WebCore::GraphicsContextGLANGLE::bindBufferRange):
300
        (WebCore::GraphicsContextGLANGLE::getUniformIndices):
301
        (WebCore::GraphicsContextGLANGLE::getActiveUniformBlockiv):
302
        (WebCore::GraphicsContextGLANGLE::multiDrawArraysANGLE):
303
        (WebCore::GraphicsContextGLANGLE::multiDrawArraysInstancedANGLE):
304
        (WebCore::GraphicsContextGLANGLE::multiDrawElementsANGLE):
305
        (WebCore::GraphicsContextGLANGLE::multiDrawElementsInstancedANGLE):
306
        (WebCore::GraphicsContextGLANGLE::waitAndUpdateOldestFrame):
307
        (WebCore::GraphicsContextGLANGLE::simulateEventForTesting):
308
        (WebCore::GraphicsContextGLANGLE::isGLES2Compliant const):
309
        (WebCore::GraphicsContextGLANGLE::paintRenderingResultsToCanvas):
310
        (WebCore::GraphicsContextGLANGLE::paintCompositedResultsToCanvas):
311
        (WebCore::GraphicsContextGLANGLE::paintRenderingResultsToPixelBuffer):
312
        (WebCore::GraphicsContextGLANGLE::readRenderingResultsForPainting):
313
        (WebCore::GraphicsContextGLANGLE::readCompositedResultsForPainting):
314
        (WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTarget): Deleted.
315
        (WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTargetQueryForDrawingTarget): Deleted.
316
        (WebCore::GraphicsContextGLOpenGL::EGLDrawingBufferTextureTargetForDrawingTarget): Deleted.
317
        (WebCore::GraphicsContextGLOpenGL::releaseThreadResources): Deleted.
318
        (WebCore::GraphicsContextGLOpenGL::readPixelsForPaintResults): Deleted.
319
        (WebCore::GraphicsContextGLOpenGL::validateAttributes): Deleted.
320
        (WebCore::GraphicsContextGLOpenGL::reshapeFBOs): Deleted.
321
        (WebCore::GraphicsContextGLOpenGL::attachDepthAndStencilBufferIfNeeded): Deleted.
322
        (WebCore::GraphicsContextGLOpenGL::resolveMultisamplingIfNecessary): Deleted.
323
        (WebCore::GraphicsContextGLOpenGL::renderbufferStorage): Deleted.
324
        (WebCore::GraphicsContextGLOpenGL::getIntegerv): Deleted.
325
        (WebCore::GraphicsContextGLOpenGL::getShaderPrecisionFormat): Deleted.
326
        (WebCore::GraphicsContextGLOpenGL::texImage2D): Deleted.
327
        (WebCore::GraphicsContextGLOpenGL::texSubImage2D): Deleted.
328
        (WebCore::GraphicsContextGLOpenGL::compressedTexImage2D): Deleted.
329
        (WebCore::GraphicsContextGLOpenGL::compressedTexSubImage2D): Deleted.
330
        (WebCore::GraphicsContextGLOpenGL::depthRange): Deleted.
331
        (WebCore::GraphicsContextGLOpenGL::clearDepth): Deleted.
332
        (WebCore::GraphicsContextGLOpenGL::getExtensions): Deleted.
333
        (WebCore::GraphicsContextGLOpenGL::readnPixels): Deleted.
334
        (WebCore::GraphicsContextGLOpenGL::readnPixelsImpl): Deleted.
335
        (WebCore::GraphicsContextGLOpenGL::validateDepthStencil): Deleted.
336
        (WebCore::GraphicsContextGLOpenGL::prepareTexture): Deleted.
337
        (WebCore::GraphicsContextGLOpenGL::prepareTextureImpl): Deleted.
338
        (WebCore::GraphicsContextGLOpenGL::readRenderingResults): Deleted.
339
        (WebCore::GraphicsContextGLOpenGL::reshape): Deleted.
340
        (WebCore::GraphicsContextGLOpenGL::activeTexture): Deleted.
341
        (WebCore::GraphicsContextGLOpenGL::attachShader): Deleted.
342
        (WebCore::GraphicsContextGLOpenGL::bindAttribLocation): Deleted.
343
        (WebCore::GraphicsContextGLOpenGL::bindBuffer): Deleted.
344
        (WebCore::GraphicsContextGLOpenGL::bindFramebuffer): Deleted.
345
        (WebCore::GraphicsContextGLOpenGL::bindRenderbuffer): Deleted.
346
        (WebCore::GraphicsContextGLOpenGL::bindTexture): Deleted.
347
        (WebCore::GraphicsContextGLOpenGL::blendColor): Deleted.
348
        (WebCore::GraphicsContextGLOpenGL::blendEquation): Deleted.
349
        (WebCore::GraphicsContextGLOpenGL::blendEquationSeparate): Deleted.
350
        (WebCore::GraphicsContextGLOpenGL::blendFunc): Deleted.
351
        (WebCore::GraphicsContextGLOpenGL::blendFuncSeparate): Deleted.
352
        (WebCore::GraphicsContextGLOpenGL::bufferData): Deleted.
353
        (WebCore::GraphicsContextGLOpenGL::bufferSubData): Deleted.
354
        (WebCore::GraphicsContextGLOpenGL::getBufferSubData): Deleted.
355
        (WebCore::GraphicsContextGLOpenGL::copyBufferSubData): Deleted.
356
        (WebCore::GraphicsContextGLOpenGL::getInternalformativ): Deleted.
357
        (WebCore::GraphicsContextGLOpenGL::renderbufferStorageMultisample): Deleted.
358
        (WebCore::GraphicsContextGLOpenGL::texStorage2D): Deleted.
359
        (WebCore::GraphicsContextGLOpenGL::texStorage3D): Deleted.
360
        (WebCore::GraphicsContextGLOpenGL::texImage3D): Deleted.
361
        (WebCore::GraphicsContextGLOpenGL::texSubImage3D): Deleted.
362
        (WebCore::GraphicsContextGLOpenGL::compressedTexImage3D): Deleted.
363
        (WebCore::GraphicsContextGLOpenGL::compressedTexSubImage3D): Deleted.
364
        (WebCore::GraphicsContextGLOpenGL::getActiveUniforms): Deleted.
365
        (WebCore::GraphicsContextGLOpenGL::checkFramebufferStatus): Deleted.
366
        (WebCore::GraphicsContextGLOpenGL::clearColor): Deleted.
367
        (WebCore::GraphicsContextGLOpenGL::clear): Deleted.
368
        (WebCore::GraphicsContextGLOpenGL::clearStencil): Deleted.
369
        (WebCore::GraphicsContextGLOpenGL::colorMask): Deleted.
370
        (WebCore::GraphicsContextGLOpenGL::compileShader): Deleted.
371
        (WebCore::GraphicsContextGLOpenGL::compileShaderDirect): Deleted.
372
        (WebCore::GraphicsContextGLOpenGL::texImage2DDirect): Deleted.
373
        (WebCore::GraphicsContextGLOpenGL::copyTexImage2D): Deleted.
374
        (WebCore::GraphicsContextGLOpenGL::copyTexSubImage2D): Deleted.
375
        (WebCore::GraphicsContextGLOpenGL::cullFace): Deleted.
376
        (WebCore::GraphicsContextGLOpenGL::depthFunc): Deleted.
377
        (WebCore::GraphicsContextGLOpenGL::depthMask): Deleted.
378
        (WebCore::GraphicsContextGLOpenGL::detachShader): Deleted.
379
        (WebCore::GraphicsContextGLOpenGL::disable): Deleted.
380
        (WebCore::GraphicsContextGLOpenGL::disableVertexAttribArray): Deleted.
381
        (WebCore::GraphicsContextGLOpenGL::drawArrays): Deleted.
382
        (WebCore::GraphicsContextGLOpenGL::drawElements): Deleted.
383
        (WebCore::GraphicsContextGLOpenGL::enable): Deleted.
384
        (WebCore::GraphicsContextGLOpenGL::enableVertexAttribArray): Deleted.
385
        (WebCore::GraphicsContextGLOpenGL::finish): Deleted.
386
        (WebCore::GraphicsContextGLOpenGL::flush): Deleted.
387
        (WebCore::GraphicsContextGLOpenGL::framebufferRenderbuffer): Deleted.
388
        (WebCore::GraphicsContextGLOpenGL::framebufferTexture2D): Deleted.
389
        (WebCore::GraphicsContextGLOpenGL::frontFace): Deleted.
390
        (WebCore::GraphicsContextGLOpenGL::generateMipmap): Deleted.
391
        (WebCore::GraphicsContextGLOpenGL::getActiveAttribImpl): Deleted.
392
        (WebCore::GraphicsContextGLOpenGL::getActiveAttrib): Deleted.
393
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformImpl): Deleted.
394
        (WebCore::GraphicsContextGLOpenGL::getActiveUniform): Deleted.
395
        (WebCore::GraphicsContextGLOpenGL::getAttachedShaders): Deleted.
396
        (WebCore::GraphicsContextGLOpenGL::getAttribLocation): Deleted.
397
        (WebCore::GraphicsContextGLOpenGL::getAttribLocationDirect): Deleted.
398
        (WebCore::GraphicsContextGLOpenGL::moveErrorsToSyntheticErrorList): Deleted.
399
        (WebCore::GraphicsContextGLOpenGL::getError): Deleted.
400
        (WebCore::GraphicsContextGLOpenGL::getString): Deleted.
401
        (WebCore::GraphicsContextGLOpenGL::hint): Deleted.
402
        (WebCore::GraphicsContextGLOpenGL::isBuffer): Deleted.
403
        (WebCore::GraphicsContextGLOpenGL::isEnabled): Deleted.
404
        (WebCore::GraphicsContextGLOpenGL::isFramebuffer): Deleted.
405
        (WebCore::GraphicsContextGLOpenGL::isProgram): Deleted.
406
        (WebCore::GraphicsContextGLOpenGL::isRenderbuffer): Deleted.
407
        (WebCore::GraphicsContextGLOpenGL::isShader): Deleted.
408
        (WebCore::GraphicsContextGLOpenGL::isTexture): Deleted.
409
        (WebCore::GraphicsContextGLOpenGL::lineWidth): Deleted.
410
        (WebCore::GraphicsContextGLOpenGL::linkProgram): Deleted.
411
        (WebCore::GraphicsContextGLOpenGL::pixelStorei): Deleted.
412
        (WebCore::GraphicsContextGLOpenGL::polygonOffset): Deleted.
413
        (WebCore::GraphicsContextGLOpenGL::sampleCoverage): Deleted.
414
        (WebCore::GraphicsContextGLOpenGL::scissor): Deleted.
415
        (WebCore::GraphicsContextGLOpenGL::shaderSource): Deleted.
416
        (WebCore::GraphicsContextGLOpenGL::stencilFunc): Deleted.
417
        (WebCore::GraphicsContextGLOpenGL::stencilFuncSeparate): Deleted.
418
        (WebCore::GraphicsContextGLOpenGL::stencilMask): Deleted.
419
        (WebCore::GraphicsContextGLOpenGL::stencilMaskSeparate): Deleted.
420
        (WebCore::GraphicsContextGLOpenGL::stencilOp): Deleted.
421
        (WebCore::GraphicsContextGLOpenGL::stencilOpSeparate): Deleted.
422
        (WebCore::GraphicsContextGLOpenGL::texParameterf): Deleted.
423
        (WebCore::GraphicsContextGLOpenGL::texParameteri): Deleted.
424
        (WebCore::GraphicsContextGLOpenGL::uniform1f): Deleted.
425
        (WebCore::GraphicsContextGLOpenGL::uniform1fv): Deleted.
426
        (WebCore::GraphicsContextGLOpenGL::uniform2f): Deleted.
427
        (WebCore::GraphicsContextGLOpenGL::uniform2fv): Deleted.
428
        (WebCore::GraphicsContextGLOpenGL::uniform3f): Deleted.
429
        (WebCore::GraphicsContextGLOpenGL::uniform3fv): Deleted.
430
        (WebCore::GraphicsContextGLOpenGL::uniform4f): Deleted.
431
        (WebCore::GraphicsContextGLOpenGL::uniform4fv): Deleted.
432
        (WebCore::GraphicsContextGLOpenGL::uniform1i): Deleted.
433
        (WebCore::GraphicsContextGLOpenGL::uniform1iv): Deleted.
434
        (WebCore::GraphicsContextGLOpenGL::uniform2i): Deleted.
435
        (WebCore::GraphicsContextGLOpenGL::uniform2iv): Deleted.
436
        (WebCore::GraphicsContextGLOpenGL::uniform3i): Deleted.
437
        (WebCore::GraphicsContextGLOpenGL::uniform3iv): Deleted.
438
        (WebCore::GraphicsContextGLOpenGL::uniform4i): Deleted.
439
        (WebCore::GraphicsContextGLOpenGL::uniform4iv): Deleted.
440
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2fv): Deleted.
441
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3fv): Deleted.
442
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4fv): Deleted.
443
        (WebCore::GraphicsContextGLOpenGL::useProgram): Deleted.
444
        (WebCore::GraphicsContextGLOpenGL::validateProgram): Deleted.
445
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib1f): Deleted.
446
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib1fv): Deleted.
447
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib2f): Deleted.
448
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib2fv): Deleted.
449
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib3f): Deleted.
450
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib3fv): Deleted.
451
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib4f): Deleted.
452
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib4fv): Deleted.
453
        (WebCore::GraphicsContextGLOpenGL::vertexAttribPointer): Deleted.
454
        (WebCore::GraphicsContextGLOpenGL::vertexAttribIPointer): Deleted.
455
        (WebCore::GraphicsContextGLOpenGL::viewport): Deleted.
456
        (WebCore::GraphicsContextGLOpenGL::createVertexArray): Deleted.
457
        (WebCore::GraphicsContextGLOpenGL::deleteVertexArray): Deleted.
458
        (WebCore::GraphicsContextGLOpenGL::isVertexArray): Deleted.
459
        (WebCore::GraphicsContextGLOpenGL::bindVertexArray): Deleted.
460
        (WebCore::GraphicsContextGLOpenGL::getBooleanv): Deleted.
461
        (WebCore::GraphicsContextGLOpenGL::getBufferParameteri): Deleted.
462
        (WebCore::GraphicsContextGLOpenGL::getFloatv): Deleted.
463
        (WebCore::GraphicsContextGLOpenGL::getInteger64): Deleted.
464
        (WebCore::GraphicsContextGLOpenGL::getInteger64i): Deleted.
465
        (WebCore::GraphicsContextGLOpenGL::getFramebufferAttachmentParameteri): Deleted.
466
        (WebCore::GraphicsContextGLOpenGL::getProgrami): Deleted.
467
        (WebCore::GraphicsContextGLOpenGL::getUnmangledInfoLog): Deleted.
468
        (WebCore::GraphicsContextGLOpenGL::getProgramInfoLog): Deleted.
469
        (WebCore::GraphicsContextGLOpenGL::getRenderbufferParameteri): Deleted.
470
        (WebCore::GraphicsContextGLOpenGL::getShaderi): Deleted.
471
        (WebCore::GraphicsContextGLOpenGL::getShaderInfoLog): Deleted.
472
        (WebCore::GraphicsContextGLOpenGL::getShaderSource): Deleted.
473
        (WebCore::GraphicsContextGLOpenGL::getTexParameterf): Deleted.
474
        (WebCore::GraphicsContextGLOpenGL::getTexParameteri): Deleted.
475
        (WebCore::GraphicsContextGLOpenGL::getUniformfv): Deleted.
476
        (WebCore::GraphicsContextGLOpenGL::getUniformiv): Deleted.
477
        (WebCore::GraphicsContextGLOpenGL::getUniformuiv): Deleted.
478
        (WebCore::GraphicsContextGLOpenGL::getUniformLocation): Deleted.
479
        (WebCore::GraphicsContextGLOpenGL::getVertexAttribOffset): Deleted.
480
        (WebCore::GraphicsContextGLOpenGL::createBuffer): Deleted.
481
        (WebCore::GraphicsContextGLOpenGL::createFramebuffer): Deleted.
482
        (WebCore::GraphicsContextGLOpenGL::createProgram): Deleted.
483
        (WebCore::GraphicsContextGLOpenGL::createRenderbuffer): Deleted.
484
        (WebCore::GraphicsContextGLOpenGL::createShader): Deleted.
485
        (WebCore::GraphicsContextGLOpenGL::createTexture): Deleted.
486
        (WebCore::GraphicsContextGLOpenGL::deleteBuffer): Deleted.
487
        (WebCore::GraphicsContextGLOpenGL::deleteFramebuffer): Deleted.
488
        (WebCore::GraphicsContextGLOpenGL::deleteProgram): Deleted.
489
        (WebCore::GraphicsContextGLOpenGL::deleteRenderbuffer): Deleted.
490
        (WebCore::GraphicsContextGLOpenGL::deleteShader): Deleted.
491
        (WebCore::GraphicsContextGLOpenGL::deleteTexture): Deleted.
492
        (WebCore::GraphicsContextGLOpenGL::synthesizeGLError): Deleted.
493
        (WebCore::GraphicsContextGLOpenGL::forceContextLost): Deleted.
494
        (WebCore::GraphicsContextGLOpenGL::recycleContext): Deleted.
495
        (WebCore::GraphicsContextGLOpenGL::dispatchContextChangedNotification): Deleted.
496
        (WebCore::GraphicsContextGLOpenGL::drawArraysInstanced): Deleted.
497
        (WebCore::GraphicsContextGLOpenGL::drawElementsInstanced): Deleted.
498
        (WebCore::GraphicsContextGLOpenGL::vertexAttribDivisor): Deleted.
499
        (WebCore::GraphicsContextGLOpenGL::getUniformBlockIndex): Deleted.
500
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformBlockName): Deleted.
501
        (WebCore::GraphicsContextGLOpenGL::uniformBlockBinding): Deleted.
502
        (WebCore::GraphicsContextGLOpenGL::createQuery): Deleted.
503
        (WebCore::GraphicsContextGLOpenGL::beginQuery): Deleted.
504
        (WebCore::GraphicsContextGLOpenGL::endQuery): Deleted.
505
        (WebCore::GraphicsContextGLOpenGL::getQueryObjectui): Deleted.
506
        (WebCore::GraphicsContextGLOpenGL::createTransformFeedback): Deleted.
507
        (WebCore::GraphicsContextGLOpenGL::deleteTransformFeedback): Deleted.
508
        (WebCore::GraphicsContextGLOpenGL::isTransformFeedback): Deleted.
509
        (WebCore::GraphicsContextGLOpenGL::bindTransformFeedback): Deleted.
510
        (WebCore::GraphicsContextGLOpenGL::beginTransformFeedback): Deleted.
511
        (WebCore::GraphicsContextGLOpenGL::endTransformFeedback): Deleted.
512
        (WebCore::GraphicsContextGLOpenGL::transformFeedbackVaryings): Deleted.
513
        (WebCore::GraphicsContextGLOpenGL::getTransformFeedbackVarying): Deleted.
514
        (WebCore::GraphicsContextGLOpenGL::bindBufferBase): Deleted.
515
        (WebCore::GraphicsContextGLOpenGL::blitFramebuffer): Deleted.
516
        (WebCore::GraphicsContextGLOpenGL::framebufferTextureLayer): Deleted.
517
        (WebCore::GraphicsContextGLOpenGL::invalidateFramebuffer): Deleted.
518
        (WebCore::GraphicsContextGLOpenGL::invalidateSubFramebuffer): Deleted.
519
        (WebCore::GraphicsContextGLOpenGL::readBuffer): Deleted.
520
        (WebCore::GraphicsContextGLOpenGL::copyTexSubImage3D): Deleted.
521
        (WebCore::GraphicsContextGLOpenGL::getFragDataLocation): Deleted.
522
        (WebCore::GraphicsContextGLOpenGL::uniform1ui): Deleted.
523
        (WebCore::GraphicsContextGLOpenGL::uniform2ui): Deleted.
524
        (WebCore::GraphicsContextGLOpenGL::uniform3ui): Deleted.
525
        (WebCore::GraphicsContextGLOpenGL::uniform4ui): Deleted.
526
        (WebCore::GraphicsContextGLOpenGL::uniform1uiv): Deleted.
527
        (WebCore::GraphicsContextGLOpenGL::uniform2uiv): Deleted.
528
        (WebCore::GraphicsContextGLOpenGL::uniform3uiv): Deleted.
529
        (WebCore::GraphicsContextGLOpenGL::uniform4uiv): Deleted.
530
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2x3fv): Deleted.
531
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3x2fv): Deleted.
532
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2x4fv): Deleted.
533
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4x2fv): Deleted.
534
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3x4fv): Deleted.
535
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4x3fv): Deleted.
536
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4i): Deleted.
537
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4iv): Deleted.
538
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4ui): Deleted.
539
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4uiv): Deleted.
540
        (WebCore::GraphicsContextGLOpenGL::drawRangeElements): Deleted.
541
        (WebCore::GraphicsContextGLOpenGL::drawBuffers): Deleted.
542
        (WebCore::GraphicsContextGLOpenGL::clearBufferiv): Deleted.
543
        (WebCore::GraphicsContextGLOpenGL::clearBufferuiv): Deleted.
544
        (WebCore::GraphicsContextGLOpenGL::clearBufferfv): Deleted.
545
        (WebCore::GraphicsContextGLOpenGL::clearBufferfi): Deleted.
546
        (WebCore::GraphicsContextGLOpenGL::deleteQuery): Deleted.
547
        (WebCore::GraphicsContextGLOpenGL::isQuery): Deleted.
548
        (WebCore::GraphicsContextGLOpenGL::getQuery): Deleted.
549
        (WebCore::GraphicsContextGLOpenGL::createSampler): Deleted.
550
        (WebCore::GraphicsContextGLOpenGL::deleteSampler): Deleted.
551
        (WebCore::GraphicsContextGLOpenGL::isSampler): Deleted.
552
        (WebCore::GraphicsContextGLOpenGL::bindSampler): Deleted.
553
        (WebCore::GraphicsContextGLOpenGL::samplerParameteri): Deleted.
554
        (WebCore::GraphicsContextGLOpenGL::samplerParameterf): Deleted.
555
        (WebCore::GraphicsContextGLOpenGL::getSamplerParameterf): Deleted.
556
        (WebCore::GraphicsContextGLOpenGL::getSamplerParameteri): Deleted.
557
        (WebCore::GraphicsContextGLOpenGL::fenceSync): Deleted.
558
        (WebCore::GraphicsContextGLOpenGL::isSync): Deleted.
559
        (WebCore::GraphicsContextGLOpenGL::deleteSync): Deleted.
560
        (WebCore::GraphicsContextGLOpenGL::clientWaitSync): Deleted.
561
        (WebCore::GraphicsContextGLOpenGL::waitSync): Deleted.
562
        (WebCore::GraphicsContextGLOpenGL::getSynci): Deleted.
563
        (WebCore::GraphicsContextGLOpenGL::pauseTransformFeedback): Deleted.
564
        (WebCore::GraphicsContextGLOpenGL::resumeTransformFeedback): Deleted.
565
        (WebCore::GraphicsContextGLOpenGL::bindBufferRange): Deleted.
566
        (WebCore::GraphicsContextGLOpenGL::getUniformIndices): Deleted.
567
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformBlockiv): Deleted.
568
        (WebCore::GraphicsContextGLOpenGL::multiDrawArraysANGLE): Deleted.
569
        (WebCore::GraphicsContextGLOpenGL::multiDrawArraysInstancedANGLE): Deleted.
570
        (WebCore::GraphicsContextGLOpenGL::multiDrawElementsANGLE): Deleted.
571
        (WebCore::GraphicsContextGLOpenGL::multiDrawElementsInstancedANGLE): Deleted.
572
        (WebCore::GraphicsContextGLOpenGL::waitAndUpdateOldestFrame): Deleted.
573
        * platform/graphics/angle/GraphicsContextGLANGLE.h: Copied from Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h.
574
        * platform/graphics/cairo/GraphicsContextGLCairo.cpp:
575
        (WebCore::GraphicsContextGL::paintToCanvas):
576
        (WebCore::GraphicsContextGLOpenGL::paintToCanvas): Deleted.
577
        * platform/graphics/cg/GraphicsContextGLCG.cpp:
578
        (WebCore::GraphicsContextGL::paintToCanvas):
579
        (WebCore::GraphicsContextGLOpenGL::paintToCanvas): Deleted.
580
        Move paintToCanvas from GraphicsContextGLOpenGL to
581
        GraphicsContextGL. It was a generic static function and did not
582
        have any dependency to the GraphicsContextGLOpenGL.
583
584
        * platform/graphics/cocoa/GraphicsContextGLCocoa.h:
585
        * platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
586
        (WebCore::initializeEGLDisplay):
587
        (WebCore::GraphicsContextGLCocoa::GraphicsContextGLCocoa):
588
        (WebCore::GraphicsContextGLANGLE::GraphicsContextGLANGLE):
589
        (WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
590
        (WebCore::GraphicsContextGLANGLE::platformLayer const):
591
        (WebCore::GraphicsContextGLANGLE::makeContextCurrent):
592
        (WebCore::GraphicsContextGLANGLE::checkGPUStatus):
593
        (WebCore::GraphicsContextGLANGLE::setContextVisibility):
594
        (WebCore::GraphicsContextGLANGLE::displayWasReconfigured):
595
        (WebCore::GraphicsContextGLANGLE::reshapeDisplayBufferBacking):
596
        (WebCore::GraphicsContextGLANGLE::allocateAndBindDisplayBufferBacking):
597
        (WebCore::GraphicsContextGLANGLE::bindDisplayBufferBacking):
598
        (WebCore::GraphicsContextGLANGLE::makeCurrent):
599
        (WebCore::GraphicsContextGLCocoa::createPbufferAndAttachIOSurface):
600
        (WebCore::GraphicsContextGLANGLE::prepareForDisplay):
601
        (WebCore::GraphicsContextGLCocoa::asCV):
602
        (WebCore::GraphicsContextGLANGLE::readCompositedResults):
603
        (WebCore::GraphicsContextGLANGLE::paintCompositedResultsToMediaSample):
604
        (WebCore::GraphicsContextGLANGLE::platformReleaseThreadResources):
605
        (WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL): Deleted.
606
        (WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL): Deleted.
607
        (WebCore::GraphicsContextGLOpenGL::platformLayer const): Deleted.
608
        (WebCore::GraphicsContextGLOpenGL::makeContextCurrent): Deleted.
609
        (WebCore::GraphicsContextGLOpenGL::checkGPUStatus): Deleted.
610
        (WebCore::GraphicsContextGLOpenGL::setContextVisibility): Deleted.
611
        (WebCore::GraphicsContextGLOpenGL::displayWasReconfigured): Deleted.
612
        (WebCore::GraphicsContextGLOpenGL::reshapeDisplayBufferBacking): Deleted.
613
        (WebCore::GraphicsContextGLOpenGL::allocateAndBindDisplayBufferBacking): Deleted.
614
        (WebCore::GraphicsContextGLOpenGL::bindDisplayBufferBacking): Deleted.
615
        (WebCore::GraphicsContextGLOpenGL::makeCurrent): Deleted.
616
        (WebCore::GraphicsContextGLOpenGL::isGLES2Compliant const): Deleted.
617
        (WebCore::GraphicsContextGLOpenGL::simulateEventForTesting): Deleted.
618
        (WebCore::GraphicsContextGLOpenGL::prepareForDisplay): Deleted.
619
        (WebCore::GraphicsContextGLOpenGL::asCV): Deleted.
620
        (WebCore::GraphicsContextGLOpenGL::readCompositedResults): Deleted.
621
        (WebCore::GraphicsContextGLOpenGL::paintCompositedResultsToMediaSample): Deleted.
622
        (WebCore::GraphicsContextGLOpenGL::platformReleaseThreadResources): Deleted.
623
        * platform/graphics/cv/GraphicsContextGLCVCocoa.cpp: Renamed from Source/WebCore/platform/graphics/cv/GraphicsContextGLCVANGLE.cpp.
624
        (WebCore::GraphicsContextGLCVCocoa::create):
625
        (WebCore::GraphicsContextGLCVCocoa::~GraphicsContextGLCVCocoa):
626
        (WebCore::GraphicsContextGLCVCocoa::GraphicsContextGLCVCocoa):
627
        (WebCore::GraphicsContextGLCVCocoa::copyPixelBufferToTexture):
628
        * platform/graphics/cv/GraphicsContextGLCVCocoa.h: Renamed from Source/WebCore/platform/graphics/cv/GraphicsContextGLCVANGLE.h.
629
        * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
630
        (WebCore::setCurrentNameHashMapForShader):
631
        (WebCore::nameHashForShader):
632
        (WebCore::GraphicsContextGLOpenGL::validateDepthStencil):
633
        (WebCore::GraphicsContextGLOpenGL::prepareTexture):
634
        (WebCore::GraphicsContextGLOpenGL::readRenderingResults):
635
        (WebCore::GraphicsContextGLOpenGL::reshape):
636
        (WebCore::GraphicsContextGLOpenGL::checkVaryingsPacking const):
637
        (WebCore::GraphicsContextGLOpenGL::precisionsMatch const):
638
        (WebCore::GraphicsContextGLOpenGL::activeTexture):
639
        (WebCore::GraphicsContextGLOpenGL::attachShader):
640
        (WebCore::GraphicsContextGLOpenGL::bindAttribLocation):
641
        (WebCore::GraphicsContextGLOpenGL::bindBuffer):
642
        (WebCore::GraphicsContextGLOpenGL::bindFramebuffer):
643
        (WebCore::GraphicsContextGLOpenGL::bindRenderbuffer):
644
        (WebCore::GraphicsContextGLOpenGL::bindTexture):
645
        (WebCore::GraphicsContextGLOpenGL::blendColor):
646
        (WebCore::GraphicsContextGLOpenGL::blendEquation):
647
        (WebCore::GraphicsContextGLOpenGL::blendEquationSeparate):
648
        (WebCore::GraphicsContextGLOpenGL::blendFunc):
649
        (WebCore::GraphicsContextGLOpenGL::blendFuncSeparate):
650
        (WebCore::GraphicsContextGLOpenGL::bufferData):
651
        (WebCore::GraphicsContextGLOpenGL::bufferSubData):
652
        (WebCore::GraphicsContextGLOpenGL::checkFramebufferStatus):
653
        (WebCore::GraphicsContextGLOpenGL::clearColor):
654
        (WebCore::GraphicsContextGLOpenGL::clear):
655
        (WebCore::GraphicsContextGLOpenGL::clearStencil):
656
        (WebCore::GraphicsContextGLOpenGL::colorMask):
657
        (WebCore::GraphicsContextGLOpenGL::compileShader):
658
        (WebCore::GraphicsContextGLOpenGL::compileShaderDirect):
659
        (WebCore::GraphicsContextGLOpenGL::copyTexImage2D):
660
        (WebCore::GraphicsContextGLOpenGL::copyTexSubImage2D):
661
        (WebCore::GraphicsContextGLOpenGL::cullFace):
662
        (WebCore::GraphicsContextGLOpenGL::depthFunc):
663
        (WebCore::GraphicsContextGLOpenGL::depthMask):
664
        (WebCore::GraphicsContextGLOpenGL::detachShader):
665
        (WebCore::GraphicsContextGLOpenGL::disable):
666
        (WebCore::GraphicsContextGLOpenGL::disableVertexAttribArray):
667
        (WebCore::GraphicsContextGLOpenGL::drawArrays):
668
        (WebCore::GraphicsContextGLOpenGL::drawElements):
669
        (WebCore::GraphicsContextGLOpenGL::enable):
670
        (WebCore::GraphicsContextGLOpenGL::enableVertexAttribArray):
671
        (WebCore::GraphicsContextGLOpenGL::finish):
672
        (WebCore::GraphicsContextGLOpenGL::flush):
673
        (WebCore::GraphicsContextGLOpenGL::framebufferRenderbuffer):
674
        (WebCore::GraphicsContextGLOpenGL::framebufferTexture2D):
675
        (WebCore::GraphicsContextGLOpenGL::frontFace):
676
        (WebCore::GraphicsContextGLOpenGL::generateMipmap):
677
        (WebCore::GraphicsContextGLOpenGL::getActiveAttribImpl):
678
        (WebCore::GraphicsContextGLOpenGL::getActiveAttrib):
679
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformImpl):
680
        (WebCore::GraphicsContextGLOpenGL::getActiveUniform):
681
        (WebCore::GraphicsContextGLOpenGL::getAttachedShaders):
682
        (WebCore::generateHashedName):
683
        (WebCore::GraphicsContextGLOpenGL::mappedSymbolInShaderSourceMap):
684
        (WebCore::GraphicsContextGLOpenGL::mappedSymbolName):
685
        (WebCore::GraphicsContextGLOpenGL::originalSymbolInShaderSourceMap):
686
        (WebCore::GraphicsContextGLOpenGL::originalSymbolName):
687
        (WebCore::GraphicsContextGLOpenGL::getAttribLocation):
688
        (WebCore::GraphicsContextGLOpenGL::getAttribLocationDirect):
689
        (WebCore::GraphicsContextGLOpenGL::moveErrorsToSyntheticErrorList):
690
        (WebCore::GraphicsContextGLOpenGL::getError):
691
        (WebCore::GraphicsContextGLOpenGL::getString):
692
        (WebCore::GraphicsContextGLOpenGL::hint):
693
        (WebCore::GraphicsContextGLOpenGL::isBuffer):
694
        (WebCore::GraphicsContextGLOpenGL::isEnabled):
695
        (WebCore::GraphicsContextGLOpenGL::isFramebuffer):
696
        (WebCore::GraphicsContextGLOpenGL::isProgram):
697
        (WebCore::GraphicsContextGLOpenGL::isRenderbuffer):
698
        (WebCore::GraphicsContextGLOpenGL::isShader):
699
        (WebCore::GraphicsContextGLOpenGL::isTexture):
700
        (WebCore::GraphicsContextGLOpenGL::lineWidth):
701
        (WebCore::GraphicsContextGLOpenGL::linkProgram):
702
        (WebCore::GraphicsContextGLOpenGL::pixelStorei):
703
        (WebCore::GraphicsContextGLOpenGL::polygonOffset):
704
        (WebCore::GraphicsContextGLOpenGL::sampleCoverage):
705
        (WebCore::GraphicsContextGLOpenGL::scissor):
706
        (WebCore::GraphicsContextGLOpenGL::shaderSource):
707
        (WebCore::GraphicsContextGLOpenGL::stencilFunc):
708
        (WebCore::GraphicsContextGLOpenGL::stencilFuncSeparate):
709
        (WebCore::GraphicsContextGLOpenGL::stencilMask):
710
        (WebCore::GraphicsContextGLOpenGL::stencilMaskSeparate):
711
        (WebCore::GraphicsContextGLOpenGL::stencilOp):
712
        (WebCore::GraphicsContextGLOpenGL::stencilOpSeparate):
713
        (WebCore::GraphicsContextGLOpenGL::texParameterf):
714
        (WebCore::GraphicsContextGLOpenGL::texParameteri):
715
        (WebCore::GraphicsContextGLOpenGL::uniform1f):
716
        (WebCore::GraphicsContextGLOpenGL::uniform1fv):
717
        (WebCore::GraphicsContextGLOpenGL::uniform2f):
718
        (WebCore::GraphicsContextGLOpenGL::uniform2fv):
719
        (WebCore::GraphicsContextGLOpenGL::uniform3f):
720
        (WebCore::GraphicsContextGLOpenGL::uniform3fv):
721
        (WebCore::GraphicsContextGLOpenGL::uniform4f):
722
        (WebCore::GraphicsContextGLOpenGL::uniform4fv):
723
        (WebCore::GraphicsContextGLOpenGL::uniform1i):
724
        (WebCore::GraphicsContextGLOpenGL::uniform1iv):
725
        (WebCore::GraphicsContextGLOpenGL::uniform2i):
726
        (WebCore::GraphicsContextGLOpenGL::uniform2iv):
727
        (WebCore::GraphicsContextGLOpenGL::uniform3i):
728
        (WebCore::GraphicsContextGLOpenGL::uniform3iv):
729
        (WebCore::GraphicsContextGLOpenGL::uniform4i):
730
        (WebCore::GraphicsContextGLOpenGL::uniform4iv):
731
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2fv):
732
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3fv):
733
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4fv):
734
        (WebCore::GraphicsContextGLOpenGL::useProgram):
735
        (WebCore::GraphicsContextGLOpenGL::validateProgram):
736
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib1f):
737
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib1fv):
738
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib2f):
739
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib2fv):
740
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib3f):
741
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib3fv):
742
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib4f):
743
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib4fv):
744
        (WebCore::GraphicsContextGLOpenGL::vertexAttribPointer):
745
        (WebCore::GraphicsContextGLOpenGL::viewport):
746
        (WebCore::GraphicsContextGLOpenGL::createVertexArray):
747
        (WebCore::GraphicsContextGLOpenGL::deleteVertexArray):
748
        (WebCore::GraphicsContextGLOpenGL::isVertexArray):
749
        (WebCore::GraphicsContextGLOpenGL::bindVertexArray):
750
        (WebCore::GraphicsContextGLOpenGL::getBooleanv):
751
        (WebCore::GraphicsContextGLOpenGL::getBufferParameteri):
752
        (WebCore::GraphicsContextGLOpenGL::getFloatv):
753
        (WebCore::GraphicsContextGLOpenGL::getInteger64):
754
        (WebCore::GraphicsContextGLOpenGL::getInteger64i):
755
        (WebCore::GraphicsContextGLOpenGL::getFramebufferAttachmentParameteri):
756
        (WebCore::GraphicsContextGLOpenGL::getProgrami):
757
        (WebCore::GraphicsContextGLOpenGL::getNonBuiltInActiveSymbolCount):
758
        (WebCore::GraphicsContextGLOpenGL::getUnmangledInfoLog):
759
        (WebCore::GraphicsContextGLOpenGL::getProgramInfoLog):
760
        (WebCore::GraphicsContextGLOpenGL::getRenderbufferParameteri):
761
        (WebCore::GraphicsContextGLOpenGL::getShaderi):
762
        (WebCore::GraphicsContextGLOpenGL::getShaderInfoLog):
763
        (WebCore::GraphicsContextGLOpenGL::getShaderSource):
764
        (WebCore::GraphicsContextGLOpenGL::getTexParameterf):
765
        (WebCore::GraphicsContextGLOpenGL::getTexParameteri):
766
        (WebCore::GraphicsContextGLOpenGL::getUniformfv):
767
        (WebCore::GraphicsContextGLOpenGL::getUniformiv):
768
        (WebCore::GraphicsContextGLOpenGL::getUniformuiv):
769
        (WebCore::GraphicsContextGLOpenGL::getUniformLocation):
770
        (WebCore::GraphicsContextGLOpenGL::getVertexAttribOffset):
771
        (WebCore::GraphicsContextGLOpenGL::texSubImage2D):
772
        (WebCore::GraphicsContextGLOpenGL::compressedTexImage2D):
773
        (WebCore::GraphicsContextGLOpenGL::compressedTexSubImage2D):
774
        (WebCore::GraphicsContextGLOpenGL::createBuffer):
775
        (WebCore::GraphicsContextGLOpenGL::createFramebuffer):
776
        (WebCore::GraphicsContextGLOpenGL::createProgram):
777
        (WebCore::GraphicsContextGLOpenGL::createRenderbuffer):
778
        (WebCore::GraphicsContextGLOpenGL::createShader):
779
        (WebCore::GraphicsContextGLOpenGL::createTexture):
780
        (WebCore::GraphicsContextGLOpenGL::deleteBuffer):
781
        (WebCore::GraphicsContextGLOpenGL::deleteFramebuffer):
782
        (WebCore::GraphicsContextGLOpenGL::deleteProgram):
783
        (WebCore::GraphicsContextGLOpenGL::deleteRenderbuffer):
784
        (WebCore::GraphicsContextGLOpenGL::deleteShader):
785
        (WebCore::GraphicsContextGLOpenGL::deleteTexture):
786
        (WebCore::GraphicsContextGLOpenGL::synthesizeGLError):
787
        (WebCore::GraphicsContextGLOpenGL::forceContextLost):
788
        (WebCore::GraphicsContextGLOpenGL::recycleContext):
789
        (WebCore::GraphicsContextGLOpenGL::dispatchContextChangedNotification):
790
        (WebCore::GraphicsContextGLOpenGL::texImage2DDirect):
791
        (WebCore::GraphicsContextGLOpenGL::drawArraysInstanced):
792
        (WebCore::GraphicsContextGLOpenGL::drawElementsInstanced):
793
        (WebCore::GraphicsContextGLOpenGL::vertexAttribDivisor):
794
        (WebCore::GraphicsContextGLOpenGL::primitiveRestartIndex):
795
        (WebCore::GraphicsContextGLOpenGL::copyBufferSubData):
796
        (WebCore::GraphicsContextGLOpenGL::getBufferSubData):
797
        (WebCore::GraphicsContextGLOpenGL::blitFramebuffer):
798
        (WebCore::GraphicsContextGLOpenGL::framebufferTextureLayer):
799
        (WebCore::GraphicsContextGLOpenGL::invalidateFramebuffer):
800
        (WebCore::GraphicsContextGLOpenGL::invalidateSubFramebuffer):
801
        (WebCore::GraphicsContextGLOpenGL::readBuffer):
802
        (WebCore::GraphicsContextGLOpenGL::getInternalformativ):
803
        (WebCore::GraphicsContextGLOpenGL::renderbufferStorageMultisample):
804
        (WebCore::GraphicsContextGLOpenGL::texStorage2D):
805
        (WebCore::GraphicsContextGLOpenGL::texStorage3D):
806
        (WebCore::GraphicsContextGLOpenGL::copyTexSubImage3D):
807
        (WebCore::GraphicsContextGLOpenGL::getFragDataLocation):
808
        (WebCore::GraphicsContextGLOpenGL::uniform1ui):
809
        (WebCore::GraphicsContextGLOpenGL::uniform2ui):
810
        (WebCore::GraphicsContextGLOpenGL::uniform3ui):
811
        (WebCore::GraphicsContextGLOpenGL::uniform4ui):
812
        (WebCore::GraphicsContextGLOpenGL::uniform1uiv):
813
        (WebCore::GraphicsContextGLOpenGL::uniform2uiv):
814
        (WebCore::GraphicsContextGLOpenGL::uniform3uiv):
815
        (WebCore::GraphicsContextGLOpenGL::uniform4uiv):
816
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2x3fv):
817
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3x2fv):
818
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2x4fv):
819
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4x2fv):
820
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3x4fv):
821
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4x3fv):
822
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4i):
823
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4iv):
824
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4ui):
825
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4uiv):
826
        (WebCore::GraphicsContextGLOpenGL::vertexAttribIPointer):
827
        (WebCore::GraphicsContextGLOpenGL::drawRangeElements):
828
        (WebCore::GraphicsContextGLOpenGL::drawBuffers):
829
        (WebCore::GraphicsContextGLOpenGL::clearBufferiv):
830
        (WebCore::GraphicsContextGLOpenGL::clearBufferuiv):
831
        (WebCore::GraphicsContextGLOpenGL::clearBufferfv):
832
        (WebCore::GraphicsContextGLOpenGL::clearBufferfi):
833
        (WebCore::GraphicsContextGLOpenGL::createQuery):
834
        (WebCore::GraphicsContextGLOpenGL::deleteQuery):
835
        (WebCore::GraphicsContextGLOpenGL::isQuery):
836
        (WebCore::GraphicsContextGLOpenGL::beginQuery):
837
        (WebCore::GraphicsContextGLOpenGL::endQuery):
838
        (WebCore::GraphicsContextGLOpenGL::getQuery):
839
        (WebCore::GraphicsContextGLOpenGL::getQueryObjectui):
840
        (WebCore::GraphicsContextGLOpenGL::createSampler):
841
        (WebCore::GraphicsContextGLOpenGL::deleteSampler):
842
        (WebCore::GraphicsContextGLOpenGL::isSampler):
843
        (WebCore::GraphicsContextGLOpenGL::bindSampler):
844
        (WebCore::GraphicsContextGLOpenGL::samplerParameteri):
845
        (WebCore::GraphicsContextGLOpenGL::samplerParameterf):
846
        (WebCore::GraphicsContextGLOpenGL::getSamplerParameterf):
847
        (WebCore::GraphicsContextGLOpenGL::getSamplerParameteri):
848
        (WebCore::GraphicsContextGLOpenGL::fenceSync):
849
        (WebCore::GraphicsContextGLOpenGL::isSync):
850
        (WebCore::GraphicsContextGLOpenGL::deleteSync):
851
        (WebCore::GraphicsContextGLOpenGL::clientWaitSync):
852
        (WebCore::GraphicsContextGLOpenGL::waitSync):
853
        (WebCore::GraphicsContextGLOpenGL::getSynci):
854
        (WebCore::GraphicsContextGLOpenGL::createTransformFeedback):
855
        (WebCore::GraphicsContextGLOpenGL::deleteTransformFeedback):
856
        (WebCore::GraphicsContextGLOpenGL::isTransformFeedback):
857
        (WebCore::GraphicsContextGLOpenGL::bindTransformFeedback):
858
        (WebCore::GraphicsContextGLOpenGL::beginTransformFeedback):
859
        (WebCore::GraphicsContextGLOpenGL::endTransformFeedback):
860
        (WebCore::GraphicsContextGLOpenGL::transformFeedbackVaryings):
861
        (WebCore::GraphicsContextGLOpenGL::getTransformFeedbackVarying):
862
        (WebCore::GraphicsContextGLOpenGL::pauseTransformFeedback):
863
        (WebCore::GraphicsContextGLOpenGL::resumeTransformFeedback):
864
        (WebCore::GraphicsContextGLOpenGL::bindBufferBase):
865
        (WebCore::GraphicsContextGLOpenGL::bindBufferRange):
866
        (WebCore::GraphicsContextGLOpenGL::getUniformIndices):
867
        (WebCore::GraphicsContextGLOpenGL::getActiveUniforms):
868
        (WebCore::GraphicsContextGLOpenGL::getUniformBlockIndex):
869
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformBlockName):
870
        (WebCore::GraphicsContextGLOpenGL::uniformBlockBinding):
871
        (WebCore::GraphicsContextGLOpenGL::readnPixels):
872
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformBlockiv):
873
        (WebCore::GraphicsContextGLOpenGL::texImage2D):
874
        (WebCore::GraphicsContextGLOpenGL::texImage3D):
875
        (WebCore::GraphicsContextGLOpenGL::texSubImage3D):
876
        (WebCore::GraphicsContextGLOpenGL::compressedTexImage3D):
877
        (WebCore::GraphicsContextGLOpenGL::compressedTexSubImage3D):
878
        (WebCore::GraphicsContextGLOpenGL::multiDrawArraysANGLE):
879
        (WebCore::GraphicsContextGLOpenGL::multiDrawArraysInstancedANGLE):
880
        (WebCore::GraphicsContextGLOpenGL::multiDrawElementsANGLE):
881
        (WebCore::GraphicsContextGLOpenGL::multiDrawElementsInstancedANGLE):
882
        (WebCore::GraphicsContextGLOpenGL::texImage2DResourceSafe):
883
        * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
884
        * platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp: Removed.
885
        (): Deleted.
886
        (WebCore::setCurrentNameHashMapForShader): Deleted.
887
        (WebCore::nameHashForShader): Deleted.
888
        (WebCore::GraphicsContextGLOpenGL::validateDepthStencil): Deleted.
889
        (WebCore::GraphicsContextGLOpenGL::prepareTexture): Deleted.
890
        (WebCore::GraphicsContextGLOpenGL::readRenderingResults): Deleted.
891
        (WebCore::GraphicsContextGLOpenGL::reshape): Deleted.
892
        (WebCore::GraphicsContextGLOpenGL::checkVaryingsPacking const): Deleted.
893
        (WebCore::GraphicsContextGLOpenGL::precisionsMatch const): Deleted.
894
        (WebCore::GraphicsContextGLOpenGL::activeTexture): Deleted.
895
        (WebCore::GraphicsContextGLOpenGL::attachShader): Deleted.
896
        (WebCore::GraphicsContextGLOpenGL::bindAttribLocation): Deleted.
897
        (WebCore::GraphicsContextGLOpenGL::bindBuffer): Deleted.
898
        (WebCore::GraphicsContextGLOpenGL::bindFramebuffer): Deleted.
899
        (WebCore::GraphicsContextGLOpenGL::bindRenderbuffer): Deleted.
900
        (WebCore::GraphicsContextGLOpenGL::bindTexture): Deleted.
901
        (WebCore::GraphicsContextGLOpenGL::blendColor): Deleted.
902
        (WebCore::GraphicsContextGLOpenGL::blendEquation): Deleted.
903
        (WebCore::GraphicsContextGLOpenGL::blendEquationSeparate): Deleted.
904
        (WebCore::GraphicsContextGLOpenGL::blendFunc): Deleted.
905
        (WebCore::GraphicsContextGLOpenGL::blendFuncSeparate): Deleted.
906
        (WebCore::GraphicsContextGLOpenGL::bufferData): Deleted.
907
        (WebCore::GraphicsContextGLOpenGL::bufferSubData): Deleted.
908
        (WebCore::GraphicsContextGLOpenGL::checkFramebufferStatus): Deleted.
909
        (WebCore::GraphicsContextGLOpenGL::clearColor): Deleted.
910
        (WebCore::GraphicsContextGLOpenGL::clear): Deleted.
911
        (WebCore::GraphicsContextGLOpenGL::clearStencil): Deleted.
912
        (WebCore::GraphicsContextGLOpenGL::colorMask): Deleted.
913
        (WebCore::GraphicsContextGLOpenGL::compileShader): Deleted.
914
        (WebCore::GraphicsContextGLOpenGL::compileShaderDirect): Deleted.
915
        (WebCore::GraphicsContextGLOpenGL::copyTexImage2D): Deleted.
916
        (WebCore::GraphicsContextGLOpenGL::copyTexSubImage2D): Deleted.
917
        (WebCore::GraphicsContextGLOpenGL::cullFace): Deleted.
918
        (WebCore::GraphicsContextGLOpenGL::depthFunc): Deleted.
919
        (WebCore::GraphicsContextGLOpenGL::depthMask): Deleted.
920
        (WebCore::GraphicsContextGLOpenGL::detachShader): Deleted.
921
        (WebCore::GraphicsContextGLOpenGL::disable): Deleted.
922
        (WebCore::GraphicsContextGLOpenGL::disableVertexAttribArray): Deleted.
923
        (WebCore::GraphicsContextGLOpenGL::drawArrays): Deleted.
924
        (WebCore::GraphicsContextGLOpenGL::drawElements): Deleted.
925
        (WebCore::GraphicsContextGLOpenGL::enable): Deleted.
926
        (WebCore::GraphicsContextGLOpenGL::enableVertexAttribArray): Deleted.
927
        (WebCore::GraphicsContextGLOpenGL::finish): Deleted.
928
        (WebCore::GraphicsContextGLOpenGL::flush): Deleted.
929
        (WebCore::GraphicsContextGLOpenGL::framebufferRenderbuffer): Deleted.
930
        (WebCore::GraphicsContextGLOpenGL::framebufferTexture2D): Deleted.
931
        (WebCore::GraphicsContextGLOpenGL::frontFace): Deleted.
932
        (WebCore::GraphicsContextGLOpenGL::generateMipmap): Deleted.
933
        (WebCore::GraphicsContextGLOpenGL::getActiveAttribImpl): Deleted.
934
        (WebCore::GraphicsContextGLOpenGL::getActiveAttrib): Deleted.
935
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformImpl): Deleted.
936
        (WebCore::GraphicsContextGLOpenGL::getActiveUniform): Deleted.
937
        (WebCore::GraphicsContextGLOpenGL::getAttachedShaders): Deleted.
938
        (WebCore::generateHashedName): Deleted.
939
        (WebCore::GraphicsContextGLOpenGL::mappedSymbolInShaderSourceMap): Deleted.
940
        (WebCore::GraphicsContextGLOpenGL::mappedSymbolName): Deleted.
941
        (WebCore::GraphicsContextGLOpenGL::originalSymbolInShaderSourceMap): Deleted.
942
        (WebCore::GraphicsContextGLOpenGL::originalSymbolName): Deleted.
943
        (WebCore::GraphicsContextGLOpenGL::getAttribLocation): Deleted.
944
        (WebCore::GraphicsContextGLOpenGL::getAttribLocationDirect): Deleted.
945
        (WebCore::GraphicsContextGLOpenGL::moveErrorsToSyntheticErrorList): Deleted.
946
        (WebCore::GraphicsContextGLOpenGL::getError): Deleted.
947
        (WebCore::GraphicsContextGLOpenGL::getString): Deleted.
948
        (WebCore::GraphicsContextGLOpenGL::hint): Deleted.
949
        (WebCore::GraphicsContextGLOpenGL::isBuffer): Deleted.
950
        (WebCore::GraphicsContextGLOpenGL::isEnabled): Deleted.
951
        (WebCore::GraphicsContextGLOpenGL::isFramebuffer): Deleted.
952
        (WebCore::GraphicsContextGLOpenGL::isProgram): Deleted.
953
        (WebCore::GraphicsContextGLOpenGL::isRenderbuffer): Deleted.
954
        (WebCore::GraphicsContextGLOpenGL::isShader): Deleted.
955
        (WebCore::GraphicsContextGLOpenGL::isTexture): Deleted.
956
        (WebCore::GraphicsContextGLOpenGL::lineWidth): Deleted.
957
        (WebCore::GraphicsContextGLOpenGL::linkProgram): Deleted.
958
        (WebCore::GraphicsContextGLOpenGL::pixelStorei): Deleted.
959
        (WebCore::GraphicsContextGLOpenGL::polygonOffset): Deleted.
960
        (WebCore::GraphicsContextGLOpenGL::sampleCoverage): Deleted.
961
        (WebCore::GraphicsContextGLOpenGL::scissor): Deleted.
962
        (WebCore::GraphicsContextGLOpenGL::shaderSource): Deleted.
963
        (WebCore::GraphicsContextGLOpenGL::stencilFunc): Deleted.
964
        (WebCore::GraphicsContextGLOpenGL::stencilFuncSeparate): Deleted.
965
        (WebCore::GraphicsContextGLOpenGL::stencilMask): Deleted.
966
        (WebCore::GraphicsContextGLOpenGL::stencilMaskSeparate): Deleted.
967
        (WebCore::GraphicsContextGLOpenGL::stencilOp): Deleted.
968
        (WebCore::GraphicsContextGLOpenGL::stencilOpSeparate): Deleted.
969
        (WebCore::GraphicsContextGLOpenGL::texParameterf): Deleted.
970
        (WebCore::GraphicsContextGLOpenGL::texParameteri): Deleted.
971
        (WebCore::GraphicsContextGLOpenGL::uniform1f): Deleted.
972
        (WebCore::GraphicsContextGLOpenGL::uniform1fv): Deleted.
973
        (WebCore::GraphicsContextGLOpenGL::uniform2f): Deleted.
974
        (WebCore::GraphicsContextGLOpenGL::uniform2fv): Deleted.
975
        (WebCore::GraphicsContextGLOpenGL::uniform3f): Deleted.
976
        (WebCore::GraphicsContextGLOpenGL::uniform3fv): Deleted.
977
        (WebCore::GraphicsContextGLOpenGL::uniform4f): Deleted.
978
        (WebCore::GraphicsContextGLOpenGL::uniform4fv): Deleted.
979
        (WebCore::GraphicsContextGLOpenGL::uniform1i): Deleted.
980
        (WebCore::GraphicsContextGLOpenGL::uniform1iv): Deleted.
981
        (WebCore::GraphicsContextGLOpenGL::uniform2i): Deleted.
982
        (WebCore::GraphicsContextGLOpenGL::uniform2iv): Deleted.
983
        (WebCore::GraphicsContextGLOpenGL::uniform3i): Deleted.
984
        (WebCore::GraphicsContextGLOpenGL::uniform3iv): Deleted.
985
        (WebCore::GraphicsContextGLOpenGL::uniform4i): Deleted.
986
        (WebCore::GraphicsContextGLOpenGL::uniform4iv): Deleted.
987
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2fv): Deleted.
988
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3fv): Deleted.
989
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4fv): Deleted.
990
        (WebCore::GraphicsContextGLOpenGL::useProgram): Deleted.
991
        (WebCore::GraphicsContextGLOpenGL::validateProgram): Deleted.
992
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib1f): Deleted.
993
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib1fv): Deleted.
994
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib2f): Deleted.
995
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib2fv): Deleted.
996
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib3f): Deleted.
997
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib3fv): Deleted.
998
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib4f): Deleted.
999
        (WebCore::GraphicsContextGLOpenGL::vertexAttrib4fv): Deleted.
1000
        (WebCore::GraphicsContextGLOpenGL::vertexAttribPointer): Deleted.
1001
        (WebCore::GraphicsContextGLOpenGL::viewport): Deleted.
1002
        (WebCore::GraphicsContextGLOpenGL::createVertexArray): Deleted.
1003
        (WebCore::GraphicsContextGLOpenGL::deleteVertexArray): Deleted.
1004
        (WebCore::GraphicsContextGLOpenGL::isVertexArray): Deleted.
1005
        (WebCore::GraphicsContextGLOpenGL::bindVertexArray): Deleted.
1006
        (WebCore::GraphicsContextGLOpenGL::getBooleanv): Deleted.
1007
        (WebCore::GraphicsContextGLOpenGL::getBufferParameteri): Deleted.
1008
        (WebCore::GraphicsContextGLOpenGL::getFloatv): Deleted.
1009
        (WebCore::GraphicsContextGLOpenGL::getInteger64): Deleted.
1010
        (WebCore::GraphicsContextGLOpenGL::getInteger64i): Deleted.
1011
        (WebCore::GraphicsContextGLOpenGL::getFramebufferAttachmentParameteri): Deleted.
1012
        (WebCore::GraphicsContextGLOpenGL::getProgrami): Deleted.
1013
        (WebCore::GraphicsContextGLOpenGL::getNonBuiltInActiveSymbolCount): Deleted.
1014
        (WebCore::GraphicsContextGLOpenGL::getUnmangledInfoLog): Deleted.
1015
        (WebCore::GraphicsContextGLOpenGL::getProgramInfoLog): Deleted.
1016
        (WebCore::GraphicsContextGLOpenGL::getRenderbufferParameteri): Deleted.
1017
        (WebCore::GraphicsContextGLOpenGL::getShaderi): Deleted.
1018
        (WebCore::GraphicsContextGLOpenGL::getShaderInfoLog): Deleted.
1019
        (WebCore::GraphicsContextGLOpenGL::getShaderSource): Deleted.
1020
        (WebCore::GraphicsContextGLOpenGL::getTexParameterf): Deleted.
1021
        (WebCore::GraphicsContextGLOpenGL::getTexParameteri): Deleted.
1022
        (WebCore::GraphicsContextGLOpenGL::getUniformfv): Deleted.
1023
        (WebCore::GraphicsContextGLOpenGL::getUniformiv): Deleted.
1024
        (WebCore::GraphicsContextGLOpenGL::getUniformuiv): Deleted.
1025
        (WebCore::GraphicsContextGLOpenGL::getUniformLocation): Deleted.
1026
        (WebCore::GraphicsContextGLOpenGL::getVertexAttribOffset): Deleted.
1027
        (WebCore::GraphicsContextGLOpenGL::texSubImage2D): Deleted.
1028
        (WebCore::GraphicsContextGLOpenGL::compressedTexImage2D): Deleted.
1029
        (WebCore::GraphicsContextGLOpenGL::compressedTexSubImage2D): Deleted.
1030
        (WebCore::GraphicsContextGLOpenGL::createBuffer): Deleted.
1031
        (WebCore::GraphicsContextGLOpenGL::createFramebuffer): Deleted.
1032
        (WebCore::GraphicsContextGLOpenGL::createProgram): Deleted.
1033
        (WebCore::GraphicsContextGLOpenGL::createRenderbuffer): Deleted.
1034
        (WebCore::GraphicsContextGLOpenGL::createShader): Deleted.
1035
        (WebCore::GraphicsContextGLOpenGL::createTexture): Deleted.
1036
        (WebCore::GraphicsContextGLOpenGL::deleteBuffer): Deleted.
1037
        (WebCore::GraphicsContextGLOpenGL::deleteFramebuffer): Deleted.
1038
        (WebCore::GraphicsContextGLOpenGL::deleteProgram): Deleted.
1039
        (WebCore::GraphicsContextGLOpenGL::deleteRenderbuffer): Deleted.
1040
        (WebCore::GraphicsContextGLOpenGL::deleteShader): Deleted.
1041
        (WebCore::GraphicsContextGLOpenGL::deleteTexture): Deleted.
1042
        (WebCore::GraphicsContextGLOpenGL::synthesizeGLError): Deleted.
1043
        (WebCore::GraphicsContextGLOpenGL::forceContextLost): Deleted.
1044
        (WebCore::GraphicsContextGLOpenGL::recycleContext): Deleted.
1045
        (WebCore::GraphicsContextGLOpenGL::dispatchContextChangedNotification): Deleted.
1046
        (WebCore::GraphicsContextGLOpenGL::texImage2DDirect): Deleted.
1047
        (WebCore::GraphicsContextGLOpenGL::drawArraysInstanced): Deleted.
1048
        (WebCore::GraphicsContextGLOpenGL::drawElementsInstanced): Deleted.
1049
        (WebCore::GraphicsContextGLOpenGL::vertexAttribDivisor): Deleted.
1050
        (WebCore::GraphicsContextGLOpenGL::primitiveRestartIndex): Deleted.
1051
        (WebCore::GraphicsContextGLOpenGL::copyBufferSubData): Deleted.
1052
        (WebCore::GraphicsContextGLOpenGL::getBufferSubData): Deleted.
1053
        (WebCore::GraphicsContextGLOpenGL::blitFramebuffer): Deleted.
1054
        (WebCore::GraphicsContextGLOpenGL::framebufferTextureLayer): Deleted.
1055
        (WebCore::GraphicsContextGLOpenGL::invalidateFramebuffer): Deleted.
1056
        (WebCore::GraphicsContextGLOpenGL::invalidateSubFramebuffer): Deleted.
1057
        (WebCore::GraphicsContextGLOpenGL::readBuffer): Deleted.
1058
        (WebCore::GraphicsContextGLOpenGL::getInternalformativ): Deleted.
1059
        (WebCore::GraphicsContextGLOpenGL::renderbufferStorageMultisample): Deleted.
1060
        (WebCore::GraphicsContextGLOpenGL::texStorage2D): Deleted.
1061
        (WebCore::GraphicsContextGLOpenGL::texStorage3D): Deleted.
1062
        (WebCore::GraphicsContextGLOpenGL::copyTexSubImage3D): Deleted.
1063
        (WebCore::GraphicsContextGLOpenGL::getFragDataLocation): Deleted.
1064
        (WebCore::GraphicsContextGLOpenGL::uniform1ui): Deleted.
1065
        (WebCore::GraphicsContextGLOpenGL::uniform2ui): Deleted.
1066
        (WebCore::GraphicsContextGLOpenGL::uniform3ui): Deleted.
1067
        (WebCore::GraphicsContextGLOpenGL::uniform4ui): Deleted.
1068
        (WebCore::GraphicsContextGLOpenGL::uniform1uiv): Deleted.
1069
        (WebCore::GraphicsContextGLOpenGL::uniform2uiv): Deleted.
1070
        (WebCore::GraphicsContextGLOpenGL::uniform3uiv): Deleted.
1071
        (WebCore::GraphicsContextGLOpenGL::uniform4uiv): Deleted.
1072
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2x3fv): Deleted.
1073
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3x2fv): Deleted.
1074
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix2x4fv): Deleted.
1075
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4x2fv): Deleted.
1076
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix3x4fv): Deleted.
1077
        (WebCore::GraphicsContextGLOpenGL::uniformMatrix4x3fv): Deleted.
1078
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4i): Deleted.
1079
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4iv): Deleted.
1080
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4ui): Deleted.
1081
        (WebCore::GraphicsContextGLOpenGL::vertexAttribI4uiv): Deleted.
1082
        (WebCore::GraphicsContextGLOpenGL::vertexAttribIPointer): Deleted.
1083
        (WebCore::GraphicsContextGLOpenGL::drawRangeElements): Deleted.
1084
        (WebCore::GraphicsContextGLOpenGL::drawBuffers): Deleted.
1085
        (WebCore::GraphicsContextGLOpenGL::clearBufferiv): Deleted.
1086
        (WebCore::GraphicsContextGLOpenGL::clearBufferuiv): Deleted.
1087
        (WebCore::GraphicsContextGLOpenGL::clearBufferfv): Deleted.
1088
        (WebCore::GraphicsContextGLOpenGL::clearBufferfi): Deleted.
1089
        (WebCore::GraphicsContextGLOpenGL::createQuery): Deleted.
1090
        (WebCore::GraphicsContextGLOpenGL::deleteQuery): Deleted.
1091
        (WebCore::GraphicsContextGLOpenGL::isQuery): Deleted.
1092
        (WebCore::GraphicsContextGLOpenGL::beginQuery): Deleted.
1093
        (WebCore::GraphicsContextGLOpenGL::endQuery): Deleted.
1094
        (WebCore::GraphicsContextGLOpenGL::getQuery): Deleted.
1095
        (WebCore::GraphicsContextGLOpenGL::getQueryObjectui): Deleted.
1096
        (WebCore::GraphicsContextGLOpenGL::createSampler): Deleted.
1097
        (WebCore::GraphicsContextGLOpenGL::deleteSampler): Deleted.
1098
        (WebCore::GraphicsContextGLOpenGL::isSampler): Deleted.
1099
        (WebCore::GraphicsContextGLOpenGL::bindSampler): Deleted.
1100
        (WebCore::GraphicsContextGLOpenGL::samplerParameteri): Deleted.
1101
        (WebCore::GraphicsContextGLOpenGL::samplerParameterf): Deleted.
1102
        (WebCore::GraphicsContextGLOpenGL::getSamplerParameterf): Deleted.
1103
        (WebCore::GraphicsContextGLOpenGL::getSamplerParameteri): Deleted.
1104
        (WebCore::GraphicsContextGLOpenGL::fenceSync): Deleted.
1105
        (WebCore::GraphicsContextGLOpenGL::isSync): Deleted.
1106
        (WebCore::GraphicsContextGLOpenGL::deleteSync): Deleted.
1107
        (WebCore::GraphicsContextGLOpenGL::clientWaitSync): Deleted.
1108
        (WebCore::GraphicsContextGLOpenGL::waitSync): Deleted.
1109
        (WebCore::GraphicsContextGLOpenGL::getSynci): Deleted.
1110
        (WebCore::GraphicsContextGLOpenGL::createTransformFeedback): Deleted.
1111
        (WebCore::GraphicsContextGLOpenGL::deleteTransformFeedback): Deleted.
1112
        (WebCore::GraphicsContextGLOpenGL::isTransformFeedback): Deleted.
1113
        (WebCore::GraphicsContextGLOpenGL::bindTransformFeedback): Deleted.
1114
        (WebCore::GraphicsContextGLOpenGL::beginTransformFeedback): Deleted.
1115
        (WebCore::GraphicsContextGLOpenGL::endTransformFeedback): Deleted.
1116
        (WebCore::GraphicsContextGLOpenGL::transformFeedbackVaryings): Deleted.
1117
        (WebCore::GraphicsContextGLOpenGL::getTransformFeedbackVarying): Deleted.
1118
        (WebCore::GraphicsContextGLOpenGL::pauseTransformFeedback): Deleted.
1119
        (WebCore::GraphicsContextGLOpenGL::resumeTransformFeedback): Deleted.
1120
        (WebCore::GraphicsContextGLOpenGL::bindBufferBase): Deleted.
1121
        (WebCore::GraphicsContextGLOpenGL::bindBufferRange): Deleted.
1122
        (WebCore::GraphicsContextGLOpenGL::getUniformIndices): Deleted.
1123
        (WebCore::GraphicsContextGLOpenGL::getActiveUniforms): Deleted.
1124
        (WebCore::GraphicsContextGLOpenGL::getUniformBlockIndex): Deleted.
1125
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformBlockName): Deleted.
1126
        (WebCore::GraphicsContextGLOpenGL::uniformBlockBinding): Deleted.
1127
        (WebCore::GraphicsContextGLOpenGL::readnPixels): Deleted.
1128
        (WebCore::GraphicsContextGLOpenGL::getActiveUniformBlockiv): Deleted.
1129
        (WebCore::GraphicsContextGLOpenGL::texImage2D): Deleted.
1130
        (WebCore::GraphicsContextGLOpenGL::texImage3D): Deleted.
1131
        (WebCore::GraphicsContextGLOpenGL::texSubImage3D): Deleted.
1132
        (WebCore::GraphicsContextGLOpenGL::compressedTexImage3D): Deleted.
1133
        (WebCore::GraphicsContextGLOpenGL::compressedTexSubImage3D): Deleted.
1134
        (WebCore::GraphicsContextGLOpenGL::multiDrawArraysANGLE): Deleted.
1135
        (WebCore::GraphicsContextGLOpenGL::multiDrawArraysInstancedANGLE): Deleted.
1136
        (WebCore::GraphicsContextGLOpenGL::multiDrawElementsANGLE): Deleted.
1137
        (WebCore::GraphicsContextGLOpenGL::multiDrawElementsInstancedANGLE): Deleted.
1138
        (WebCore::GraphicsContextGLOpenGL::texImage2DResourceSafe): Deleted.
1139
        * platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp:
1140
        (WebCore::GraphicsContextGLOpenGLManager::addContext):
1141
        (WebCore::GraphicsContextGLOpenGLManager::removeContext):
1142
        * platform/graphics/opengl/GraphicsContextGLOpenGLManager.h:
1143
        * platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
1144
        (WebCore::GraphicsContextGLOpenGL::isGLES2Compliant const):
1145
        * platform/graphics/texmap/GraphicsContextGLTextureMapper.h:
1146
        * platform/ios/wak/WebCoreThread.mm:
1147
1
2021-11-26  Kimmo Kinnunen  <kkinnunen@apple.com>
1148
2021-11-26  Kimmo Kinnunen  <kkinnunen@apple.com>
2
1149
3
        GPUP GraphicsContextGL creation failure cannot be detected
1150
        GPUP GraphicsContextGL creation failure cannot be detected
- a/Source/WebKit/ChangeLog +15 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2021-11-26  Kimmo Kinnunen  <kkinnunen@apple.com>
2
3
        GraphicsContextGL should have ANGLE-specific subclass
4
        https://bugs.webkit.org/show_bug.cgi?id=233522
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
9
        (WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer):
10
        Function paintToCanvas was moved to GraphicsContextGL.
11
12
        * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp:
13
        (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources):
14
        Use static functions from GraphicsContextGLANGLE.
15
1
2021-11-26  Kimmo Kinnunen  <kkinnunen@apple.com>
16
2021-11-26  Kimmo Kinnunen  <kkinnunen@apple.com>
2
17
3
        GPUP GraphicsContextGL creation failure cannot be detected
18
        GPUP GraphicsContextGL creation failure cannot be detected
- a/Source/WebCore/CMakeLists.txt -1 / +1 lines
Lines 1893-1899 if (ENABLE_WEBGL) a/Source/WebCore/CMakeLists.txt_sec1
1893
            platform/graphics/ANGLEWebKitBridge.cpp
1893
            platform/graphics/ANGLEWebKitBridge.cpp
1894
1894
1895
            platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp
1895
            platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp
1896
            platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp
1896
            platform/graphics/opengl/GraphicsContextGLOpenGL.cpp
1897
            platform/graphics/opengl/TemporaryOpenGLSetting.cpp
1897
            platform/graphics/opengl/TemporaryOpenGLSetting.cpp
1898
        )
1898
        )
1899
1899
- a/Source/WebCore/Headers.cmake +1 lines
Lines 1405-1410 set(WebCore_PRIVATE_FRAMEWORK_HEADERS a/Source/WebCore/Headers.cmake_sec1
1405
1405
1406
    platform/graphics/angle/ANGLEHeaders.h
1406
    platform/graphics/angle/ANGLEHeaders.h
1407
    platform/graphics/angle/ANGLEUtilities.h
1407
    platform/graphics/angle/ANGLEUtilities.h
1408
    platform/graphics/angle/GraphicsContextGLANGLE.h
1408
    platform/graphics/angle/ExtensionsGLANGLE.h
1409
    platform/graphics/angle/ExtensionsGLANGLE.h
1409
1410
1410
    platform/graphics/displaylists/DisplayList.h
1411
    platform/graphics/displaylists/DisplayList.h
- a/Source/WebCore/PlatformMac.cmake -1 / +1 lines
Lines 337-343 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformMac.cmake_sec1
337
    platform/graphics/coretext/GlyphPageCoreText.cpp
337
    platform/graphics/coretext/GlyphPageCoreText.cpp
338
338
339
    platform/graphics/cv/CVUtilities.mm
339
    platform/graphics/cv/CVUtilities.mm
340
    platform/graphics/cv/GraphicsContextGLCVANGLE.cpp
340
    platform/graphics/cv/GraphicsContextGLCVCocoa.cpp
341
    platform/graphics/cv/ImageRotationSessionVT.mm
341
    platform/graphics/cv/ImageRotationSessionVT.mm
342
    platform/graphics/cv/PixelBufferConformerCV.cpp
342
    platform/graphics/cv/PixelBufferConformerCV.cpp
343
343
- a/Source/WebCore/Sources.txt -1 lines
Lines 2135-2141 platform/graphics/iso/ISOSchemeInformationBox.cpp a/Source/WebCore/Sources.txt_sec1
2135
platform/graphics/iso/ISOSchemeTypeBox.cpp
2135
platform/graphics/iso/ISOSchemeTypeBox.cpp
2136
platform/graphics/iso/ISOTrackEncryptionBox.cpp
2136
platform/graphics/iso/ISOTrackEncryptionBox.cpp
2137
platform/graphics/iso/ISOVTTCue.cpp
2137
platform/graphics/iso/ISOVTTCue.cpp
2138
platform/graphics/opengl/GraphicsContextGLOpenGL.cpp
2139
platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp
2138
platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp
2140
platform/graphics/opentype/OpenTypeMathData.cpp
2139
platform/graphics/opentype/OpenTypeMathData.cpp
2141
platform/graphics/transforms/AffineTransform.cpp
2140
platform/graphics/transforms/AffineTransform.cpp
- a/Source/WebCore/SourcesCocoa.txt -1 / +1 lines
Lines 401-407 platform/graphics/coretext/GlyphPageCoreText.cpp a/Source/WebCore/SourcesCocoa.txt_sec1
401
platform/graphics/cv/CVUtilities.mm
401
platform/graphics/cv/CVUtilities.mm
402
platform/graphics/cv/ImageTransferSessionVT.mm
402
platform/graphics/cv/ImageTransferSessionVT.mm
403
platform/graphics/cv/PixelBufferConformerCV.cpp
403
platform/graphics/cv/PixelBufferConformerCV.cpp
404
platform/graphics/cv/GraphicsContextGLCVANGLE.cpp
404
platform/graphics/cv/GraphicsContextGLCVCocoa.cpp
405
platform/graphics/coreimage/FilterEffectRendererCoreImage.mm
405
platform/graphics/coreimage/FilterEffectRendererCoreImage.mm
406
platform/graphics/gpu/cocoa/GPUPrewarmingMetal.mm
406
platform/graphics/gpu/cocoa/GPUPrewarmingMetal.mm
407
platform/graphics/ios/DisplayRefreshMonitorIOS.mm
407
platform/graphics/ios/DisplayRefreshMonitorIOS.mm
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj -8 / +18 lines
Lines 2360-2366 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
2360
		7AF9B20D18CFB5F400C64BEF /* JSVTTRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20918CFB5F200C64BEF /* JSVTTRegion.h */; };
2360
		7AF9B20D18CFB5F400C64BEF /* JSVTTRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20918CFB5F200C64BEF /* JSVTTRegion.h */; };
2361
		7AF9B20F18CFB5F400C64BEF /* JSVTTRegionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */; };
2361
		7AF9B20F18CFB5F400C64BEF /* JSVTTRegionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */; };
2362
		7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */; settings = {ATTRIBUTES = (Private, ); }; };
2362
		7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */; settings = {ATTRIBUTES = (Private, ); }; };
2363
		7B10339F2549721E00C8C1AC /* GraphicsContextGLCVANGLE.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339C2549720100C8C1AC /* GraphicsContextGLCVANGLE.h */; settings = {ATTRIBUTES = (Private, ); }; };
2363
		7B10339F2549721E00C8C1AC /* GraphicsContextGLCVCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339C2549720100C8C1AC /* GraphicsContextGLCVCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
2364
		7B6094DD270C44BD0064835C /* ANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* ANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
2364
		7B6094DD270C44BD0064835C /* ANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* ANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
2365
		7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */; settings = {ATTRIBUTES = (Private, ); }; };
2365
		7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */; settings = {ATTRIBUTES = (Private, ); }; };
2366
		7B7311FB25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7311FA25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
2366
		7B7311FB25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7311FA25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 2369-2375 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
2369
		7BB34A48253776CA00029D08 /* GraphicsContextGLImageExtractor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A45253776C600029D08 /* GraphicsContextGLImageExtractor.h */; settings = {ATTRIBUTES = (Private, ); }; };
2369
		7BB34A48253776CA00029D08 /* GraphicsContextGLImageExtractor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A45253776C600029D08 /* GraphicsContextGLImageExtractor.h */; settings = {ATTRIBUTES = (Private, ); }; };
2370
		7BB680BA25BA1BE4002B8738 /* GraphicsChecksMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB680B825BA1BE4002B8738 /* GraphicsChecksMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
2370
		7BB680BA25BA1BE4002B8738 /* GraphicsChecksMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB680B825BA1BE4002B8738 /* GraphicsChecksMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
2371
		7BDDA31F274FA0210038659E /* GraphicsContextGLCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA31D274F9DA50038659E /* GraphicsContextGLCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
2371
		7BDDA31F274FA0210038659E /* GraphicsContextGLCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA31D274F9DA50038659E /* GraphicsContextGLCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
2372
		7BDDA3322750FCCD0038659E /* WebProcessGraphicsContextGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA3302750FCCC0038659E /* WebProcessGraphicsContextGL.h */; settings = {ATTRIBUTES = (Private, ); }; };
2372
		7BDDA3272750E0680038659E /* GraphicsContextGLANGLE.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA3252750E0670038659E /* GraphicsContextGLANGLE.h */; settings = {ATTRIBUTES = (Private, ); }; };
2373
		7BDDA32A2750EA0F0038659E /* WebProcessGraphicsContextGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA3282750EA0E0038659E /* WebProcessGraphicsContextGL.h */; settings = {ATTRIBUTES = (Private, ); }; };
2374
		7BDDA32B2750EA0F0038659E /* GraphicsContextGLState.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA3292750EA0E0038659E /* GraphicsContextGLState.h */; settings = {ATTRIBUTES = (Private, ); }; };
2373
		7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
2375
		7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
2374
		7C029C6E2493C8F800268204 /* ColorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C029C6D2493C8F800268204 /* ColorTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
2376
		7C029C6E2493C8F800268204 /* ColorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C029C6D2493C8F800268204 /* ColorTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
2375
		7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1843FC1C8B7283002EB973 /* Autofill.h */; settings = {ATTRIBUTES = (Private, ); }; };
2377
		7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1843FC1C8B7283002EB973 /* Autofill.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 11071-11078 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
11071
		7AF9B20918CFB5F200C64BEF /* JSVTTRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegion.h; sourceTree = "<group>"; };
11073
		7AF9B20918CFB5F200C64BEF /* JSVTTRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegion.h; sourceTree = "<group>"; };
11072
		7AF9B20A18CFB5F300C64BEF /* JSVTTRegionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVTTRegionList.cpp; sourceTree = "<group>"; };
11074
		7AF9B20A18CFB5F300C64BEF /* JSVTTRegionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVTTRegionList.cpp; sourceTree = "<group>"; };
11073
		7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegionList.h; sourceTree = "<group>"; };
11075
		7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegionList.h; sourceTree = "<group>"; };
11074
		7B10339A2549720000C8C1AC /* GraphicsContextGLCVANGLE.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLCVANGLE.cpp; sourceTree = "<group>"; };
11076
		7B10339A2549720000C8C1AC /* GraphicsContextGLCVCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLCVCocoa.cpp; sourceTree = "<group>"; };
11075
		7B10339C2549720100C8C1AC /* GraphicsContextGLCVANGLE.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCVANGLE.h; sourceTree = "<group>"; };
11077
		7B10339C2549720100C8C1AC /* GraphicsContextGLCVCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCVCocoa.h; sourceTree = "<group>"; };
11076
		7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCV.h; sourceTree = "<group>"; };
11078
		7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCV.h; sourceTree = "<group>"; };
11077
		7B1619102719880E00C40EAC /* WebProcessGraphicsContextGLCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessGraphicsContextGLCocoa.mm; sourceTree = "<group>"; };
11079
		7B1619102719880E00C40EAC /* WebProcessGraphicsContextGLCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessGraphicsContextGLCocoa.mm; sourceTree = "<group>"; };
11078
		7B6DC81525712E9100380C70 /* GraphicsContextGLIOSurfaceSwapChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLIOSurfaceSwapChain.cpp; sourceTree = "<group>"; };
11080
		7B6DC81525712E9100380C70 /* GraphicsContextGLIOSurfaceSwapChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLIOSurfaceSwapChain.cpp; sourceTree = "<group>"; };
Lines 11091-11097 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
11091
		7BCD42DC2705C94900EB2127 /* ANGLEUtilitiesCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ANGLEUtilitiesCocoa.h; sourceTree = "<group>"; };
11093
		7BCD42DC2705C94900EB2127 /* ANGLEUtilitiesCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ANGLEUtilitiesCocoa.h; sourceTree = "<group>"; };
11092
		7BDDA31C274F9DA40038659E /* GraphicsContextGLCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GraphicsContextGLCocoa.mm; sourceTree = "<group>"; };
11094
		7BDDA31C274F9DA40038659E /* GraphicsContextGLCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GraphicsContextGLCocoa.mm; sourceTree = "<group>"; };
11093
		7BDDA31D274F9DA50038659E /* GraphicsContextGLCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCocoa.h; sourceTree = "<group>"; };
11095
		7BDDA31D274F9DA50038659E /* GraphicsContextGLCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCocoa.h; sourceTree = "<group>"; };
11094
		7BDDA3302750FCCC0038659E /* WebProcessGraphicsContextGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebProcessGraphicsContextGL.h; path = platform/graphics/WebProcessGraphicsContextGL.h; sourceTree = SOURCE_ROOT; };
11096
		7BDDA3252750E0670038659E /* GraphicsContextGLANGLE.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLANGLE.h; sourceTree = "<group>"; };
11097
		7BDDA3282750EA0E0038659E /* WebProcessGraphicsContextGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessGraphicsContextGL.h; sourceTree = "<group>"; };
11098
		7BDDA3292750EA0E0038659E /* GraphicsContextGLState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLState.h; sourceTree = "<group>"; };
11095
		7BE7265B25763B8D00E85D98 /* RemoteGraphicsContextGLProxyBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxyBase.cpp; sourceTree = "<group>"; };
11099
		7BE7265B25763B8D00E85D98 /* RemoteGraphicsContextGLProxyBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxyBase.cpp; sourceTree = "<group>"; };
11096
		7C011F3D24FAD360005BEF10 /* Settings.cpp.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = Settings.cpp.erb; sourceTree = "<group>"; };
11100
		7C011F3D24FAD360005BEF10 /* Settings.cpp.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = Settings.cpp.erb; sourceTree = "<group>"; };
11097
		7C011F3E24FAD360005BEF10 /* InternalSettingsGenerated.cpp.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = InternalSettingsGenerated.cpp.erb; sourceTree = "<group>"; };
11101
		7C011F3E24FAD360005BEF10 /* InternalSettingsGenerated.cpp.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = InternalSettingsGenerated.cpp.erb; sourceTree = "<group>"; };
Lines 23511-23516 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
23511
				27E3C806257F5E6E00C986AB /* ANGLEHeaders.h */,
23515
				27E3C806257F5E6E00C986AB /* ANGLEHeaders.h */,
23512
				7BCD42D8270599EF00EB2127 /* ANGLEUtilities.cpp */,
23516
				7BCD42D8270599EF00EB2127 /* ANGLEUtilities.cpp */,
23513
				7BB34A1625345CB200029D08 /* ANGLEUtilities.h */,
23517
				7BB34A1625345CB200029D08 /* ANGLEUtilities.h */,
23518
				7BDDA3252750E0670038659E /* GraphicsContextGLANGLE.h */,
23514
				6E27F243229C9F8400F1F632 /* ExtensionsGLANGLE.cpp */,
23519
				6E27F243229C9F8400F1F632 /* ExtensionsGLANGLE.cpp */,
23515
				6E27F244229C9F8D00F1F632 /* ExtensionsGLANGLE.h */,
23520
				6E27F244229C9F8D00F1F632 /* ExtensionsGLANGLE.h */,
23516
				6E27F2422298CE4B00F1F632 /* GraphicsContextGLANGLE.cpp */,
23521
				6E27F2422298CE4B00F1F632 /* GraphicsContextGLANGLE.cpp */,
Lines 27892-27897 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
27892
		B2A015910AF6CD53006BCE0E /* graphics */ = {
27897
		B2A015910AF6CD53006BCE0E /* graphics */ = {
27893
			isa = PBXGroup;
27898
			isa = PBXGroup;
27894
			children = (
27899
			children = (
27900
				7BDDA3292750EA0E0038659E /* GraphicsContextGLState.h */,
27901
				7BDDA3282750EA0E0038659E /* WebProcessGraphicsContextGL.h */,
27895
				6E27F2412298CE2E00F1F632 /* angle */,
27902
				6E27F2412298CE2E00F1F632 /* angle */,
27896
				076F0D0812B8192700C26AA4 /* avfoundation */,
27903
				076F0D0812B8192700C26AA4 /* avfoundation */,
27897
				499B3EC0128CCC1800E726C2 /* ca */,
27904
				499B3EC0128CCC1800E726C2 /* ca */,
Lines 29460-29467 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec7
29460
				7B8ED5ED26F0C123008AC023 /* CVUtilities.h */,
29467
				7B8ED5ED26F0C123008AC023 /* CVUtilities.h */,
29461
				7B8ED5EF26F0C123008AC023 /* CVUtilities.mm */,
29468
				7B8ED5EF26F0C123008AC023 /* CVUtilities.mm */,
29462
				7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */,
29469
				7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */,
29463
				7B10339A2549720000C8C1AC /* GraphicsContextGLCVANGLE.cpp */,
29470
				7B10339A2549720000C8C1AC /* GraphicsContextGLCVCocoa.cpp */,
29464
				7B10339C2549720100C8C1AC /* GraphicsContextGLCVANGLE.h */,
29471
				7B10339C2549720100C8C1AC /* GraphicsContextGLCVCocoa.h */,
29465
				CD27AE4E22A9868700947FF9 /* ImageRotationSessionVT.h */,
29472
				CD27AE4E22A9868700947FF9 /* ImageRotationSessionVT.h */,
29466
				CD27AE4F22A9868700947FF9 /* ImageRotationSessionVT.mm */,
29473
				CD27AE4F22A9868700947FF9 /* ImageRotationSessionVT.mm */,
29467
				0746D30C2146EA38003DDF84 /* ImageTransferSessionVT.h */,
29474
				0746D30C2146EA38003DDF84 /* ImageTransferSessionVT.h */,
Lines 32701-32706 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec8
32701
				2EDEF1F5121B0EFC00726DB2 /* BlobRegistry.h in Headers */,
32708
				2EDEF1F5121B0EFC00726DB2 /* BlobRegistry.h in Headers */,
32702
				2EDEF1F7121B0EFC00726DB2 /* BlobRegistryImpl.h in Headers */,
32709
				2EDEF1F7121B0EFC00726DB2 /* BlobRegistryImpl.h in Headers */,
32703
				2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */,
32710
				2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */,
32711
				7BDDA32A2750EA0F0038659E /* WebProcessGraphicsContextGL.h in Headers */,
32704
				976D6C7F122B8A3D001FD1F7 /* BlobURL.h in Headers */,
32712
				976D6C7F122B8A3D001FD1F7 /* BlobURL.h in Headers */,
32705
				115CFA6E208AFAB7001E6991 /* BlockFormattingContext.h in Headers */,
32713
				115CFA6E208AFAB7001E6991 /* BlockFormattingContext.h in Headers */,
32706
				4786356526507A3800C5E2E0 /* BlockFormattingGeometry.h in Headers */,
32714
				4786356526507A3800C5E2E0 /* BlockFormattingGeometry.h in Headers */,
Lines 32879-32884 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec9
32879
				26E944D91AC4B2DD007B85B5 /* CombinedURLFilters.h in Headers */,
32887
				26E944D91AC4B2DD007B85B5 /* CombinedURLFilters.h in Headers */,
32880
				A584FE351864D5AF00843B10 /* CommandLineAPIHost.h in Headers */,
32888
				A584FE351864D5AF00843B10 /* CommandLineAPIHost.h in Headers */,
32881
				A584FE2C1863870F00843B10 /* CommandLineAPIModule.h in Headers */,
32889
				A584FE2C1863870F00843B10 /* CommandLineAPIModule.h in Headers */,
32890
				7BDDA3272750E0680038659E /* GraphicsContextGLANGLE.h in Headers */,
32882
				A584FE2618637DAB00843B10 /* CommandLineAPIModuleSource.h in Headers */,
32891
				A584FE2618637DAB00843B10 /* CommandLineAPIModuleSource.h in Headers */,
32883
				6550B6A2099DF0270090D781 /* Comment.h in Headers */,
32892
				6550B6A2099DF0270090D781 /* Comment.h in Headers */,
32884
				57E664FC1E73703300765536 /* CommonCryptoDERUtilities.h in Headers */,
32893
				57E664FC1E73703300765536 /* CommonCryptoDERUtilities.h in Headers */,
Lines 33709-33715 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec10
33709
				7C330A021DF8FAC600D3395C /* GraphicsContextGLAttributes.h in Headers */,
33718
				7C330A021DF8FAC600D3395C /* GraphicsContextGLAttributes.h in Headers */,
33710
				7BDDA31F274FA0210038659E /* GraphicsContextGLCocoa.h in Headers */,
33719
				7BDDA31F274FA0210038659E /* GraphicsContextGLCocoa.h in Headers */,
33711
				7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */,
33720
				7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */,
33712
				7B10339F2549721E00C8C1AC /* GraphicsContextGLCVANGLE.h in Headers */,
33721
				7B10339F2549721E00C8C1AC /* GraphicsContextGLCVCocoa.h in Headers */,
33713
				7BB34A48253776CA00029D08 /* GraphicsContextGLImageExtractor.h in Headers */,
33722
				7BB34A48253776CA00029D08 /* GraphicsContextGLImageExtractor.h in Headers */,
33714
				7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */,
33723
				7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */,
33715
				49C7B9FC1042D3650009D447 /* GraphicsContextGLOpenGL.h in Headers */,
33724
				49C7B9FC1042D3650009D447 /* GraphicsContextGLOpenGL.h in Headers */,
Lines 37044-37049 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec11
37044
				E1EE8B962413195000E794D6 /* WebXRViewport.h in Headers */,
37053
				E1EE8B962413195000E794D6 /* WebXRViewport.h in Headers */,
37045
				F55B3DE01251F12D003EF269 /* WeekInputType.h in Headers */,
37054
				F55B3DE01251F12D003EF269 /* WeekInputType.h in Headers */,
37046
				85031B510A44EFC700F992E0 /* WheelEvent.h in Headers */,
37055
				85031B510A44EFC700F992E0 /* WheelEvent.h in Headers */,
37056
				7BDDA32B2750EA0F0038659E /* GraphicsContextGLState.h in Headers */,
37047
				2EBBC3D81B65988300F5253D /* WheelEventDeltaFilter.h in Headers */,
37057
				2EBBC3D81B65988300F5253D /* WheelEventDeltaFilter.h in Headers */,
37048
				2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */,
37058
				2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */,
37049
				7AE335F21ACB09E200E401EF /* WheelEventTestMonitor.h in Headers */,
37059
				7AE335F21ACB09E200E401EF /* WheelEventTestMonitor.h in Headers */,
- a/Source/WebCore/platform/graphics/GraphicsContextGL.cpp -10 lines
Lines 351-366 GraphicsContextGL::Client::Client() = default; a/Source/WebCore/platform/graphics/GraphicsContextGL.cpp_sec1
351
351
352
GraphicsContextGL::Client::~Client() = default;
352
GraphicsContextGL::Client::~Client() = default;
353
353
354
RefPtr<GraphicsContextGL> GraphicsContextGL::create(const GraphicsContextGLAttributes& attributes, HostWindow* hostWindow)
355
{
356
    RefPtr<GraphicsContextGL> result;
357
    if (hostWindow)
358
        result = hostWindow->createGraphicsContextGL(attributes);
359
    if (!result)
360
        result = GraphicsContextGLOpenGL::create(attributes, hostWindow);
361
    return result;
362
}
363
364
GraphicsContextGL::GraphicsContextGL(GraphicsContextGLAttributes attrs)
354
GraphicsContextGL::GraphicsContextGL(GraphicsContextGLAttributes attrs)
365
    : m_attrs(attrs)
355
    : m_attrs(attrs)
366
{
356
{
- a/Source/WebCore/platform/graphics/GraphicsContextGL.h -4 / +1 lines
Lines 911-920 public: a/Source/WebCore/platform/graphics/GraphicsContextGL.h_sec1
911
        GCGLint size;
911
        GCGLint size;
912
    };
912
    };
913
913
914
    // Creates a GraphicsContextGL instance to render into offscreen destination in context of HostWindow.
915
    // HostWindow might affect the decision which backend is to be used.
916
    WEBCORE_EXPORT static RefPtr<GraphicsContextGL> create(const GraphicsContextGLAttributes&, HostWindow*);
917
918
    WEBCORE_EXPORT GraphicsContextGL(GraphicsContextGLAttributes);
914
    WEBCORE_EXPORT GraphicsContextGL(GraphicsContextGLAttributes);
919
    WEBCORE_EXPORT virtual ~GraphicsContextGL();
915
    WEBCORE_EXPORT virtual ~GraphicsContextGL();
920
916
Lines 1355-1360 public: a/Source/WebCore/platform/graphics/GraphicsContextGL.h_sec2
1355
    // Returns true upon success.
1351
    // Returns true upon success.
1356
    static bool packImageData(Image*, const void* pixels, GCGLenum format, GCGLenum type, bool flipY, AlphaOp, DataFormat sourceFormat, unsigned sourceImageWidth, unsigned sourceImageHeight, const IntRect& sourceImageSubRectangle, int depth, unsigned sourceUnpackAlignment, int unpackImageHeight, Vector<uint8_t>& data);
1352
    static bool packImageData(Image*, const void* pixels, GCGLenum format, GCGLenum type, bool flipY, AlphaOp, DataFormat sourceFormat, unsigned sourceImageWidth, unsigned sourceImageHeight, const IntRect& sourceImageSubRectangle, int depth, unsigned sourceUnpackAlignment, int unpackImageHeight, Vector<uint8_t>& data);
1357
1353
1354
    WEBCORE_EXPORT static void paintToCanvas(const GraphicsContextGLAttributes&, PixelBuffer&&, const IntSize& canvasSize, GraphicsContext&);
1358
protected:
1355
protected:
1359
    int m_currentWidth { 0 };
1356
    int m_currentWidth { 0 };
1360
    int m_currentHeight { 0 };
1357
    int m_currentHeight { 0 };
- a/Source/WebCore/platform/graphics/GraphicsContextGLState.h +79 lines
Line 0 a/Source/WebCore/platform/graphics/GraphicsContextGLState.h_sec1
1
/*
2
 * Copyright (C) 2009, 2014-2019 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEBGL)
29
30
#include "GraphicsContextGL.h"
31
#include "GraphicsContextGLState.h"
32
#include <wtf/HashCountedSet.h>
33
#include <wtf/HashMap.h>
34
#include <wtf/HashTraits.h>
35
36
namespace WebCore {
37
38
struct GraphicsContextGLState {
39
    GCGLuint boundReadFBO { 0 };
40
    GCGLuint boundDrawFBO { 0 };
41
    GCGLenum activeTextureUnit { GraphicsContextGL::TEXTURE0 };
42
43
    using BoundTextureMap = HashMap<GCGLenum,
44
        std::pair<GCGLuint, GCGLenum>,
45
        IntHash<GCGLenum>,
46
        WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>,
47
        PairHashTraits<WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>, WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>>
48
    >;
49
    BoundTextureMap boundTextureMap;
50
    GCGLuint currentBoundTexture() const { return boundTexture(activeTextureUnit); }
51
    GCGLuint boundTexture(GCGLenum textureUnit) const
52
    {
53
        auto iterator = boundTextureMap.find(textureUnit);
54
        if (iterator != boundTextureMap.end())
55
            return iterator->value.first;
56
        return 0;
57
    }
58
59
    GCGLuint currentBoundTarget() const { return boundTarget(activeTextureUnit); }
60
    GCGLenum boundTarget(GCGLenum textureUnit) const
61
    {
62
        auto iterator = boundTextureMap.find(textureUnit);
63
        if (iterator != boundTextureMap.end())
64
            return iterator->value.second;
65
        return 0;
66
    }
67
68
    void setBoundTexture(GCGLenum textureUnit, GCGLuint texture, GCGLenum target)
69
    {
70
        boundTextureMap.set(textureUnit, std::make_pair(texture, target));
71
    }
72
73
    using TextureSeedCount = HashCountedSet<GCGLuint, IntHash<GCGLuint>, WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>>;
74
    TextureSeedCount textureSeedCount;
75
};
76
77
}
78
79
#endif
- a/Source/WebCore/platform/graphics/angle/ExtensionsGLANGLE.cpp -2 / +2 lines
Lines 29-39 a/Source/WebCore/platform/graphics/angle/ExtensionsGLANGLE.cpp_sec1
29
#include "ExtensionsGLANGLE.h"
29
#include "ExtensionsGLANGLE.h"
30
30
31
#include "ANGLEHeaders.h"
31
#include "ANGLEHeaders.h"
32
#include "GraphicsContextGLOpenGL.h"
32
#include "GraphicsContextGLANGLE.h"
33
33
34
namespace WebCore {
34
namespace WebCore {
35
35
36
ExtensionsGLANGLE::ExtensionsGLANGLE(GraphicsContextGLOpenGL* context)
36
ExtensionsGLANGLE::ExtensionsGLANGLE(GraphicsContextGLANGLE* context)
37
    : m_initializedAvailableExtensions(false)
37
    : m_initializedAvailableExtensions(false)
38
    , m_context(context)
38
    , m_context(context)
39
{
39
{
- a/Source/WebCore/platform/graphics/angle/ExtensionsGLANGLE.h -5 / +5 lines
Lines 32-44 a/Source/WebCore/platform/graphics/angle/ExtensionsGLANGLE.h_sec1
32
32
33
namespace WebCore {
33
namespace WebCore {
34
34
35
class GraphicsContextGLOpenGL;
35
class GraphicsContextGLANGLE;
36
36
37
class ExtensionsGLANGLE : public ExtensionsGL {
37
class ExtensionsGLANGLE : public ExtensionsGL {
38
    WTF_MAKE_FAST_ALLOCATED;
38
    WTF_MAKE_FAST_ALLOCATED;
39
public:
39
public:
40
    // This class only needs to be instantiated by GraphicsContextGLOpenGL implementations.
40
    // This class only needs to be instantiated by GraphicsContextGLANGLE implementations.
41
    explicit ExtensionsGLANGLE(GraphicsContextGLOpenGL*);
41
    explicit ExtensionsGLANGLE(GraphicsContextGLANGLE*);
42
    virtual ~ExtensionsGLANGLE();
42
    virtual ~ExtensionsGLANGLE();
43
43
44
    // ExtensionsGL methods.
44
    // ExtensionsGL methods.
Lines 64-71 private: a/Source/WebCore/platform/graphics/angle/ExtensionsGLANGLE.h_sec2
64
    HashSet<String> m_requestableExtensions;
64
    HashSet<String> m_requestableExtensions;
65
    HashSet<String> m_enabledExtensions;
65
    HashSet<String> m_enabledExtensions;
66
66
67
    // Weak pointer back to GraphicsContextGLOpenGL.
67
    // Weak pointer back to GraphicsContextGLANGLE.
68
    GraphicsContextGLOpenGL* m_context;
68
    GraphicsContextGLANGLE* m_context;
69
69
70
    // Whether the WebGL 1.0-related floating-point renderability extensions have been enabled.
70
    // Whether the WebGL 1.0-related floating-point renderability extensions have been enabled.
71
    bool m_webglColorBufferFloatRGB { false };
71
    bool m_webglColorBufferFloatRGB { false };
- a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp -280 / +356 lines
Lines 27-38 a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec1
27
#include "config.h"
27
#include "config.h"
28
28
29
#if ENABLE(WEBGL) && USE(ANGLE)
29
#if ENABLE(WEBGL) && USE(ANGLE)
30
#include "GraphicsContextGL.h"
30
#include "GraphicsContextGLANGLE.h"
31
31
32
#include "ANGLEHeaders.h"
32
#include "ANGLEHeaders.h"
33
#include "ANGLEUtilities.h"
33
#include "ANGLEUtilities.h"
34
#include "ExtensionsGLANGLE.h"
34
#include "ExtensionsGLANGLE.h"
35
#include "GraphicsContextGLOpenGL.h"
35
#include "GraphicsContextGLOpenGLManager.h"
36
#include "ImageBuffer.h"
36
#include "ImageBuffer.h"
37
#include "IntRect.h"
37
#include "IntRect.h"
38
#include "IntSize.h"
38
#include "IntSize.h"
Lines 40-58 a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec2
40
#include "NotImplemented.h"
40
#include "NotImplemented.h"
41
#include "PixelBuffer.h"
41
#include "PixelBuffer.h"
42
#include "TemporaryANGLESetting.h"
42
#include "TemporaryANGLESetting.h"
43
#include <JavaScriptCore/RegularExpression.h>
44
#include <JavaScriptCore/Uint8ClampedArray.h>
45
#include <algorithm>
43
#include <algorithm>
46
#include <cstring>
44
#include <cstring>
47
#include <wtf/HexNumber.h>
48
#include <wtf/Seconds.h>
45
#include <wtf/Seconds.h>
49
#include <wtf/ThreadSpecific.h>
50
#include <wtf/text/CString.h>
46
#include <wtf/text/CString.h>
51
#include <wtf/text/StringBuilder.h>
47
#include <wtf/text/StringBuilder.h>
52
48
53
54
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
49
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
55
#include "GraphicsContextGLCVANGLE.h"
50
#include "GraphicsContextGLCVCocoa.h"
56
#endif
51
#endif
57
52
58
// This one definition short-circuits the need for gl2ext.h, which
53
// This one definition short-circuits the need for gl2ext.h, which
Lines 76-83 static void wipeAlphaChannelFromPixels(int width, int height, unsigned char* pix a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec3
76
}
71
}
77
#endif
72
#endif
78
73
79
74
GCGLenum GraphicsContextGLANGLE::drawingBufferTextureTarget()
80
GCGLenum GraphicsContextGLOpenGL::drawingBufferTextureTarget()
81
{
75
{
82
    if (m_drawingBufferTextureTarget == -1)
76
    if (m_drawingBufferTextureTarget == -1)
83
        EGL_GetConfigAttrib(platformDisplay(), platformConfig(), EGL_BIND_TO_TEXTURE_TARGET_ANGLE, &m_drawingBufferTextureTarget);
77
        EGL_GetConfigAttrib(platformDisplay(), platformConfig(), EGL_BIND_TO_TEXTURE_TARGET_ANGLE, &m_drawingBufferTextureTarget);
Lines 93-99 GCGLenum GraphicsContextGLOpenGL::drawingBufferTextureTarget() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec4
93
    return 0;
87
    return 0;
94
}
88
}
95
89
96
GCGLenum GraphicsContextGLOpenGL::drawingBufferTextureTargetQueryForDrawingTarget(GCGLenum drawingTarget)
90
GCGLenum GraphicsContextGLANGLE::drawingBufferTextureTargetQueryForDrawingTarget(GCGLenum drawingTarget)
97
{
91
{
98
    switch (drawingTarget) {
92
    switch (drawingTarget) {
99
    case TEXTURE_2D:
93
    case TEXTURE_2D:
Lines 105-111 GCGLenum GraphicsContextGLOpenGL::drawingBufferTextureTargetQueryForDrawingTarge a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec5
105
    return -1;
99
    return -1;
106
}
100
}
107
101
108
GCGLint GraphicsContextGLOpenGL::EGLDrawingBufferTextureTargetForDrawingTarget(GCGLenum drawingTarget)
102
GCGLint GraphicsContextGLANGLE::EGLDrawingBufferTextureTargetForDrawingTarget(GCGLenum drawingTarget)
109
{
103
{
110
    switch (drawingTarget) {
104
    switch (drawingTarget) {
111
    case TEXTURE_2D:
105
    case TEXTURE_2D:
Lines 117-123 GCGLint GraphicsContextGLOpenGL::EGLDrawingBufferTextureTargetForDrawingTarget(G a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec6
117
    return 0;
111
    return 0;
118
}
112
}
119
113
120
bool GraphicsContextGLOpenGL::releaseThreadResources(ReleaseThreadResourceBehavior releaseBehavior)
114
bool GraphicsContextGLANGLE::releaseThreadResources(ReleaseThreadResourceBehavior releaseBehavior)
121
{
115
{
122
    platformReleaseThreadResources();
116
    platformReleaseThreadResources();
123
117
Lines 161-167 bool GraphicsContextGLOpenGL::releaseThreadResources(ReleaseThreadResourceBehavi a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec7
161
    return EGL_ReleaseThread();
155
    return EGL_ReleaseThread();
162
}
156
}
163
157
164
std::optional<PixelBuffer> GraphicsContextGLOpenGL::readPixelsForPaintResults()
158
std::optional<PixelBuffer> GraphicsContextGLANGLE::readPixelsForPaintResults()
165
{
159
{
166
    PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB() };
160
    PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB() };
167
    auto pixelBuffer = PixelBuffer::tryCreate(format, getInternalFramebufferSize());
161
    auto pixelBuffer = PixelBuffer::tryCreate(format, getInternalFramebufferSize());
Lines 187-200 std::optional<PixelBuffer> GraphicsContextGLOpenGL::readPixelsForPaintResults() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec8
187
    return pixelBuffer;
181
    return pixelBuffer;
188
}
182
}
189
183
190
void GraphicsContextGLOpenGL::validateAttributes()
184
void GraphicsContextGLANGLE::validateAttributes()
191
{
185
{
192
    m_internalColorFormat = contextAttributes().alpha ? GL_RGBA8 : GL_RGB8;
186
    m_internalColorFormat = contextAttributes().alpha ? GL_RGBA8 : GL_RGB8;
193
187
194
    validateDepthStencil(packedDepthStencilExtensionName);
188
    validateDepthStencil(packedDepthStencilExtensionName);
195
}
189
}
196
190
197
bool GraphicsContextGLOpenGL::reshapeFBOs(const IntSize& size)
191
bool GraphicsContextGLANGLE::reshapeFBOs(const IntSize& size)
198
{
192
{
199
    auto attrs = contextAttributes();
193
    auto attrs = contextAttributes();
200
    const int width = size.width();
194
    const int width = size.width();
Lines 274-280 bool GraphicsContextGLOpenGL::reshapeFBOs(const IntSize& size) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec9
274
    return mustRestoreFBO;
268
    return mustRestoreFBO;
275
}
269
}
276
270
277
void GraphicsContextGLOpenGL::attachDepthAndStencilBufferIfNeeded(GLuint internalDepthStencilFormat, int width, int height)
271
void GraphicsContextGLANGLE::attachDepthAndStencilBufferIfNeeded(GLuint internalDepthStencilFormat, int width, int height)
278
{
272
{
279
    auto attrs = contextAttributes();
273
    auto attrs = contextAttributes();
280
274
Lines 300-306 void GraphicsContextGLOpenGL::attachDepthAndStencilBufferIfNeeded(GLuint interna a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec10
300
    }
294
    }
301
}
295
}
302
296
303
void GraphicsContextGLOpenGL::resolveMultisamplingIfNecessary(const IntRect& rect)
297
void GraphicsContextGLANGLE::resolveMultisamplingIfNecessary(const IntRect& rect)
304
{
298
{
305
    TemporaryANGLESetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
299
    TemporaryANGLESetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
306
    TemporaryANGLESetting scopedDither(GL_DITHER, GL_FALSE);
300
    TemporaryANGLESetting scopedDither(GL_DITHER, GL_FALSE);
Lines 331-337 void GraphicsContextGLOpenGL::resolveMultisamplingIfNecessary(const IntRect& rec a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec11
331
        gl::BindFramebuffer(GL_FRAMEBUFFER, boundFrameBuffer);
325
        gl::BindFramebuffer(GL_FRAMEBUFFER, boundFrameBuffer);
332
}
326
}
333
327
334
void GraphicsContextGLOpenGL::renderbufferStorage(GCGLenum target, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
328
void GraphicsContextGLANGLE::renderbufferStorage(GCGLenum target, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
335
{
329
{
336
    if (!makeContextCurrent())
330
    if (!makeContextCurrent())
337
        return;
331
        return;
Lines 339-352 void GraphicsContextGLOpenGL::renderbufferStorage(GCGLenum target, GCGLenum inte a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec12
339
    gl::RenderbufferStorage(target, internalformat, width, height);
333
    gl::RenderbufferStorage(target, internalformat, width, height);
340
}
334
}
341
335
342
void GraphicsContextGLOpenGL::getIntegerv(GCGLenum pname, GCGLSpan<GCGLint> value)
336
void GraphicsContextGLANGLE::getIntegerv(GCGLenum pname, GCGLSpan<GCGLint> value)
343
{
337
{
344
    if (!makeContextCurrent())
338
    if (!makeContextCurrent())
345
        return;
339
        return;
346
    gl::GetIntegervRobustANGLE(pname, value.bufSize, nullptr, value.data);
340
    gl::GetIntegervRobustANGLE(pname, value.bufSize, nullptr, value.data);
347
}
341
}
348
342
349
void GraphicsContextGLOpenGL::getShaderPrecisionFormat(GCGLenum shaderType, GCGLenum precisionType, GCGLSpan<GCGLint, 2> range, GCGLint* precision)
343
void GraphicsContextGLANGLE::getShaderPrecisionFormat(GCGLenum shaderType, GCGLenum precisionType, GCGLSpan<GCGLint, 2> range, GCGLint* precision)
350
{
344
{
351
    if (!makeContextCurrent())
345
    if (!makeContextCurrent())
352
        return;
346
        return;
Lines 354-360 void GraphicsContextGLOpenGL::getShaderPrecisionFormat(GCGLenum shaderType, GCGL a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec13
354
    gl::GetShaderPrecisionFormat(shaderType, precisionType, range.data, precision);
348
    gl::GetShaderPrecisionFormat(shaderType, precisionType, range.data, precision);
355
}
349
}
356
350
357
void GraphicsContextGLOpenGL::texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
351
void GraphicsContextGLANGLE::texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
358
{
352
{
359
    if (!m_isForWebGL2)
353
    if (!m_isForWebGL2)
360
        internalformat = static_cast<ExtensionsGLANGLE&>(getExtensions()).adjustWebGL1TextureInternalFormat(internalformat, format, type);
354
        internalformat = static_cast<ExtensionsGLANGLE&>(getExtensions()).adjustWebGL1TextureInternalFormat(internalformat, format, type);
Lines 364-375 void GraphicsContextGLOpenGL::texImage2D(GCGLenum target, GCGLint level, GCGLenu a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec14
364
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
358
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
365
    }
359
    }
366
360
367
void GraphicsContextGLOpenGL::texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLintptr offset)
361
void GraphicsContextGLANGLE::texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLintptr offset)
368
{
362
{
369
    texImage2D(target, level, internalformat, width, height, border, format, type, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
363
    texImage2D(target, level, internalformat, width, height, border, format, type, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
370
}
364
}
371
365
372
void GraphicsContextGLOpenGL::texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoff, GCGLint yoff, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
366
void GraphicsContextGLANGLE::texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoff, GCGLint yoff, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
373
{
367
{
374
    if (!makeContextCurrent())
368
    if (!makeContextCurrent())
375
        return;
369
        return;
Lines 379-390 void GraphicsContextGLOpenGL::texSubImage2D(GCGLenum target, GCGLint level, GCGL a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec15
379
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
373
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
380
}
374
}
381
375
382
void GraphicsContextGLOpenGL::texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoff, GCGLint yoff, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset)
376
void GraphicsContextGLANGLE::texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoff, GCGLint yoff, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset)
383
{
377
{
384
    texSubImage2D(target, level, xoff, yoff, width, height, format, type, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
378
    texSubImage2D(target, level, xoff, yoff, width, height, format, type, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
385
}
379
}
386
380
387
void GraphicsContextGLOpenGL::compressedTexImage2D(GCGLenum target, int level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, int border, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
381
void GraphicsContextGLANGLE::compressedTexImage2D(GCGLenum target, int level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, int border, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
388
{
382
{
389
    if (!makeContextCurrent())
383
    if (!makeContextCurrent())
390
        return;
384
        return;
Lines 393-404 void GraphicsContextGLOpenGL::compressedTexImage2D(GCGLenum target, int level, G a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec16
393
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
387
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
394
}
388
}
395
389
396
void GraphicsContextGLOpenGL::compressedTexImage2D(GCGLenum target, int level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, int border, GCGLsizei imageSize, GCGLintptr offset)
390
void GraphicsContextGLANGLE::compressedTexImage2D(GCGLenum target, int level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, int border, GCGLsizei imageSize, GCGLintptr offset)
397
{
391
{
398
    compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
392
    compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
399
}
393
}
400
394
401
void GraphicsContextGLOpenGL::compressedTexSubImage2D(GCGLenum target, int level, int xoffset, int yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
395
void GraphicsContextGLANGLE::compressedTexSubImage2D(GCGLenum target, int level, int xoffset, int yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
402
{
396
{
403
    if (!makeContextCurrent())
397
    if (!makeContextCurrent())
404
        return;
398
        return;
Lines 407-418 void GraphicsContextGLOpenGL::compressedTexSubImage2D(GCGLenum target, int level a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec17
407
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
401
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
408
}
402
}
409
403
410
void GraphicsContextGLOpenGL::compressedTexSubImage2D(GCGLenum target, int level, int xoffset, int yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLintptr offset)
404
void GraphicsContextGLANGLE::compressedTexSubImage2D(GCGLenum target, int level, int xoffset, int yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLintptr offset)
411
{
405
{
412
    compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
406
    compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
413
}
407
}
414
408
415
void GraphicsContextGLOpenGL::depthRange(GCGLclampf zNear, GCGLclampf zFar)
409
void GraphicsContextGLANGLE::depthRange(GCGLclampf zNear, GCGLclampf zFar)
416
{
410
{
417
    if (!makeContextCurrent())
411
    if (!makeContextCurrent())
418
        return;
412
        return;
Lines 420-426 void GraphicsContextGLOpenGL::depthRange(GCGLclampf zNear, GCGLclampf zFar) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec18
420
    gl::DepthRangef(static_cast<float>(zNear), static_cast<float>(zFar));
414
    gl::DepthRangef(static_cast<float>(zNear), static_cast<float>(zFar));
421
}
415
}
422
416
423
void GraphicsContextGLOpenGL::clearDepth(GCGLclampf depth)
417
void GraphicsContextGLANGLE::clearDepth(GCGLclampf depth)
424
{
418
{
425
    if (!makeContextCurrent())
419
    if (!makeContextCurrent())
426
        return;
420
        return;
Lines 428-451 void GraphicsContextGLOpenGL::clearDepth(GCGLclampf depth) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec19
428
    gl::ClearDepthf(static_cast<float>(depth));
422
    gl::ClearDepthf(static_cast<float>(depth));
429
}
423
}
430
424
431
ExtensionsGL& GraphicsContextGLOpenGL::getExtensions()
425
ExtensionsGL& GraphicsContextGLANGLE::getExtensions()
432
{
426
{
433
    if (!m_extensions)
427
    if (!m_extensions)
434
        m_extensions = makeUnique<ExtensionsGLANGLE>(this);
428
        m_extensions = makeUnique<ExtensionsGLANGLE>(this);
435
    return *m_extensions;
429
    return *m_extensions;
436
}
430
}
437
431
438
void GraphicsContextGLOpenGL::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<GCGLvoid> data)
432
void GraphicsContextGLANGLE::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<GCGLvoid> data)
439
{
433
{
440
    readnPixelsImpl(x, y, width, height, format, type, data.bufSize, nullptr, nullptr, nullptr, data.data, false);
434
    readnPixelsImpl(x, y, width, height, format, type, data.bufSize, nullptr, nullptr, nullptr, data.data, false);
441
}
435
}
442
436
443
void GraphicsContextGLOpenGL::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset)
437
void GraphicsContextGLANGLE::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset)
444
{
438
{
445
    readnPixelsImpl(x, y, width, height, format, type, 0, nullptr, nullptr, nullptr, reinterpret_cast<GCGLvoid*>(offset), true);
439
    readnPixelsImpl(x, y, width, height, format, type, 0, nullptr, nullptr, nullptr, reinterpret_cast<GCGLvoid*>(offset), true);
446
}
440
}
447
441
448
void GraphicsContextGLOpenGL::readnPixelsImpl(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, GCGLsizei* length, GCGLsizei* columns, GCGLsizei* rows, GCGLvoid* data, bool readingToPixelBufferObject)
442
void GraphicsContextGLANGLE::readnPixelsImpl(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, GCGLsizei* length, GCGLsizei* columns, GCGLsizei* rows, GCGLvoid* data, bool readingToPixelBufferObject)
449
{
443
{
450
    if (!makeContextCurrent())
444
    if (!makeContextCurrent())
451
        return;
445
        return;
Lines 482-490 void GraphicsContextGLOpenGL::readnPixelsImpl(GCGLint x, GCGLint y, GCGLsizei wi a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec20
482
#endif
476
#endif
483
}
477
}
484
478
485
// The contents of GraphicsContextGLOpenGLCommon follow, ported to use ANGLE.
479
// The contents of GraphicsContextGLANGLECommon follow, ported to use ANGLE.
486
480
487
void GraphicsContextGLOpenGL::validateDepthStencil(const char* packedDepthStencilExtension)
481
void GraphicsContextGLANGLE::validateDepthStencil(const char* packedDepthStencilExtension)
488
{
482
{
489
    ExtensionsGL& extensions = getExtensions();
483
    ExtensionsGL& extensions = getExtensions();
490
    // FIXME: Since the constructors of various platforms are not shared, we initialize this here.
484
    // FIXME: Since the constructors of various platforms are not shared, we initialize this here.
Lines 522-528 void GraphicsContextGLOpenGL::validateDepthStencil(const char* packedDepthStenci a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec21
522
    }
516
    }
523
}
517
}
524
518
525
void GraphicsContextGLOpenGL::prepareTexture()
519
void GraphicsContextGLANGLE::prepareTexture()
526
{
520
{
527
    if (m_layerComposited)
521
    if (m_layerComposited)
528
        return;
522
        return;
Lines 533-539 void GraphicsContextGLOpenGL::prepareTexture() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec22
533
    prepareTextureImpl();
527
    prepareTextureImpl();
534
}
528
}
535
529
536
void GraphicsContextGLOpenGL::prepareTextureImpl()
530
void GraphicsContextGLANGLE::prepareTextureImpl()
537
{
531
{
538
    ASSERT(!m_layerComposited);
532
    ASSERT(!m_layerComposited);
539
533
Lines 576-582 void GraphicsContextGLOpenGL::prepareTextureImpl() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec23
576
#endif
570
#endif
577
}
571
}
578
572
579
std::optional<PixelBuffer> GraphicsContextGLOpenGL::readRenderingResults()
573
std::optional<PixelBuffer> GraphicsContextGLANGLE::readRenderingResults()
580
{
574
{
581
    ScopedRestoreReadFramebufferBinding fboBinding(m_isForWebGL2, m_state.boundReadFBO);
575
    ScopedRestoreReadFramebufferBinding fboBinding(m_isForWebGL2, m_state.boundReadFBO);
582
    if (contextAttributes().antialias) {
576
    if (contextAttributes().antialias) {
Lines 587-593 std::optional<PixelBuffer> GraphicsContextGLOpenGL::readRenderingResults() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec24
587
    return readPixelsForPaintResults();
581
    return readPixelsForPaintResults();
588
}
582
}
589
583
590
void GraphicsContextGLOpenGL::reshape(int width, int height)
584
void GraphicsContextGLANGLE::reshape(int width, int height)
591
{
585
{
592
    if (width == m_currentWidth && height == m_currentHeight)
586
    if (width == m_currentWidth && height == m_currentHeight)
593
        return;
587
        return;
Lines 673-679 void GraphicsContextGLOpenGL::reshape(int width, int height) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec25
673
    gl::Flush();
667
    gl::Flush();
674
}
668
}
675
669
676
void GraphicsContextGLOpenGL::activeTexture(GCGLenum texture)
670
void GraphicsContextGLANGLE::activeTexture(GCGLenum texture)
677
{
671
{
678
    if (!makeContextCurrent())
672
    if (!makeContextCurrent())
679
        return;
673
        return;
Lines 682-688 void GraphicsContextGLOpenGL::activeTexture(GCGLenum texture) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec26
682
    gl::ActiveTexture(texture);
676
    gl::ActiveTexture(texture);
683
}
677
}
684
678
685
void GraphicsContextGLOpenGL::attachShader(PlatformGLObject program, PlatformGLObject shader)
679
void GraphicsContextGLANGLE::attachShader(PlatformGLObject program, PlatformGLObject shader)
686
{
680
{
687
    ASSERT(program);
681
    ASSERT(program);
688
    ASSERT(shader);
682
    ASSERT(shader);
Lines 692-698 void GraphicsContextGLOpenGL::attachShader(PlatformGLObject program, PlatformGLO a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec27
692
    gl::AttachShader(program, shader);
686
    gl::AttachShader(program, shader);
693
}
687
}
694
688
695
void GraphicsContextGLOpenGL::bindAttribLocation(PlatformGLObject program, GCGLuint index, const String& name)
689
void GraphicsContextGLANGLE::bindAttribLocation(PlatformGLObject program, GCGLuint index, const String& name)
696
{
690
{
697
    ASSERT(program);
691
    ASSERT(program);
698
    if (!makeContextCurrent())
692
    if (!makeContextCurrent())
Lines 701-707 void GraphicsContextGLOpenGL::bindAttribLocation(PlatformGLObject program, GCGLu a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec28
701
    gl::BindAttribLocation(program, index, name.utf8().data());
695
    gl::BindAttribLocation(program, index, name.utf8().data());
702
}
696
}
703
697
704
void GraphicsContextGLOpenGL::bindBuffer(GCGLenum target, PlatformGLObject buffer)
698
void GraphicsContextGLANGLE::bindBuffer(GCGLenum target, PlatformGLObject buffer)
705
{
699
{
706
    if (!makeContextCurrent())
700
    if (!makeContextCurrent())
707
        return;
701
        return;
Lines 709-715 void GraphicsContextGLOpenGL::bindBuffer(GCGLenum target, PlatformGLObject buffe a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec29
709
    gl::BindBuffer(target, buffer);
703
    gl::BindBuffer(target, buffer);
710
}
704
}
711
705
712
void GraphicsContextGLOpenGL::bindFramebuffer(GCGLenum target, PlatformGLObject buffer)
706
void GraphicsContextGLANGLE::bindFramebuffer(GCGLenum target, PlatformGLObject buffer)
713
{
707
{
714
    if (!makeContextCurrent())
708
    if (!makeContextCurrent())
715
        return;
709
        return;
Lines 730-736 void GraphicsContextGLOpenGL::bindFramebuffer(GCGLenum target, PlatformGLObject a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec30
730
    }
724
    }
731
}
725
}
732
726
733
void GraphicsContextGLOpenGL::bindRenderbuffer(GCGLenum target, PlatformGLObject renderbuffer)
727
void GraphicsContextGLANGLE::bindRenderbuffer(GCGLenum target, PlatformGLObject renderbuffer)
734
{
728
{
735
    if (!makeContextCurrent())
729
    if (!makeContextCurrent())
736
        return;
730
        return;
Lines 739-745 void GraphicsContextGLOpenGL::bindRenderbuffer(GCGLenum target, PlatformGLObject a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec31
739
}
733
}
740
734
741
735
742
void GraphicsContextGLOpenGL::bindTexture(GCGLenum target, PlatformGLObject texture)
736
void GraphicsContextGLANGLE::bindTexture(GCGLenum target, PlatformGLObject texture)
743
{
737
{
744
    if (!makeContextCurrent())
738
    if (!makeContextCurrent())
745
        return;
739
        return;
Lines 748-754 void GraphicsContextGLOpenGL::bindTexture(GCGLenum target, PlatformGLObject text a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec32
748
    gl::BindTexture(target, texture);
742
    gl::BindTexture(target, texture);
749
}
743
}
750
744
751
void GraphicsContextGLOpenGL::blendColor(GCGLclampf red, GCGLclampf green, GCGLclampf blue, GCGLclampf alpha)
745
void GraphicsContextGLANGLE::blendColor(GCGLclampf red, GCGLclampf green, GCGLclampf blue, GCGLclampf alpha)
752
{
746
{
753
    if (!makeContextCurrent())
747
    if (!makeContextCurrent())
754
        return;
748
        return;
Lines 756-762 void GraphicsContextGLOpenGL::blendColor(GCGLclampf red, GCGLclampf green, GCGLc a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec33
756
    gl::BlendColor(red, green, blue, alpha);
750
    gl::BlendColor(red, green, blue, alpha);
757
}
751
}
758
752
759
void GraphicsContextGLOpenGL::blendEquation(GCGLenum mode)
753
void GraphicsContextGLANGLE::blendEquation(GCGLenum mode)
760
{
754
{
761
    if (!makeContextCurrent())
755
    if (!makeContextCurrent())
762
        return;
756
        return;
Lines 764-770 void GraphicsContextGLOpenGL::blendEquation(GCGLenum mode) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec34
764
    gl::BlendEquation(mode);
758
    gl::BlendEquation(mode);
765
}
759
}
766
760
767
void GraphicsContextGLOpenGL::blendEquationSeparate(GCGLenum modeRGB, GCGLenum modeAlpha)
761
void GraphicsContextGLANGLE::blendEquationSeparate(GCGLenum modeRGB, GCGLenum modeAlpha)
768
{
762
{
769
    if (!makeContextCurrent())
763
    if (!makeContextCurrent())
770
        return;
764
        return;
Lines 773-779 void GraphicsContextGLOpenGL::blendEquationSeparate(GCGLenum modeRGB, GCGLenum m a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec35
773
}
767
}
774
768
775
769
776
void GraphicsContextGLOpenGL::blendFunc(GCGLenum sfactor, GCGLenum dfactor)
770
void GraphicsContextGLANGLE::blendFunc(GCGLenum sfactor, GCGLenum dfactor)
777
{
771
{
778
    if (!makeContextCurrent())
772
    if (!makeContextCurrent())
779
        return;
773
        return;
Lines 781-787 void GraphicsContextGLOpenGL::blendFunc(GCGLenum sfactor, GCGLenum dfactor) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec36
781
    gl::BlendFunc(sfactor, dfactor);
775
    gl::BlendFunc(sfactor, dfactor);
782
}
776
}
783
777
784
void GraphicsContextGLOpenGL::blendFuncSeparate(GCGLenum srcRGB, GCGLenum dstRGB, GCGLenum srcAlpha, GCGLenum dstAlpha)
778
void GraphicsContextGLANGLE::blendFuncSeparate(GCGLenum srcRGB, GCGLenum dstRGB, GCGLenum srcAlpha, GCGLenum dstAlpha)
785
{
779
{
786
    if (!makeContextCurrent())
780
    if (!makeContextCurrent())
787
        return;
781
        return;
Lines 789-795 void GraphicsContextGLOpenGL::blendFuncSeparate(GCGLenum srcRGB, GCGLenum dstRGB a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec37
789
    gl::BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
783
    gl::BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
790
}
784
}
791
785
792
void GraphicsContextGLOpenGL::bufferData(GCGLenum target, GCGLsizeiptr size, GCGLenum usage)
786
void GraphicsContextGLANGLE::bufferData(GCGLenum target, GCGLsizeiptr size, GCGLenum usage)
793
{
787
{
794
    if (!makeContextCurrent())
788
    if (!makeContextCurrent())
795
        return;
789
        return;
Lines 797-803 void GraphicsContextGLOpenGL::bufferData(GCGLenum target, GCGLsizeiptr size, GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec38
797
    gl::BufferData(target, size, 0, usage);
791
    gl::BufferData(target, size, 0, usage);
798
}
792
}
799
793
800
void GraphicsContextGLOpenGL::bufferData(GCGLenum target, GCGLSpan<const GCGLvoid> data, GCGLenum usage)
794
void GraphicsContextGLANGLE::bufferData(GCGLenum target, GCGLSpan<const GCGLvoid> data, GCGLenum usage)
801
{
795
{
802
    if (!makeContextCurrent())
796
    if (!makeContextCurrent())
803
        return;
797
        return;
Lines 805-811 void GraphicsContextGLOpenGL::bufferData(GCGLenum target, GCGLSpan<const GCGLvoi a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec39
805
    gl::BufferData(target, data.bufSize, data.data, usage);
799
    gl::BufferData(target, data.bufSize, data.data, usage);
806
}
800
}
807
801
808
void GraphicsContextGLOpenGL::bufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<const GCGLvoid> data)
802
void GraphicsContextGLANGLE::bufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<const GCGLvoid> data)
809
{
803
{
810
    if (!makeContextCurrent())
804
    if (!makeContextCurrent())
811
        return;
805
        return;
Lines 813-819 void GraphicsContextGLOpenGL::bufferSubData(GCGLenum target, GCGLintptr offset, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec40
813
    gl::BufferSubData(target, offset, data.bufSize, data.data);
807
    gl::BufferSubData(target, offset, data.bufSize, data.data);
814
}
808
}
815
809
816
void GraphicsContextGLOpenGL::getBufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<GCGLvoid> data)
810
void GraphicsContextGLANGLE::getBufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<GCGLvoid> data)
817
{
811
{
818
    if (!makeContextCurrent())
812
    if (!makeContextCurrent())
819
        return;
813
        return;
Lines 825-831 void GraphicsContextGLOpenGL::getBufferSubData(GCGLenum target, GCGLintptr offse a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec41
825
        synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
819
        synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
826
}
820
}
827
821
828
void GraphicsContextGLOpenGL::copyBufferSubData(GCGLenum readTarget, GCGLenum writeTarget, GCGLintptr readOffset, GCGLintptr writeOffset, GCGLsizeiptr size)
822
void GraphicsContextGLANGLE::copyBufferSubData(GCGLenum readTarget, GCGLenum writeTarget, GCGLintptr readOffset, GCGLintptr writeOffset, GCGLsizeiptr size)
829
{
823
{
830
    if (!makeContextCurrent())
824
    if (!makeContextCurrent())
831
        return;
825
        return;
Lines 833-846 void GraphicsContextGLOpenGL::copyBufferSubData(GCGLenum readTarget, GCGLenum wr a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec42
833
    gl::CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
827
    gl::CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
834
}
828
}
835
829
836
void GraphicsContextGLOpenGL::getInternalformativ(GCGLenum target, GCGLenum internalformat, GCGLenum pname, GCGLSpan<GCGLint> data)
830
void GraphicsContextGLANGLE::getInternalformativ(GCGLenum target, GCGLenum internalformat, GCGLenum pname, GCGLSpan<GCGLint> data)
837
{
831
{
838
    if (!makeContextCurrent())
832
    if (!makeContextCurrent())
839
        return;
833
        return;
840
    gl::GetInternalformativRobustANGLE(target, internalformat, pname, data.bufSize, nullptr, data.data);
834
    gl::GetInternalformativRobustANGLE(target, internalformat, pname, data.bufSize, nullptr, data.data);
841
}
835
}
842
836
843
void GraphicsContextGLOpenGL::renderbufferStorageMultisample(GCGLenum target, GCGLsizei samples, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
837
void GraphicsContextGLANGLE::renderbufferStorageMultisample(GCGLenum target, GCGLsizei samples, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
844
{
838
{
845
    if (!makeContextCurrent())
839
    if (!makeContextCurrent())
846
        return;
840
        return;
Lines 848-854 void GraphicsContextGLOpenGL::renderbufferStorageMultisample(GCGLenum target, GC a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec43
848
    gl::RenderbufferStorageMultisample(target, samples, internalformat, width, height);
842
    gl::RenderbufferStorageMultisample(target, samples, internalformat, width, height);
849
}
843
}
850
844
851
void GraphicsContextGLOpenGL::texStorage2D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
845
void GraphicsContextGLANGLE::texStorage2D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
852
{
846
{
853
    if (!makeContextCurrent())
847
    if (!makeContextCurrent())
854
        return;
848
        return;
Lines 857-863 void GraphicsContextGLOpenGL::texStorage2D(GCGLenum target, GCGLsizei levels, GC a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec44
857
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
851
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
858
}
852
}
859
853
860
void GraphicsContextGLOpenGL::texStorage3D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth)
854
void GraphicsContextGLANGLE::texStorage3D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth)
861
{
855
{
862
    if (!makeContextCurrent())
856
    if (!makeContextCurrent())
863
        return;
857
        return;
Lines 866-872 void GraphicsContextGLOpenGL::texStorage3D(GCGLenum target, GCGLsizei levels, GC a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec45
866
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
860
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
867
}
861
}
868
862
869
void GraphicsContextGLOpenGL::texImage3D(GCGLenum target, int level, int internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, int border, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
863
void GraphicsContextGLANGLE::texImage3D(GCGLenum target, int level, int internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, int border, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
870
{
864
{
871
    if (!makeContextCurrent())
865
    if (!makeContextCurrent())
872
        return;
866
        return;
Lines 874-885 void GraphicsContextGLOpenGL::texImage3D(GCGLenum target, int level, int interna a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec46
874
    gl::TexImage3DRobustANGLE(target, level, internalformat, width, height, depth, border, format, type, pixels.bufSize, pixels.data);
868
    gl::TexImage3DRobustANGLE(target, level, internalformat, width, height, depth, border, format, type, pixels.bufSize, pixels.data);
875
}
869
}
876
870
877
void GraphicsContextGLOpenGL::texImage3D(GCGLenum target, int level, int internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, int border, GCGLenum format, GCGLenum type, GCGLintptr offset)
871
void GraphicsContextGLANGLE::texImage3D(GCGLenum target, int level, int internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, int border, GCGLenum format, GCGLenum type, GCGLintptr offset)
878
{
872
{
879
    texImage3D(target, level, internalformat, width, height, depth, border, format, type, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
873
    texImage3D(target, level, internalformat, width, height, depth, border, format, type, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
880
}
874
}
881
875
882
void GraphicsContextGLOpenGL::texSubImage3D(GCGLenum target, int level, int xoffset, int yoffset, int zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
876
void GraphicsContextGLANGLE::texSubImage3D(GCGLenum target, int level, int xoffset, int yoffset, int zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
883
{
877
{
884
    if (!makeContextCurrent())
878
    if (!makeContextCurrent())
885
        return;
879
        return;
Lines 887-898 void GraphicsContextGLOpenGL::texSubImage3D(GCGLenum target, int level, int xoff a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec47
887
    gl::TexSubImage3DRobustANGLE(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels.bufSize, pixels.data);
881
    gl::TexSubImage3DRobustANGLE(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels.bufSize, pixels.data);
888
}
882
}
889
883
890
void GraphicsContextGLOpenGL::texSubImage3D(GCGLenum target, int level, int xoffset, int yoffset, int zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, GCGLintptr offset)
884
void GraphicsContextGLANGLE::texSubImage3D(GCGLenum target, int level, int xoffset, int yoffset, int zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, GCGLintptr offset)
891
{
885
{
892
    texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
886
    texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
893
}
887
}
894
888
895
void GraphicsContextGLOpenGL::compressedTexImage3D(GCGLenum target, int level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, int border, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
889
void GraphicsContextGLANGLE::compressedTexImage3D(GCGLenum target, int level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, int border, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
896
{
890
{
897
    if (!makeContextCurrent())
891
    if (!makeContextCurrent())
898
        return;
892
        return;
Lines 900-911 void GraphicsContextGLOpenGL::compressedTexImage3D(GCGLenum target, int level, G a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec48
900
    gl::CompressedTexImage3DRobustANGLE(target, level, internalformat, width, height, depth, border, imageSize, data.bufSize, data.data);
894
    gl::CompressedTexImage3DRobustANGLE(target, level, internalformat, width, height, depth, border, imageSize, data.bufSize, data.data);
901
}
895
}
902
896
903
void GraphicsContextGLOpenGL::compressedTexImage3D(GCGLenum target, int level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, int border, GCGLsizei imageSize, GCGLintptr offset)
897
void GraphicsContextGLANGLE::compressedTexImage3D(GCGLenum target, int level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, int border, GCGLsizei imageSize, GCGLintptr offset)
904
{
898
{
905
    compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
899
    compressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
906
}
900
}
907
901
908
void GraphicsContextGLOpenGL::compressedTexSubImage3D(GCGLenum target, int level, int xoffset, int yoffset, int zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
902
void GraphicsContextGLANGLE::compressedTexSubImage3D(GCGLenum target, int level, int xoffset, int yoffset, int zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
909
{
903
{
910
    if (!makeContextCurrent())
904
    if (!makeContextCurrent())
911
        return;
905
        return;
Lines 913-924 void GraphicsContextGLOpenGL::compressedTexSubImage3D(GCGLenum target, int level a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec49
913
    gl::CompressedTexSubImage3DRobustANGLE(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data.bufSize, data.data);
907
    gl::CompressedTexSubImage3DRobustANGLE(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data.bufSize, data.data);
914
}
908
}
915
909
916
void GraphicsContextGLOpenGL::compressedTexSubImage3D(GCGLenum target, int level, int xoffset, int yoffset, int zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLsizei imageSize, GCGLintptr offset)
910
void GraphicsContextGLANGLE::compressedTexSubImage3D(GCGLenum target, int level, int xoffset, int yoffset, int zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLsizei imageSize, GCGLintptr offset)
917
{
911
{
918
    compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
912
    compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, makeGCGLSpan(reinterpret_cast<const GCGLvoid*>(offset), 0));
919
}
913
}
920
914
921
Vector<GCGLint> GraphicsContextGLOpenGL::getActiveUniforms(PlatformGLObject program, const Vector<GCGLuint>& uniformIndices, GCGLenum pname)
915
Vector<GCGLint> GraphicsContextGLANGLE::getActiveUniforms(PlatformGLObject program, const Vector<GCGLuint>& uniformIndices, GCGLenum pname)
922
{
916
{
923
    Vector<GCGLint> result(uniformIndices.size(), 0);
917
    Vector<GCGLint> result(uniformIndices.size(), 0);
924
    ASSERT(program);
918
    ASSERT(program);
Lines 929-935 Vector<GCGLint> GraphicsContextGLOpenGL::getActiveUniforms(PlatformGLObject prog a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec50
929
    return result;
923
    return result;
930
}
924
}
931
925
932
GCGLenum GraphicsContextGLOpenGL::checkFramebufferStatus(GCGLenum target)
926
GCGLenum GraphicsContextGLANGLE::checkFramebufferStatus(GCGLenum target)
933
{
927
{
934
    if (!makeContextCurrent())
928
    if (!makeContextCurrent())
935
        return GL_INVALID_OPERATION;
929
        return GL_INVALID_OPERATION;
Lines 937-943 GCGLenum GraphicsContextGLOpenGL::checkFramebufferStatus(GCGLenum target) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec51
937
    return gl::CheckFramebufferStatus(target);
931
    return gl::CheckFramebufferStatus(target);
938
}
932
}
939
933
940
void GraphicsContextGLOpenGL::clearColor(GCGLclampf r, GCGLclampf g, GCGLclampf b, GCGLclampf a)
934
void GraphicsContextGLANGLE::clearColor(GCGLclampf r, GCGLclampf g, GCGLclampf b, GCGLclampf a)
941
{
935
{
942
    if (!makeContextCurrent())
936
    if (!makeContextCurrent())
943
        return;
937
        return;
Lines 945-951 void GraphicsContextGLOpenGL::clearColor(GCGLclampf r, GCGLclampf g, GCGLclampf a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec52
945
    gl::ClearColor(r, g, b, a);
939
    gl::ClearColor(r, g, b, a);
946
}
940
}
947
941
948
void GraphicsContextGLOpenGL::clear(GCGLbitfield mask)
942
void GraphicsContextGLANGLE::clear(GCGLbitfield mask)
949
{
943
{
950
    if (!makeContextCurrent())
944
    if (!makeContextCurrent())
951
        return;
945
        return;
Lines 954-960 void GraphicsContextGLOpenGL::clear(GCGLbitfield mask) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec53
954
    checkGPUStatus();
948
    checkGPUStatus();
955
}
949
}
956
950
957
void GraphicsContextGLOpenGL::clearStencil(GCGLint s)
951
void GraphicsContextGLANGLE::clearStencil(GCGLint s)
958
{
952
{
959
    if (!makeContextCurrent())
953
    if (!makeContextCurrent())
960
        return;
954
        return;
Lines 962-968 void GraphicsContextGLOpenGL::clearStencil(GCGLint s) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec54
962
    gl::ClearStencil(s);
956
    gl::ClearStencil(s);
963
}
957
}
964
958
965
void GraphicsContextGLOpenGL::colorMask(GCGLboolean red, GCGLboolean green, GCGLboolean blue, GCGLboolean alpha)
959
void GraphicsContextGLANGLE::colorMask(GCGLboolean red, GCGLboolean green, GCGLboolean blue, GCGLboolean alpha)
966
{
960
{
967
    if (!makeContextCurrent())
961
    if (!makeContextCurrent())
968
        return;
962
        return;
Lines 970-976 void GraphicsContextGLOpenGL::colorMask(GCGLboolean red, GCGLboolean green, GCGL a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec55
970
    gl::ColorMask(red, green, blue, alpha);
964
    gl::ColorMask(red, green, blue, alpha);
971
}
965
}
972
966
973
void GraphicsContextGLOpenGL::compileShader(PlatformGLObject shader)
967
void GraphicsContextGLANGLE::compileShader(PlatformGLObject shader)
974
{
968
{
975
    ASSERT(shader);
969
    ASSERT(shader);
976
    if (!makeContextCurrent())
970
    if (!makeContextCurrent())
Lines 988-994 void GraphicsContextGLOpenGL::compileShader(PlatformGLObject shader) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec56
988
#endif
982
#endif
989
}
983
}
990
984
991
void GraphicsContextGLOpenGL::compileShaderDirect(PlatformGLObject shader)
985
void GraphicsContextGLANGLE::compileShaderDirect(PlatformGLObject shader)
992
{
986
{
993
    ASSERT(shader);
987
    ASSERT(shader);
994
    if (!makeContextCurrent())
988
    if (!makeContextCurrent())
Lines 997-1003 void GraphicsContextGLOpenGL::compileShaderDirect(PlatformGLObject shader) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec57
997
    gl::CompileShader(shader);
991
    gl::CompileShader(shader);
998
}
992
}
999
993
1000
void GraphicsContextGLOpenGL::texImage2DDirect(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, const void* pixels)
994
void GraphicsContextGLANGLE::texImage2DDirect(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, const void* pixels)
1001
{
995
{
1002
    if (!makeContextCurrent())
996
    if (!makeContextCurrent())
1003
        return;
997
        return;
Lines 1005-1011 void GraphicsContextGLOpenGL::texImage2DDirect(GCGLenum target, GCGLint level, G a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec58
1005
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
999
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1006
}
1000
}
1007
1001
1008
void GraphicsContextGLOpenGL::copyTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLint border)
1002
void GraphicsContextGLANGLE::copyTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLint border)
1009
{
1003
{
1010
    if (!makeContextCurrent())
1004
    if (!makeContextCurrent())
1011
        return;
1005
        return;
Lines 1022-1028 void GraphicsContextGLOpenGL::copyTexImage2D(GCGLenum target, GCGLint level, GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec59
1022
        gl::BindFramebuffer(framebufferTarget, m_multisampleFBO);
1016
        gl::BindFramebuffer(framebufferTarget, m_multisampleFBO);
1023
}
1017
}
1024
1018
1025
void GraphicsContextGLOpenGL::copyTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1019
void GraphicsContextGLANGLE::copyTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1026
{
1020
{
1027
    if (!makeContextCurrent())
1021
    if (!makeContextCurrent())
1028
        return;
1022
        return;
Lines 1039-1045 void GraphicsContextGLOpenGL::copyTexSubImage2D(GCGLenum target, GCGLint level, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec60
1039
        gl::BindFramebuffer(framebufferTarget, m_multisampleFBO);
1033
        gl::BindFramebuffer(framebufferTarget, m_multisampleFBO);
1040
}
1034
}
1041
1035
1042
void GraphicsContextGLOpenGL::cullFace(GCGLenum mode)
1036
void GraphicsContextGLANGLE::cullFace(GCGLenum mode)
1043
{
1037
{
1044
    if (!makeContextCurrent())
1038
    if (!makeContextCurrent())
1045
        return;
1039
        return;
Lines 1047-1053 void GraphicsContextGLOpenGL::cullFace(GCGLenum mode) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec61
1047
    gl::CullFace(mode);
1041
    gl::CullFace(mode);
1048
}
1042
}
1049
1043
1050
void GraphicsContextGLOpenGL::depthFunc(GCGLenum func)
1044
void GraphicsContextGLANGLE::depthFunc(GCGLenum func)
1051
{
1045
{
1052
    if (!makeContextCurrent())
1046
    if (!makeContextCurrent())
1053
        return;
1047
        return;
Lines 1055-1061 void GraphicsContextGLOpenGL::depthFunc(GCGLenum func) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec62
1055
    gl::DepthFunc(func);
1049
    gl::DepthFunc(func);
1056
}
1050
}
1057
1051
1058
void GraphicsContextGLOpenGL::depthMask(GCGLboolean flag)
1052
void GraphicsContextGLANGLE::depthMask(GCGLboolean flag)
1059
{
1053
{
1060
    if (!makeContextCurrent())
1054
    if (!makeContextCurrent())
1061
        return;
1055
        return;
Lines 1063-1069 void GraphicsContextGLOpenGL::depthMask(GCGLboolean flag) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec63
1063
    gl::DepthMask(flag);
1057
    gl::DepthMask(flag);
1064
}
1058
}
1065
1059
1066
void GraphicsContextGLOpenGL::detachShader(PlatformGLObject program, PlatformGLObject shader)
1060
void GraphicsContextGLANGLE::detachShader(PlatformGLObject program, PlatformGLObject shader)
1067
{
1061
{
1068
    ASSERT(program);
1062
    ASSERT(program);
1069
    ASSERT(shader);
1063
    ASSERT(shader);
Lines 1073-1079 void GraphicsContextGLOpenGL::detachShader(PlatformGLObject program, PlatformGLO a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec64
1073
    gl::DetachShader(program, shader);
1067
    gl::DetachShader(program, shader);
1074
}
1068
}
1075
1069
1076
void GraphicsContextGLOpenGL::disable(GCGLenum cap)
1070
void GraphicsContextGLANGLE::disable(GCGLenum cap)
1077
{
1071
{
1078
    if (!makeContextCurrent())
1072
    if (!makeContextCurrent())
1079
        return;
1073
        return;
Lines 1081-1087 void GraphicsContextGLOpenGL::disable(GCGLenum cap) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec65
1081
    gl::Disable(cap);
1075
    gl::Disable(cap);
1082
}
1076
}
1083
1077
1084
void GraphicsContextGLOpenGL::disableVertexAttribArray(GCGLuint index)
1078
void GraphicsContextGLANGLE::disableVertexAttribArray(GCGLuint index)
1085
{
1079
{
1086
    if (!makeContextCurrent())
1080
    if (!makeContextCurrent())
1087
        return;
1081
        return;
Lines 1089-1095 void GraphicsContextGLOpenGL::disableVertexAttribArray(GCGLuint index) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec66
1089
    gl::DisableVertexAttribArray(index);
1083
    gl::DisableVertexAttribArray(index);
1090
}
1084
}
1091
1085
1092
void GraphicsContextGLOpenGL::drawArrays(GCGLenum mode, GCGLint first, GCGLsizei count)
1086
void GraphicsContextGLANGLE::drawArrays(GCGLenum mode, GCGLint first, GCGLsizei count)
1093
{
1087
{
1094
    if (!makeContextCurrent())
1088
    if (!makeContextCurrent())
1095
        return;
1089
        return;
Lines 1098-1104 void GraphicsContextGLOpenGL::drawArrays(GCGLenum mode, GCGLint first, GCGLsizei a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec67
1098
    checkGPUStatus();
1092
    checkGPUStatus();
1099
}
1093
}
1100
1094
1101
void GraphicsContextGLOpenGL::drawElements(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset)
1095
void GraphicsContextGLANGLE::drawElements(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset)
1102
{
1096
{
1103
    if (!makeContextCurrent())
1097
    if (!makeContextCurrent())
1104
        return;
1098
        return;
Lines 1107-1113 void GraphicsContextGLOpenGL::drawElements(GCGLenum mode, GCGLsizei count, GCGLe a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec68
1107
    checkGPUStatus();
1101
    checkGPUStatus();
1108
}
1102
}
1109
1103
1110
void GraphicsContextGLOpenGL::enable(GCGLenum cap)
1104
void GraphicsContextGLANGLE::enable(GCGLenum cap)
1111
{
1105
{
1112
    if (!makeContextCurrent())
1106
    if (!makeContextCurrent())
1113
        return;
1107
        return;
Lines 1115-1121 void GraphicsContextGLOpenGL::enable(GCGLenum cap) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec69
1115
    gl::Enable(cap);
1109
    gl::Enable(cap);
1116
}
1110
}
1117
1111
1118
void GraphicsContextGLOpenGL::enableVertexAttribArray(GCGLuint index)
1112
void GraphicsContextGLANGLE::enableVertexAttribArray(GCGLuint index)
1119
{
1113
{
1120
    if (!makeContextCurrent())
1114
    if (!makeContextCurrent())
1121
        return;
1115
        return;
Lines 1123-1129 void GraphicsContextGLOpenGL::enableVertexAttribArray(GCGLuint index) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec70
1123
    gl::EnableVertexAttribArray(index);
1117
    gl::EnableVertexAttribArray(index);
1124
}
1118
}
1125
1119
1126
void GraphicsContextGLOpenGL::finish()
1120
void GraphicsContextGLANGLE::finish()
1127
{
1121
{
1128
    if (!makeContextCurrent())
1122
    if (!makeContextCurrent())
1129
        return;
1123
        return;
Lines 1131-1137 void GraphicsContextGLOpenGL::finish() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec71
1131
    gl::Finish();
1125
    gl::Finish();
1132
}
1126
}
1133
1127
1134
void GraphicsContextGLOpenGL::flush()
1128
void GraphicsContextGLANGLE::flush()
1135
{
1129
{
1136
    if (!makeContextCurrent())
1130
    if (!makeContextCurrent())
1137
        return;
1131
        return;
Lines 1139-1145 void GraphicsContextGLOpenGL::flush() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec72
1139
    gl::Flush();
1133
    gl::Flush();
1140
}
1134
}
1141
1135
1142
void GraphicsContextGLOpenGL::framebufferRenderbuffer(GCGLenum target, GCGLenum attachment, GCGLenum renderbuffertarget, PlatformGLObject buffer)
1136
void GraphicsContextGLANGLE::framebufferRenderbuffer(GCGLenum target, GCGLenum attachment, GCGLenum renderbuffertarget, PlatformGLObject buffer)
1143
{
1137
{
1144
    if (!makeContextCurrent())
1138
    if (!makeContextCurrent())
1145
        return;
1139
        return;
Lines 1147-1153 void GraphicsContextGLOpenGL::framebufferRenderbuffer(GCGLenum target, GCGLenum a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec73
1147
    gl::FramebufferRenderbuffer(target, attachment, renderbuffertarget, buffer);
1141
    gl::FramebufferRenderbuffer(target, attachment, renderbuffertarget, buffer);
1148
}
1142
}
1149
1143
1150
void GraphicsContextGLOpenGL::framebufferTexture2D(GCGLenum target, GCGLenum attachment, GCGLenum textarget, PlatformGLObject texture, GCGLint level)
1144
void GraphicsContextGLANGLE::framebufferTexture2D(GCGLenum target, GCGLenum attachment, GCGLenum textarget, PlatformGLObject texture, GCGLint level)
1151
{
1145
{
1152
    if (!makeContextCurrent())
1146
    if (!makeContextCurrent())
1153
        return;
1147
        return;
Lines 1156-1162 void GraphicsContextGLOpenGL::framebufferTexture2D(GCGLenum target, GCGLenum att a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec74
1156
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1150
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1157
}
1151
}
1158
1152
1159
void GraphicsContextGLOpenGL::frontFace(GCGLenum mode)
1153
void GraphicsContextGLANGLE::frontFace(GCGLenum mode)
1160
{
1154
{
1161
    if (!makeContextCurrent())
1155
    if (!makeContextCurrent())
1162
        return;
1156
        return;
Lines 1164-1170 void GraphicsContextGLOpenGL::frontFace(GCGLenum mode) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec75
1164
    gl::FrontFace(mode);
1158
    gl::FrontFace(mode);
1165
}
1159
}
1166
1160
1167
void GraphicsContextGLOpenGL::generateMipmap(GCGLenum target)
1161
void GraphicsContextGLANGLE::generateMipmap(GCGLenum target)
1168
{
1162
{
1169
    if (!makeContextCurrent())
1163
    if (!makeContextCurrent())
1170
        return;
1164
        return;
Lines 1172-1178 void GraphicsContextGLOpenGL::generateMipmap(GCGLenum target) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec76
1172
    gl::GenerateMipmap(target);
1166
    gl::GenerateMipmap(target);
1173
}
1167
}
1174
1168
1175
bool GraphicsContextGLOpenGL::getActiveAttribImpl(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
1169
bool GraphicsContextGLANGLE::getActiveAttribImpl(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
1176
{
1170
{
1177
    if (!program) {
1171
    if (!program) {
1178
        synthesizeGLError(INVALID_VALUE);
1172
        synthesizeGLError(INVALID_VALUE);
Lines 1197-1208 bool GraphicsContextGLOpenGL::getActiveAttribImpl(PlatformGLObject program, GCGL a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec77
1197
    return true;
1191
    return true;
1198
}
1192
}
1199
1193
1200
bool GraphicsContextGLOpenGL::getActiveAttrib(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
1194
bool GraphicsContextGLANGLE::getActiveAttrib(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
1201
{
1195
{
1202
    return getActiveAttribImpl(program, index, info);
1196
    return getActiveAttribImpl(program, index, info);
1203
}
1197
}
1204
1198
1205
bool GraphicsContextGLOpenGL::getActiveUniformImpl(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
1199
bool GraphicsContextGLANGLE::getActiveUniformImpl(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
1206
{
1200
{
1207
    if (!program) {
1201
    if (!program) {
1208
        synthesizeGLError(INVALID_VALUE);
1202
        synthesizeGLError(INVALID_VALUE);
Lines 1228-1239 bool GraphicsContextGLOpenGL::getActiveUniformImpl(PlatformGLObject program, GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec78
1228
    return true;
1222
    return true;
1229
}
1223
}
1230
1224
1231
bool GraphicsContextGLOpenGL::getActiveUniform(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
1225
bool GraphicsContextGLANGLE::getActiveUniform(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
1232
{
1226
{
1233
    return getActiveUniformImpl(program, index, info);
1227
    return getActiveUniformImpl(program, index, info);
1234
}
1228
}
1235
1229
1236
void GraphicsContextGLOpenGL::getAttachedShaders(PlatformGLObject program, GCGLsizei maxCount, GCGLsizei* count, PlatformGLObject* shaders)
1230
void GraphicsContextGLANGLE::getAttachedShaders(PlatformGLObject program, GCGLsizei maxCount, GCGLsizei* count, PlatformGLObject* shaders)
1237
{
1231
{
1238
    if (!program) {
1232
    if (!program) {
1239
        synthesizeGLError(INVALID_VALUE);
1233
        synthesizeGLError(INVALID_VALUE);
Lines 1245-1251 void GraphicsContextGLOpenGL::getAttachedShaders(PlatformGLObject program, GCGLs a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec79
1245
    gl::GetAttachedShaders(program, maxCount, count, shaders);
1239
    gl::GetAttachedShaders(program, maxCount, count, shaders);
1246
}
1240
}
1247
1241
1248
int GraphicsContextGLOpenGL::getAttribLocation(PlatformGLObject program, const String& name)
1242
int GraphicsContextGLANGLE::getAttribLocation(PlatformGLObject program, const String& name)
1249
{
1243
{
1250
    if (!program)
1244
    if (!program)
1251
        return -1;
1245
        return -1;
Lines 1257-1268 int GraphicsContextGLOpenGL::getAttribLocation(PlatformGLObject program, const S a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec80
1257
    return gl::GetAttribLocation(program, name.utf8().data());
1251
    return gl::GetAttribLocation(program, name.utf8().data());
1258
}
1252
}
1259
1253
1260
int GraphicsContextGLOpenGL::getAttribLocationDirect(PlatformGLObject program, const String& name)
1254
int GraphicsContextGLANGLE::getAttribLocationDirect(PlatformGLObject program, const String& name)
1261
{
1255
{
1262
    return getAttribLocation(program, name);
1256
    return getAttribLocation(program, name);
1263
}
1257
}
1264
1258
1265
bool GraphicsContextGLOpenGL::moveErrorsToSyntheticErrorList()
1259
bool GraphicsContextGLANGLE::moveErrorsToSyntheticErrorList()
1266
{
1260
{
1267
    if (!makeContextCurrent())
1261
    if (!makeContextCurrent())
1268
        return false;
1262
        return false;
Lines 1283-1289 bool GraphicsContextGLOpenGL::moveErrorsToSyntheticErrorList() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec81
1283
    return movedAnError;
1277
    return movedAnError;
1284
}
1278
}
1285
1279
1286
GCGLenum GraphicsContextGLOpenGL::getError()
1280
GCGLenum GraphicsContextGLANGLE::getError()
1287
{
1281
{
1288
    if (!m_syntheticErrors.isEmpty()) {
1282
    if (!m_syntheticErrors.isEmpty()) {
1289
        // Need to move the current errors to the synthetic error list in case
1283
        // Need to move the current errors to the synthetic error list in case
Lines 1299-1305 GCGLenum GraphicsContextGLOpenGL::getError() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec82
1299
    return gl::GetError();
1293
    return gl::GetError();
1300
}
1294
}
1301
1295
1302
String GraphicsContextGLOpenGL::getString(GCGLenum name)
1296
String GraphicsContextGLANGLE::getString(GCGLenum name)
1303
{
1297
{
1304
    if (!makeContextCurrent())
1298
    if (!makeContextCurrent())
1305
        return String();
1299
        return String();
Lines 1307-1313 String GraphicsContextGLOpenGL::getString(GCGLenum name) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec83
1307
    return String(reinterpret_cast<const char*>(gl::GetString(name)));
1301
    return String(reinterpret_cast<const char*>(gl::GetString(name)));
1308
}
1302
}
1309
1303
1310
void GraphicsContextGLOpenGL::hint(GCGLenum target, GCGLenum mode)
1304
void GraphicsContextGLANGLE::hint(GCGLenum target, GCGLenum mode)
1311
{
1305
{
1312
    if (!makeContextCurrent())
1306
    if (!makeContextCurrent())
1313
        return;
1307
        return;
Lines 1315-1321 void GraphicsContextGLOpenGL::hint(GCGLenum target, GCGLenum mode) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec84
1315
    gl::Hint(target, mode);
1309
    gl::Hint(target, mode);
1316
}
1310
}
1317
1311
1318
GCGLboolean GraphicsContextGLOpenGL::isBuffer(PlatformGLObject buffer)
1312
GCGLboolean GraphicsContextGLANGLE::isBuffer(PlatformGLObject buffer)
1319
{
1313
{
1320
    if (!buffer)
1314
    if (!buffer)
1321
        return GL_FALSE;
1315
        return GL_FALSE;
Lines 1326-1332 GCGLboolean GraphicsContextGLOpenGL::isBuffer(PlatformGLObject buffer) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec85
1326
    return gl::IsBuffer(buffer);
1320
    return gl::IsBuffer(buffer);
1327
}
1321
}
1328
1322
1329
GCGLboolean GraphicsContextGLOpenGL::isEnabled(GCGLenum cap)
1323
GCGLboolean GraphicsContextGLANGLE::isEnabled(GCGLenum cap)
1330
{
1324
{
1331
    if (!makeContextCurrent())
1325
    if (!makeContextCurrent())
1332
        return GL_FALSE;
1326
        return GL_FALSE;
Lines 1334-1340 GCGLboolean GraphicsContextGLOpenGL::isEnabled(GCGLenum cap) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec86
1334
    return gl::IsEnabled(cap);
1328
    return gl::IsEnabled(cap);
1335
}
1329
}
1336
1330
1337
GCGLboolean GraphicsContextGLOpenGL::isFramebuffer(PlatformGLObject framebuffer)
1331
GCGLboolean GraphicsContextGLANGLE::isFramebuffer(PlatformGLObject framebuffer)
1338
{
1332
{
1339
    if (!framebuffer)
1333
    if (!framebuffer)
1340
        return GL_FALSE;
1334
        return GL_FALSE;
Lines 1345-1351 GCGLboolean GraphicsContextGLOpenGL::isFramebuffer(PlatformGLObject framebuffer) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec87
1345
    return gl::IsFramebuffer(framebuffer);
1339
    return gl::IsFramebuffer(framebuffer);
1346
}
1340
}
1347
1341
1348
GCGLboolean GraphicsContextGLOpenGL::isProgram(PlatformGLObject program)
1342
GCGLboolean GraphicsContextGLANGLE::isProgram(PlatformGLObject program)
1349
{
1343
{
1350
    if (!program)
1344
    if (!program)
1351
        return GL_FALSE;
1345
        return GL_FALSE;
Lines 1356-1362 GCGLboolean GraphicsContextGLOpenGL::isProgram(PlatformGLObject program) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec88
1356
    return gl::IsProgram(program);
1350
    return gl::IsProgram(program);
1357
}
1351
}
1358
1352
1359
GCGLboolean GraphicsContextGLOpenGL::isRenderbuffer(PlatformGLObject renderbuffer)
1353
GCGLboolean GraphicsContextGLANGLE::isRenderbuffer(PlatformGLObject renderbuffer)
1360
{
1354
{
1361
    if (!renderbuffer)
1355
    if (!renderbuffer)
1362
        return GL_FALSE;
1356
        return GL_FALSE;
Lines 1367-1373 GCGLboolean GraphicsContextGLOpenGL::isRenderbuffer(PlatformGLObject renderbuffe a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec89
1367
    return gl::IsRenderbuffer(renderbuffer);
1361
    return gl::IsRenderbuffer(renderbuffer);
1368
}
1362
}
1369
1363
1370
GCGLboolean GraphicsContextGLOpenGL::isShader(PlatformGLObject shader)
1364
GCGLboolean GraphicsContextGLANGLE::isShader(PlatformGLObject shader)
1371
{
1365
{
1372
    if (!shader)
1366
    if (!shader)
1373
        return GL_FALSE;
1367
        return GL_FALSE;
Lines 1378-1384 GCGLboolean GraphicsContextGLOpenGL::isShader(PlatformGLObject shader) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec90
1378
    return gl::IsShader(shader);
1372
    return gl::IsShader(shader);
1379
}
1373
}
1380
1374
1381
GCGLboolean GraphicsContextGLOpenGL::isTexture(PlatformGLObject texture)
1375
GCGLboolean GraphicsContextGLANGLE::isTexture(PlatformGLObject texture)
1382
{
1376
{
1383
    if (!texture)
1377
    if (!texture)
1384
        return GL_FALSE;
1378
        return GL_FALSE;
Lines 1389-1395 GCGLboolean GraphicsContextGLOpenGL::isTexture(PlatformGLObject texture) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec91
1389
    return gl::IsTexture(texture);
1383
    return gl::IsTexture(texture);
1390
}
1384
}
1391
1385
1392
void GraphicsContextGLOpenGL::lineWidth(GCGLfloat width)
1386
void GraphicsContextGLANGLE::lineWidth(GCGLfloat width)
1393
{
1387
{
1394
    if (!makeContextCurrent())
1388
    if (!makeContextCurrent())
1395
        return;
1389
        return;
Lines 1397-1403 void GraphicsContextGLOpenGL::lineWidth(GCGLfloat width) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec92
1397
    gl::LineWidth(width);
1391
    gl::LineWidth(width);
1398
}
1392
}
1399
1393
1400
void GraphicsContextGLOpenGL::linkProgram(PlatformGLObject program)
1394
void GraphicsContextGLANGLE::linkProgram(PlatformGLObject program)
1401
{
1395
{
1402
    ASSERT(program);
1396
    ASSERT(program);
1403
    if (!makeContextCurrent())
1397
    if (!makeContextCurrent())
Lines 1406-1412 void GraphicsContextGLOpenGL::linkProgram(PlatformGLObject program) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec93
1406
    gl::LinkProgram(program);
1400
    gl::LinkProgram(program);
1407
}
1401
}
1408
1402
1409
void GraphicsContextGLOpenGL::pixelStorei(GCGLenum pname, GCGLint param)
1403
void GraphicsContextGLANGLE::pixelStorei(GCGLenum pname, GCGLint param)
1410
{
1404
{
1411
    if (!makeContextCurrent())
1405
    if (!makeContextCurrent())
1412
        return;
1406
        return;
Lines 1414-1420 void GraphicsContextGLOpenGL::pixelStorei(GCGLenum pname, GCGLint param) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec94
1414
    gl::PixelStorei(pname, param);
1408
    gl::PixelStorei(pname, param);
1415
}
1409
}
1416
1410
1417
void GraphicsContextGLOpenGL::polygonOffset(GCGLfloat factor, GCGLfloat units)
1411
void GraphicsContextGLANGLE::polygonOffset(GCGLfloat factor, GCGLfloat units)
1418
{
1412
{
1419
    if (!makeContextCurrent())
1413
    if (!makeContextCurrent())
1420
        return;
1414
        return;
Lines 1422-1428 void GraphicsContextGLOpenGL::polygonOffset(GCGLfloat factor, GCGLfloat units) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec95
1422
    gl::PolygonOffset(factor, units);
1416
    gl::PolygonOffset(factor, units);
1423
}
1417
}
1424
1418
1425
void GraphicsContextGLOpenGL::sampleCoverage(GCGLclampf value, GCGLboolean invert)
1419
void GraphicsContextGLANGLE::sampleCoverage(GCGLclampf value, GCGLboolean invert)
1426
{
1420
{
1427
    if (!makeContextCurrent())
1421
    if (!makeContextCurrent())
1428
        return;
1422
        return;
Lines 1430-1436 void GraphicsContextGLOpenGL::sampleCoverage(GCGLclampf value, GCGLboolean inver a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec96
1430
    gl::SampleCoverage(value, invert);
1424
    gl::SampleCoverage(value, invert);
1431
}
1425
}
1432
1426
1433
void GraphicsContextGLOpenGL::scissor(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1427
void GraphicsContextGLANGLE::scissor(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1434
{
1428
{
1435
    if (!makeContextCurrent())
1429
    if (!makeContextCurrent())
1436
        return;
1430
        return;
Lines 1438-1444 void GraphicsContextGLOpenGL::scissor(GCGLint x, GCGLint y, GCGLsizei width, GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec97
1438
    gl::Scissor(x, y, width, height);
1432
    gl::Scissor(x, y, width, height);
1439
}
1433
}
1440
1434
1441
void GraphicsContextGLOpenGL::shaderSource(PlatformGLObject shader, const String& string)
1435
void GraphicsContextGLANGLE::shaderSource(PlatformGLObject shader, const String& string)
1442
{
1436
{
1443
    ASSERT(shader);
1437
    ASSERT(shader);
1444
1438
Lines 1451-1457 void GraphicsContextGLOpenGL::shaderSource(PlatformGLObject shader, const String a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec98
1451
    gl::ShaderSource(shader, 1, &shaderSourcePtr, &shaderSourceLength);
1445
    gl::ShaderSource(shader, 1, &shaderSourcePtr, &shaderSourceLength);
1452
}
1446
}
1453
1447
1454
void GraphicsContextGLOpenGL::stencilFunc(GCGLenum func, GCGLint ref, GCGLuint mask)
1448
void GraphicsContextGLANGLE::stencilFunc(GCGLenum func, GCGLint ref, GCGLuint mask)
1455
{
1449
{
1456
    if (!makeContextCurrent())
1450
    if (!makeContextCurrent())
1457
        return;
1451
        return;
Lines 1459-1465 void GraphicsContextGLOpenGL::stencilFunc(GCGLenum func, GCGLint ref, GCGLuint m a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec99
1459
    gl::StencilFunc(func, ref, mask);
1453
    gl::StencilFunc(func, ref, mask);
1460
}
1454
}
1461
1455
1462
void GraphicsContextGLOpenGL::stencilFuncSeparate(GCGLenum face, GCGLenum func, GCGLint ref, GCGLuint mask)
1456
void GraphicsContextGLANGLE::stencilFuncSeparate(GCGLenum face, GCGLenum func, GCGLint ref, GCGLuint mask)
1463
{
1457
{
1464
    if (!makeContextCurrent())
1458
    if (!makeContextCurrent())
1465
        return;
1459
        return;
Lines 1467-1473 void GraphicsContextGLOpenGL::stencilFuncSeparate(GCGLenum face, GCGLenum func, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec100
1467
    gl::StencilFuncSeparate(face, func, ref, mask);
1461
    gl::StencilFuncSeparate(face, func, ref, mask);
1468
}
1462
}
1469
1463
1470
void GraphicsContextGLOpenGL::stencilMask(GCGLuint mask)
1464
void GraphicsContextGLANGLE::stencilMask(GCGLuint mask)
1471
{
1465
{
1472
    if (!makeContextCurrent())
1466
    if (!makeContextCurrent())
1473
        return;
1467
        return;
Lines 1475-1481 void GraphicsContextGLOpenGL::stencilMask(GCGLuint mask) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec101
1475
    gl::StencilMask(mask);
1469
    gl::StencilMask(mask);
1476
}
1470
}
1477
1471
1478
void GraphicsContextGLOpenGL::stencilMaskSeparate(GCGLenum face, GCGLuint mask)
1472
void GraphicsContextGLANGLE::stencilMaskSeparate(GCGLenum face, GCGLuint mask)
1479
{
1473
{
1480
    if (!makeContextCurrent())
1474
    if (!makeContextCurrent())
1481
        return;
1475
        return;
Lines 1483-1489 void GraphicsContextGLOpenGL::stencilMaskSeparate(GCGLenum face, GCGLuint mask) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec102
1483
    gl::StencilMaskSeparate(face, mask);
1477
    gl::StencilMaskSeparate(face, mask);
1484
}
1478
}
1485
1479
1486
void GraphicsContextGLOpenGL::stencilOp(GCGLenum fail, GCGLenum zfail, GCGLenum zpass)
1480
void GraphicsContextGLANGLE::stencilOp(GCGLenum fail, GCGLenum zfail, GCGLenum zpass)
1487
{
1481
{
1488
    if (!makeContextCurrent())
1482
    if (!makeContextCurrent())
1489
        return;
1483
        return;
Lines 1491-1497 void GraphicsContextGLOpenGL::stencilOp(GCGLenum fail, GCGLenum zfail, GCGLenum a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec103
1491
    gl::StencilOp(fail, zfail, zpass);
1485
    gl::StencilOp(fail, zfail, zpass);
1492
}
1486
}
1493
1487
1494
void GraphicsContextGLOpenGL::stencilOpSeparate(GCGLenum face, GCGLenum fail, GCGLenum zfail, GCGLenum zpass)
1488
void GraphicsContextGLANGLE::stencilOpSeparate(GCGLenum face, GCGLenum fail, GCGLenum zfail, GCGLenum zpass)
1495
{
1489
{
1496
    if (!makeContextCurrent())
1490
    if (!makeContextCurrent())
1497
        return;
1491
        return;
Lines 1499-1505 void GraphicsContextGLOpenGL::stencilOpSeparate(GCGLenum face, GCGLenum fail, GC a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec104
1499
    gl::StencilOpSeparate(face, fail, zfail, zpass);
1493
    gl::StencilOpSeparate(face, fail, zfail, zpass);
1500
}
1494
}
1501
1495
1502
void GraphicsContextGLOpenGL::texParameterf(GCGLenum target, GCGLenum pname, GCGLfloat value)
1496
void GraphicsContextGLANGLE::texParameterf(GCGLenum target, GCGLenum pname, GCGLfloat value)
1503
{
1497
{
1504
    if (!makeContextCurrent())
1498
    if (!makeContextCurrent())
1505
        return;
1499
        return;
Lines 1507-1513 void GraphicsContextGLOpenGL::texParameterf(GCGLenum target, GCGLenum pname, GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec105
1507
    gl::TexParameterf(target, pname, value);
1501
    gl::TexParameterf(target, pname, value);
1508
}
1502
}
1509
1503
1510
void GraphicsContextGLOpenGL::texParameteri(GCGLenum target, GCGLenum pname, GCGLint value)
1504
void GraphicsContextGLANGLE::texParameteri(GCGLenum target, GCGLenum pname, GCGLint value)
1511
{
1505
{
1512
    if (!makeContextCurrent())
1506
    if (!makeContextCurrent())
1513
        return;
1507
        return;
Lines 1515-1521 void GraphicsContextGLOpenGL::texParameteri(GCGLenum target, GCGLenum pname, GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec106
1515
    gl::TexParameteri(target, pname, value);
1509
    gl::TexParameteri(target, pname, value);
1516
}
1510
}
1517
1511
1518
void GraphicsContextGLOpenGL::uniform1f(GCGLint location, GCGLfloat v0)
1512
void GraphicsContextGLANGLE::uniform1f(GCGLint location, GCGLfloat v0)
1519
{
1513
{
1520
    if (!makeContextCurrent())
1514
    if (!makeContextCurrent())
1521
        return;
1515
        return;
Lines 1523-1529 void GraphicsContextGLOpenGL::uniform1f(GCGLint location, GCGLfloat v0) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec107
1523
    gl::Uniform1f(location, v0);
1517
    gl::Uniform1f(location, v0);
1524
}
1518
}
1525
1519
1526
void GraphicsContextGLOpenGL::uniform1fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1520
void GraphicsContextGLANGLE::uniform1fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1527
{
1521
{
1528
    if (!makeContextCurrent())
1522
    if (!makeContextCurrent())
1529
        return;
1523
        return;
Lines 1531-1537 void GraphicsContextGLOpenGL::uniform1fv(GCGLint location, GCGLSpan<const GCGLfl a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec108
1531
    gl::Uniform1fv(location, array.bufSize, array.data);
1525
    gl::Uniform1fv(location, array.bufSize, array.data);
1532
}
1526
}
1533
1527
1534
void GraphicsContextGLOpenGL::uniform2f(GCGLint location, GCGLfloat v0, GCGLfloat v1)
1528
void GraphicsContextGLANGLE::uniform2f(GCGLint location, GCGLfloat v0, GCGLfloat v1)
1535
{
1529
{
1536
    if (!makeContextCurrent())
1530
    if (!makeContextCurrent())
1537
        return;
1531
        return;
Lines 1539-1545 void GraphicsContextGLOpenGL::uniform2f(GCGLint location, GCGLfloat v0, GCGLfloa a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec109
1539
    gl::Uniform2f(location, v0, v1);
1533
    gl::Uniform2f(location, v0, v1);
1540
}
1534
}
1541
1535
1542
void GraphicsContextGLOpenGL::uniform2fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1536
void GraphicsContextGLANGLE::uniform2fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1543
{
1537
{
1544
    ASSERT(!(array.bufSize % 2));
1538
    ASSERT(!(array.bufSize % 2));
1545
    if (!makeContextCurrent())
1539
    if (!makeContextCurrent())
Lines 1548-1554 void GraphicsContextGLOpenGL::uniform2fv(GCGLint location, GCGLSpan<const GCGLfl a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec110
1548
    gl::Uniform2fv(location, array.bufSize / 2, array.data);
1542
    gl::Uniform2fv(location, array.bufSize / 2, array.data);
1549
}
1543
}
1550
1544
1551
void GraphicsContextGLOpenGL::uniform3f(GCGLint location, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2)
1545
void GraphicsContextGLANGLE::uniform3f(GCGLint location, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2)
1552
{
1546
{
1553
    if (!makeContextCurrent())
1547
    if (!makeContextCurrent())
1554
        return;
1548
        return;
Lines 1556-1562 void GraphicsContextGLOpenGL::uniform3f(GCGLint location, GCGLfloat v0, GCGLfloa a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec111
1556
    gl::Uniform3f(location, v0, v1, v2);
1550
    gl::Uniform3f(location, v0, v1, v2);
1557
}
1551
}
1558
1552
1559
void GraphicsContextGLOpenGL::uniform3fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1553
void GraphicsContextGLANGLE::uniform3fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1560
{
1554
{
1561
    ASSERT(!(array.bufSize % 3));
1555
    ASSERT(!(array.bufSize % 3));
1562
    if (!makeContextCurrent())
1556
    if (!makeContextCurrent())
Lines 1565-1571 void GraphicsContextGLOpenGL::uniform3fv(GCGLint location, GCGLSpan<const GCGLfl a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec112
1565
    gl::Uniform3fv(location, array.bufSize / 3, array.data);
1559
    gl::Uniform3fv(location, array.bufSize / 3, array.data);
1566
}
1560
}
1567
1561
1568
void GraphicsContextGLOpenGL::uniform4f(GCGLint location, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2, GCGLfloat v3)
1562
void GraphicsContextGLANGLE::uniform4f(GCGLint location, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2, GCGLfloat v3)
1569
{
1563
{
1570
    if (!makeContextCurrent())
1564
    if (!makeContextCurrent())
1571
        return;
1565
        return;
Lines 1573-1579 void GraphicsContextGLOpenGL::uniform4f(GCGLint location, GCGLfloat v0, GCGLfloa a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec113
1573
    gl::Uniform4f(location, v0, v1, v2, v3);
1567
    gl::Uniform4f(location, v0, v1, v2, v3);
1574
}
1568
}
1575
1569
1576
void GraphicsContextGLOpenGL::uniform4fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1570
void GraphicsContextGLANGLE::uniform4fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1577
{
1571
{
1578
    ASSERT(!(array.bufSize % 4));
1572
    ASSERT(!(array.bufSize % 4));
1579
    if (!makeContextCurrent())
1573
    if (!makeContextCurrent())
Lines 1582-1588 void GraphicsContextGLOpenGL::uniform4fv(GCGLint location, GCGLSpan<const GCGLfl a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec114
1582
    gl::Uniform4fv(location, array.bufSize / 4, array.data);
1576
    gl::Uniform4fv(location, array.bufSize / 4, array.data);
1583
}
1577
}
1584
1578
1585
void GraphicsContextGLOpenGL::uniform1i(GCGLint location, GCGLint v0)
1579
void GraphicsContextGLANGLE::uniform1i(GCGLint location, GCGLint v0)
1586
{
1580
{
1587
    if (!makeContextCurrent())
1581
    if (!makeContextCurrent())
1588
        return;
1582
        return;
Lines 1590-1596 void GraphicsContextGLOpenGL::uniform1i(GCGLint location, GCGLint v0) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec115
1590
    gl::Uniform1i(location, v0);
1584
    gl::Uniform1i(location, v0);
1591
}
1585
}
1592
1586
1593
void GraphicsContextGLOpenGL::uniform1iv(GCGLint location, GCGLSpan<const GCGLint> array)
1587
void GraphicsContextGLANGLE::uniform1iv(GCGLint location, GCGLSpan<const GCGLint> array)
1594
{
1588
{
1595
    if (!makeContextCurrent())
1589
    if (!makeContextCurrent())
1596
        return;
1590
        return;
Lines 1598-1604 void GraphicsContextGLOpenGL::uniform1iv(GCGLint location, GCGLSpan<const GCGLin a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec116
1598
    gl::Uniform1iv(location, array.bufSize, array.data);
1592
    gl::Uniform1iv(location, array.bufSize, array.data);
1599
}
1593
}
1600
1594
1601
void GraphicsContextGLOpenGL::uniform2i(GCGLint location, GCGLint v0, GCGLint v1)
1595
void GraphicsContextGLANGLE::uniform2i(GCGLint location, GCGLint v0, GCGLint v1)
1602
{
1596
{
1603
    if (!makeContextCurrent())
1597
    if (!makeContextCurrent())
1604
        return;
1598
        return;
Lines 1606-1612 void GraphicsContextGLOpenGL::uniform2i(GCGLint location, GCGLint v0, GCGLint v1 a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec117
1606
    gl::Uniform2i(location, v0, v1);
1600
    gl::Uniform2i(location, v0, v1);
1607
}
1601
}
1608
1602
1609
void GraphicsContextGLOpenGL::uniform2iv(GCGLint location, GCGLSpan<const GCGLint> array)
1603
void GraphicsContextGLANGLE::uniform2iv(GCGLint location, GCGLSpan<const GCGLint> array)
1610
{
1604
{
1611
    ASSERT(!(array.bufSize % 2));
1605
    ASSERT(!(array.bufSize % 2));
1612
    if (!makeContextCurrent())
1606
    if (!makeContextCurrent())
Lines 1615-1621 void GraphicsContextGLOpenGL::uniform2iv(GCGLint location, GCGLSpan<const GCGLin a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec118
1615
    gl::Uniform2iv(location, array.bufSize / 2, array.data);
1609
    gl::Uniform2iv(location, array.bufSize / 2, array.data);
1616
}
1610
}
1617
1611
1618
void GraphicsContextGLOpenGL::uniform3i(GCGLint location, GCGLint v0, GCGLint v1, GCGLint v2)
1612
void GraphicsContextGLANGLE::uniform3i(GCGLint location, GCGLint v0, GCGLint v1, GCGLint v2)
1619
{
1613
{
1620
    if (!makeContextCurrent())
1614
    if (!makeContextCurrent())
1621
        return;
1615
        return;
Lines 1623-1629 void GraphicsContextGLOpenGL::uniform3i(GCGLint location, GCGLint v0, GCGLint v1 a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec119
1623
    gl::Uniform3i(location, v0, v1, v2);
1617
    gl::Uniform3i(location, v0, v1, v2);
1624
}
1618
}
1625
1619
1626
void GraphicsContextGLOpenGL::uniform3iv(GCGLint location, GCGLSpan<const GCGLint> array)
1620
void GraphicsContextGLANGLE::uniform3iv(GCGLint location, GCGLSpan<const GCGLint> array)
1627
{
1621
{
1628
    ASSERT(!(array.bufSize % 3));
1622
    ASSERT(!(array.bufSize % 3));
1629
    if (!makeContextCurrent())
1623
    if (!makeContextCurrent())
Lines 1632-1638 void GraphicsContextGLOpenGL::uniform3iv(GCGLint location, GCGLSpan<const GCGLin a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec120
1632
    gl::Uniform3iv(location, array.bufSize / 3, array.data);
1626
    gl::Uniform3iv(location, array.bufSize / 3, array.data);
1633
}
1627
}
1634
1628
1635
void GraphicsContextGLOpenGL::uniform4i(GCGLint location, GCGLint v0, GCGLint v1, GCGLint v2, GCGLint v3)
1629
void GraphicsContextGLANGLE::uniform4i(GCGLint location, GCGLint v0, GCGLint v1, GCGLint v2, GCGLint v3)
1636
{
1630
{
1637
    if (!makeContextCurrent())
1631
    if (!makeContextCurrent())
1638
        return;
1632
        return;
Lines 1640-1646 void GraphicsContextGLOpenGL::uniform4i(GCGLint location, GCGLint v0, GCGLint v1 a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec121
1640
    gl::Uniform4i(location, v0, v1, v2, v3);
1634
    gl::Uniform4i(location, v0, v1, v2, v3);
1641
}
1635
}
1642
1636
1643
void GraphicsContextGLOpenGL::uniform4iv(GCGLint location, GCGLSpan<const GCGLint> array)
1637
void GraphicsContextGLANGLE::uniform4iv(GCGLint location, GCGLSpan<const GCGLint> array)
1644
{
1638
{
1645
    ASSERT(!(array.bufSize % 4));
1639
    ASSERT(!(array.bufSize % 4));
1646
    if (!makeContextCurrent())
1640
    if (!makeContextCurrent())
Lines 1649-1655 void GraphicsContextGLOpenGL::uniform4iv(GCGLint location, GCGLSpan<const GCGLin a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec122
1649
    gl::Uniform4iv(location, array.bufSize / 4, array.data);
1643
    gl::Uniform4iv(location, array.bufSize / 4, array.data);
1650
}
1644
}
1651
1645
1652
void GraphicsContextGLOpenGL::uniformMatrix2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1646
void GraphicsContextGLANGLE::uniformMatrix2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1653
{
1647
{
1654
    if (!makeContextCurrent())
1648
    if (!makeContextCurrent())
1655
        return;
1649
        return;
Lines 1657-1663 void GraphicsContextGLOpenGL::uniformMatrix2fv(GCGLint location, GCGLboolean tra a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec123
1657
    gl::UniformMatrix2fv(location, array.bufSize / 4, transpose, array.data);
1651
    gl::UniformMatrix2fv(location, array.bufSize / 4, transpose, array.data);
1658
}
1652
}
1659
1653
1660
void GraphicsContextGLOpenGL::uniformMatrix3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1654
void GraphicsContextGLANGLE::uniformMatrix3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1661
{
1655
{
1662
    ASSERT(!(array.bufSize % 9));
1656
    ASSERT(!(array.bufSize % 9));
1663
    if (!makeContextCurrent())
1657
    if (!makeContextCurrent())
Lines 1666-1672 void GraphicsContextGLOpenGL::uniformMatrix3fv(GCGLint location, GCGLboolean tra a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec124
1666
    gl::UniformMatrix3fv(location, array.bufSize / 9, transpose, array.data);
1660
    gl::UniformMatrix3fv(location, array.bufSize / 9, transpose, array.data);
1667
}
1661
}
1668
1662
1669
void GraphicsContextGLOpenGL::uniformMatrix4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1663
void GraphicsContextGLANGLE::uniformMatrix4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1670
{
1664
{
1671
    ASSERT(!(array.bufSize % 16));
1665
    ASSERT(!(array.bufSize % 16));
1672
    if (!makeContextCurrent())
1666
    if (!makeContextCurrent())
Lines 1675-1681 void GraphicsContextGLOpenGL::uniformMatrix4fv(GCGLint location, GCGLboolean tra a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec125
1675
    gl::UniformMatrix4fv(location, array.bufSize / 16, transpose, array.data);
1669
    gl::UniformMatrix4fv(location, array.bufSize / 16, transpose, array.data);
1676
}
1670
}
1677
1671
1678
void GraphicsContextGLOpenGL::useProgram(PlatformGLObject program)
1672
void GraphicsContextGLANGLE::useProgram(PlatformGLObject program)
1679
{
1673
{
1680
    if (!makeContextCurrent())
1674
    if (!makeContextCurrent())
1681
        return;
1675
        return;
Lines 1683-1689 void GraphicsContextGLOpenGL::useProgram(PlatformGLObject program) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec126
1683
    gl::UseProgram(program);
1677
    gl::UseProgram(program);
1684
}
1678
}
1685
1679
1686
void GraphicsContextGLOpenGL::validateProgram(PlatformGLObject program)
1680
void GraphicsContextGLANGLE::validateProgram(PlatformGLObject program)
1687
{
1681
{
1688
    ASSERT(program);
1682
    ASSERT(program);
1689
1683
Lines 1693-1699 void GraphicsContextGLOpenGL::validateProgram(PlatformGLObject program) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec127
1693
    gl::ValidateProgram(program);
1687
    gl::ValidateProgram(program);
1694
}
1688
}
1695
1689
1696
void GraphicsContextGLOpenGL::vertexAttrib1f(GCGLuint index, GCGLfloat v0)
1690
void GraphicsContextGLANGLE::vertexAttrib1f(GCGLuint index, GCGLfloat v0)
1697
{
1691
{
1698
    if (!makeContextCurrent())
1692
    if (!makeContextCurrent())
1699
        return;
1693
        return;
Lines 1701-1707 void GraphicsContextGLOpenGL::vertexAttrib1f(GCGLuint index, GCGLfloat v0) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec128
1701
    gl::VertexAttrib1f(index, v0);
1695
    gl::VertexAttrib1f(index, v0);
1702
}
1696
}
1703
1697
1704
void GraphicsContextGLOpenGL::vertexAttrib1fv(GCGLuint index, GCGLSpan<const GCGLfloat, 1> array)
1698
void GraphicsContextGLANGLE::vertexAttrib1fv(GCGLuint index, GCGLSpan<const GCGLfloat, 1> array)
1705
{
1699
{
1706
    if (!makeContextCurrent())
1700
    if (!makeContextCurrent())
1707
        return;
1701
        return;
Lines 1709-1715 void GraphicsContextGLOpenGL::vertexAttrib1fv(GCGLuint index, GCGLSpan<const GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec129
1709
    gl::VertexAttrib1fv(index, array.data);
1703
    gl::VertexAttrib1fv(index, array.data);
1710
}
1704
}
1711
1705
1712
void GraphicsContextGLOpenGL::vertexAttrib2f(GCGLuint index, GCGLfloat v0, GCGLfloat v1)
1706
void GraphicsContextGLANGLE::vertexAttrib2f(GCGLuint index, GCGLfloat v0, GCGLfloat v1)
1713
{
1707
{
1714
    if (!makeContextCurrent())
1708
    if (!makeContextCurrent())
1715
        return;
1709
        return;
Lines 1717-1723 void GraphicsContextGLOpenGL::vertexAttrib2f(GCGLuint index, GCGLfloat v0, GCGLf a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec130
1717
    gl::VertexAttrib2f(index, v0, v1);
1711
    gl::VertexAttrib2f(index, v0, v1);
1718
}
1712
}
1719
1713
1720
void GraphicsContextGLOpenGL::vertexAttrib2fv(GCGLuint index, GCGLSpan<const GCGLfloat, 2> array)
1714
void GraphicsContextGLANGLE::vertexAttrib2fv(GCGLuint index, GCGLSpan<const GCGLfloat, 2> array)
1721
{
1715
{
1722
    if (!makeContextCurrent())
1716
    if (!makeContextCurrent())
1723
        return;
1717
        return;
Lines 1725-1731 void GraphicsContextGLOpenGL::vertexAttrib2fv(GCGLuint index, GCGLSpan<const GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec131
1725
    gl::VertexAttrib2fv(index, array.data);
1719
    gl::VertexAttrib2fv(index, array.data);
1726
}
1720
}
1727
1721
1728
void GraphicsContextGLOpenGL::vertexAttrib3f(GCGLuint index, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2)
1722
void GraphicsContextGLANGLE::vertexAttrib3f(GCGLuint index, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2)
1729
{
1723
{
1730
    if (!makeContextCurrent())
1724
    if (!makeContextCurrent())
1731
        return;
1725
        return;
Lines 1733-1739 void GraphicsContextGLOpenGL::vertexAttrib3f(GCGLuint index, GCGLfloat v0, GCGLf a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec132
1733
    gl::VertexAttrib3f(index, v0, v1, v2);
1727
    gl::VertexAttrib3f(index, v0, v1, v2);
1734
}
1728
}
1735
1729
1736
void GraphicsContextGLOpenGL::vertexAttrib3fv(GCGLuint index, GCGLSpan<const GCGLfloat, 3> array)
1730
void GraphicsContextGLANGLE::vertexAttrib3fv(GCGLuint index, GCGLSpan<const GCGLfloat, 3> array)
1737
{
1731
{
1738
    if (!makeContextCurrent())
1732
    if (!makeContextCurrent())
1739
        return;
1733
        return;
Lines 1741-1747 void GraphicsContextGLOpenGL::vertexAttrib3fv(GCGLuint index, GCGLSpan<const GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec133
1741
    gl::VertexAttrib3fv(index, array.data);
1735
    gl::VertexAttrib3fv(index, array.data);
1742
}
1736
}
1743
1737
1744
void GraphicsContextGLOpenGL::vertexAttrib4f(GCGLuint index, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2, GCGLfloat v3)
1738
void GraphicsContextGLANGLE::vertexAttrib4f(GCGLuint index, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2, GCGLfloat v3)
1745
{
1739
{
1746
    if (!makeContextCurrent())
1740
    if (!makeContextCurrent())
1747
        return;
1741
        return;
Lines 1749-1755 void GraphicsContextGLOpenGL::vertexAttrib4f(GCGLuint index, GCGLfloat v0, GCGLf a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec134
1749
    gl::VertexAttrib4f(index, v0, v1, v2, v3);
1743
    gl::VertexAttrib4f(index, v0, v1, v2, v3);
1750
}
1744
}
1751
1745
1752
void GraphicsContextGLOpenGL::vertexAttrib4fv(GCGLuint index, GCGLSpan<const GCGLfloat, 4> array)
1746
void GraphicsContextGLANGLE::vertexAttrib4fv(GCGLuint index, GCGLSpan<const GCGLfloat, 4> array)
1753
{
1747
{
1754
    if (!makeContextCurrent())
1748
    if (!makeContextCurrent())
1755
        return;
1749
        return;
Lines 1757-1763 void GraphicsContextGLOpenGL::vertexAttrib4fv(GCGLuint index, GCGLSpan<const GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec135
1757
    gl::VertexAttrib4fv(index, array.data);
1751
    gl::VertexAttrib4fv(index, array.data);
1758
}
1752
}
1759
1753
1760
void GraphicsContextGLOpenGL::vertexAttribPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLboolean normalized, GCGLsizei stride, GCGLintptr offset)
1754
void GraphicsContextGLANGLE::vertexAttribPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLboolean normalized, GCGLsizei stride, GCGLintptr offset)
1761
{
1755
{
1762
    if (!makeContextCurrent())
1756
    if (!makeContextCurrent())
1763
        return;
1757
        return;
Lines 1765-1771 void GraphicsContextGLOpenGL::vertexAttribPointer(GCGLuint index, GCGLint size, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec136
1765
    gl::VertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
1759
    gl::VertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
1766
}
1760
}
1767
1761
1768
void GraphicsContextGLOpenGL::vertexAttribIPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLsizei stride, GCGLintptr offset)
1762
void GraphicsContextGLANGLE::vertexAttribIPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLsizei stride, GCGLintptr offset)
1769
{
1763
{
1770
    if (!makeContextCurrent())
1764
    if (!makeContextCurrent())
1771
        return;
1765
        return;
Lines 1773-1779 void GraphicsContextGLOpenGL::vertexAttribIPointer(GCGLuint index, GCGLint size, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec137
1773
    gl::VertexAttribIPointer(index, size, type, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
1767
    gl::VertexAttribIPointer(index, size, type, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
1774
}
1768
}
1775
1769
1776
void GraphicsContextGLOpenGL::viewport(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1770
void GraphicsContextGLANGLE::viewport(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1777
{
1771
{
1778
    if (!makeContextCurrent())
1772
    if (!makeContextCurrent())
1779
        return;
1773
        return;
Lines 1781-1787 void GraphicsContextGLOpenGL::viewport(GCGLint x, GCGLint y, GCGLsizei width, GC a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec138
1781
    gl::Viewport(x, y, width, height);
1775
    gl::Viewport(x, y, width, height);
1782
}
1776
}
1783
1777
1784
PlatformGLObject GraphicsContextGLOpenGL::createVertexArray()
1778
PlatformGLObject GraphicsContextGLANGLE::createVertexArray()
1785
{
1779
{
1786
    if (!makeContextCurrent())
1780
    if (!makeContextCurrent())
1787
        return 0;
1781
        return 0;
Lines 1794-1800 PlatformGLObject GraphicsContextGLOpenGL::createVertexArray() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec139
1794
    return array;
1788
    return array;
1795
}
1789
}
1796
1790
1797
void GraphicsContextGLOpenGL::deleteVertexArray(PlatformGLObject array)
1791
void GraphicsContextGLANGLE::deleteVertexArray(PlatformGLObject array)
1798
{
1792
{
1799
    if (!array)
1793
    if (!array)
1800
        return;
1794
        return;
Lines 1806-1812 void GraphicsContextGLOpenGL::deleteVertexArray(PlatformGLObject array) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec140
1806
        gl::DeleteVertexArraysOES(1, &array);
1800
        gl::DeleteVertexArraysOES(1, &array);
1807
}
1801
}
1808
1802
1809
GCGLboolean GraphicsContextGLOpenGL::isVertexArray(PlatformGLObject array)
1803
GCGLboolean GraphicsContextGLANGLE::isVertexArray(PlatformGLObject array)
1810
{
1804
{
1811
    if (!array)
1805
    if (!array)
1812
        return GL_FALSE;
1806
        return GL_FALSE;
Lines 1818-1824 GCGLboolean GraphicsContextGLOpenGL::isVertexArray(PlatformGLObject array) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec141
1818
    return gl::IsVertexArrayOES(array);
1812
    return gl::IsVertexArrayOES(array);
1819
}
1813
}
1820
1814
1821
void GraphicsContextGLOpenGL::bindVertexArray(PlatformGLObject array)
1815
void GraphicsContextGLANGLE::bindVertexArray(PlatformGLObject array)
1822
{
1816
{
1823
    if (!makeContextCurrent())
1817
    if (!makeContextCurrent())
1824
        return;
1818
        return;
Lines 1828-1834 void GraphicsContextGLOpenGL::bindVertexArray(PlatformGLObject array) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec142
1828
        gl::BindVertexArrayOES(array);
1822
        gl::BindVertexArrayOES(array);
1829
}
1823
}
1830
1824
1831
void GraphicsContextGLOpenGL::getBooleanv(GCGLenum pname, GCGLSpan<GCGLboolean> value)
1825
void GraphicsContextGLANGLE::getBooleanv(GCGLenum pname, GCGLSpan<GCGLboolean> value)
1832
{
1826
{
1833
    if (!makeContextCurrent())
1827
    if (!makeContextCurrent())
1834
        return;
1828
        return;
Lines 1836-1842 void GraphicsContextGLOpenGL::getBooleanv(GCGLenum pname, GCGLSpan<GCGLboolean> a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec143
1836
    gl::GetBooleanvRobustANGLE(pname, value.bufSize, nullptr, value.data);
1830
    gl::GetBooleanvRobustANGLE(pname, value.bufSize, nullptr, value.data);
1837
}
1831
}
1838
1832
1839
GCGLint GraphicsContextGLOpenGL::getBufferParameteri(GCGLenum target, GCGLenum pname)
1833
GCGLint GraphicsContextGLANGLE::getBufferParameteri(GCGLenum target, GCGLenum pname)
1840
{
1834
{
1841
    GCGLint value = 0;
1835
    GCGLint value = 0;
1842
    if (!makeContextCurrent())
1836
    if (!makeContextCurrent())
Lines 1845-1851 GCGLint GraphicsContextGLOpenGL::getBufferParameteri(GCGLenum target, GCGLenum p a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec144
1845
    return value;
1839
    return value;
1846
}
1840
}
1847
1841
1848
void GraphicsContextGLOpenGL::getFloatv(GCGLenum pname, GCGLSpan<GCGLfloat> value)
1842
void GraphicsContextGLANGLE::getFloatv(GCGLenum pname, GCGLSpan<GCGLfloat> value)
1849
{
1843
{
1850
    if (!makeContextCurrent())
1844
    if (!makeContextCurrent())
1851
        return;
1845
        return;
Lines 1853-1859 void GraphicsContextGLOpenGL::getFloatv(GCGLenum pname, GCGLSpan<GCGLfloat> valu a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec145
1853
    gl::GetFloatvRobustANGLE(pname, value.bufSize, nullptr, value.data);
1847
    gl::GetFloatvRobustANGLE(pname, value.bufSize, nullptr, value.data);
1854
}
1848
}
1855
    
1849
    
1856
GCGLint64 GraphicsContextGLOpenGL::getInteger64(GCGLenum pname)
1850
GCGLint64 GraphicsContextGLANGLE::getInteger64(GCGLenum pname)
1857
{
1851
{
1858
    GCGLint64 value = 0;
1852
    GCGLint64 value = 0;
1859
    if (!makeContextCurrent())
1853
    if (!makeContextCurrent())
Lines 1862-1868 GCGLint64 GraphicsContextGLOpenGL::getInteger64(GCGLenum pname) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec146
1862
    return value;
1856
    return value;
1863
}
1857
}
1864
1858
1865
GCGLint64 GraphicsContextGLOpenGL::getInteger64i(GCGLenum pname, GCGLuint index)
1859
GCGLint64 GraphicsContextGLANGLE::getInteger64i(GCGLenum pname, GCGLuint index)
1866
{
1860
{
1867
    GCGLint64 value = 0;
1861
    GCGLint64 value = 0;
1868
    if (!makeContextCurrent())
1862
    if (!makeContextCurrent())
Lines 1871-1877 GCGLint64 GraphicsContextGLOpenGL::getInteger64i(GCGLenum pname, GCGLuint index) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec147
1871
    return value;
1865
    return value;
1872
}
1866
}
1873
1867
1874
GCGLint GraphicsContextGLOpenGL::getFramebufferAttachmentParameteri(GCGLenum target, GCGLenum attachment, GCGLenum pname)
1868
GCGLint GraphicsContextGLANGLE::getFramebufferAttachmentParameteri(GCGLenum target, GCGLenum attachment, GCGLenum pname)
1875
{
1869
{
1876
    GCGLint value = 0;
1870
    GCGLint value = 0;
1877
    if (!makeContextCurrent())
1871
    if (!makeContextCurrent())
Lines 1882-1888 GCGLint GraphicsContextGLOpenGL::getFramebufferAttachmentParameteri(GCGLenum tar a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec148
1882
    return value;
1876
    return value;
1883
}
1877
}
1884
1878
1885
GCGLint GraphicsContextGLOpenGL::getProgrami(PlatformGLObject program, GCGLenum pname)
1879
GCGLint GraphicsContextGLANGLE::getProgrami(PlatformGLObject program, GCGLenum pname)
1886
{
1880
{
1887
    GCGLint value = 0;
1881
    GCGLint value = 0;
1888
    if (!makeContextCurrent())
1882
    if (!makeContextCurrent())
Lines 1891-1897 GCGLint GraphicsContextGLOpenGL::getProgrami(PlatformGLObject program, GCGLenum a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec149
1891
    return value;
1885
    return value;
1892
}
1886
}
1893
1887
1894
String GraphicsContextGLOpenGL::getUnmangledInfoLog(PlatformGLObject shaders[2], GCGLsizei count, const String& log)
1888
String GraphicsContextGLANGLE::getUnmangledInfoLog(PlatformGLObject shaders[2], GCGLsizei count, const String& log)
1895
{
1889
{
1896
    UNUSED_PARAM(shaders);
1890
    UNUSED_PARAM(shaders);
1897
    UNUSED_PARAM(count);
1891
    UNUSED_PARAM(count);
Lines 1911-1917 String GraphicsContextGLOpenGL::getUnmangledInfoLog(PlatformGLObject shaders[2], a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec150
1911
    return processedLog.toString();
1905
    return processedLog.toString();
1912
}
1906
}
1913
1907
1914
String GraphicsContextGLOpenGL::getProgramInfoLog(PlatformGLObject program)
1908
String GraphicsContextGLANGLE::getProgramInfoLog(PlatformGLObject program)
1915
{
1909
{
1916
    ASSERT(program);
1910
    ASSERT(program);
1917
1911
Lines 1934-1940 String GraphicsContextGLOpenGL::getProgramInfoLog(PlatformGLObject program) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec151
1934
    return getUnmangledInfoLog(shaders, count, String(info.data(), size));
1928
    return getUnmangledInfoLog(shaders, count, String(info.data(), size));
1935
}
1929
}
1936
1930
1937
GCGLint GraphicsContextGLOpenGL::getRenderbufferParameteri(GCGLenum target, GCGLenum pname)
1931
GCGLint GraphicsContextGLANGLE::getRenderbufferParameteri(GCGLenum target, GCGLenum pname)
1938
{
1932
{
1939
    GCGLint value = 0;
1933
    GCGLint value = 0;
1940
    if (!makeContextCurrent())
1934
    if (!makeContextCurrent())
Lines 1943-1949 GCGLint GraphicsContextGLOpenGL::getRenderbufferParameteri(GCGLenum target, GCGL a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec152
1943
    return value;
1937
    return value;
1944
}
1938
}
1945
1939
1946
GCGLint GraphicsContextGLOpenGL::getShaderi(PlatformGLObject shader, GCGLenum pname)
1940
GCGLint GraphicsContextGLANGLE::getShaderi(PlatformGLObject shader, GCGLenum pname)
1947
{
1941
{
1948
    ASSERT(shader);
1942
    ASSERT(shader);
1949
    GCGLint value = 0;
1943
    GCGLint value = 0;
Lines 1953-1959 GCGLint GraphicsContextGLOpenGL::getShaderi(PlatformGLObject shader, GCGLenum pn a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec153
1953
    return value;
1947
    return value;
1954
}
1948
}
1955
1949
1956
String GraphicsContextGLOpenGL::getShaderInfoLog(PlatformGLObject shader)
1950
String GraphicsContextGLANGLE::getShaderInfoLog(PlatformGLObject shader)
1957
{
1951
{
1958
    ASSERT(shader);
1952
    ASSERT(shader);
1959
1953
Lines 1973-1984 String GraphicsContextGLOpenGL::getShaderInfoLog(PlatformGLObject shader) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec154
1973
    return getUnmangledInfoLog(shaders, 1, String(info.data(), size));
1967
    return getUnmangledInfoLog(shaders, 1, String(info.data(), size));
1974
}
1968
}
1975
1969
1976
String GraphicsContextGLOpenGL::getShaderSource(PlatformGLObject)
1970
String GraphicsContextGLANGLE::getShaderSource(PlatformGLObject)
1977
{
1971
{
1978
    return emptyString();
1972
    return emptyString();
1979
}
1973
}
1980
1974
1981
GCGLfloat GraphicsContextGLOpenGL::getTexParameterf(GCGLenum target, GCGLenum pname)
1975
GCGLfloat GraphicsContextGLANGLE::getTexParameterf(GCGLenum target, GCGLenum pname)
1982
{
1976
{
1983
    GCGLfloat value = 0.f;
1977
    GCGLfloat value = 0.f;
1984
    if (!makeContextCurrent())
1978
    if (!makeContextCurrent())
Lines 1987-1993 GCGLfloat GraphicsContextGLOpenGL::getTexParameterf(GCGLenum target, GCGLenum pn a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec155
1987
    return value;
1981
    return value;
1988
}
1982
}
1989
1983
1990
GCGLint GraphicsContextGLOpenGL::getTexParameteri(GCGLenum target, GCGLenum pname)
1984
GCGLint GraphicsContextGLANGLE::getTexParameteri(GCGLenum target, GCGLenum pname)
1991
{
1985
{
1992
    GCGLint value = 0;
1986
    GCGLint value = 0;
1993
    if (!makeContextCurrent())
1987
    if (!makeContextCurrent())
Lines 1996-2002 GCGLint GraphicsContextGLOpenGL::getTexParameteri(GCGLenum target, GCGLenum pnam a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec156
1996
    return value;
1990
    return value;
1997
}
1991
}
1998
1992
1999
void GraphicsContextGLOpenGL::getUniformfv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLfloat> value)
1993
void GraphicsContextGLANGLE::getUniformfv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLfloat> value)
2000
{
1994
{
2001
    if (!makeContextCurrent())
1995
    if (!makeContextCurrent())
2002
        return;
1996
        return;
Lines 2005-2011 void GraphicsContextGLOpenGL::getUniformfv(PlatformGLObject program, GCGLint loc a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec157
2005
    gl::GetUniformfvRobustANGLE(program, location, bufSize, nullptr, value.data);
1999
    gl::GetUniformfvRobustANGLE(program, location, bufSize, nullptr, value.data);
2006
}
2000
}
2007
2001
2008
void GraphicsContextGLOpenGL::getUniformiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLint> value)
2002
void GraphicsContextGLANGLE::getUniformiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLint> value)
2009
{
2003
{
2010
    if (!makeContextCurrent())
2004
    if (!makeContextCurrent())
2011
        return;
2005
        return;
Lines 2014-2020 void GraphicsContextGLOpenGL::getUniformiv(PlatformGLObject program, GCGLint loc a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec158
2014
    gl::GetUniformivRobustANGLE(program, location, bufSize, nullptr, value.data);
2008
    gl::GetUniformivRobustANGLE(program, location, bufSize, nullptr, value.data);
2015
}
2009
}
2016
2010
2017
void GraphicsContextGLOpenGL::getUniformuiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLuint> value)
2011
void GraphicsContextGLANGLE::getUniformuiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLuint> value)
2018
{
2012
{
2019
    if (!makeContextCurrent())
2013
    if (!makeContextCurrent())
2020
        return;
2014
        return;
Lines 2023-2029 void GraphicsContextGLOpenGL::getUniformuiv(PlatformGLObject program, GCGLint lo a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec159
2023
    gl::GetUniformuivRobustANGLE(program, location, bufSize, nullptr, value.data);
2017
    gl::GetUniformuivRobustANGLE(program, location, bufSize, nullptr, value.data);
2024
}
2018
}
2025
2019
2026
GCGLint GraphicsContextGLOpenGL::getUniformLocation(PlatformGLObject program, const String& name)
2020
GCGLint GraphicsContextGLANGLE::getUniformLocation(PlatformGLObject program, const String& name)
2027
{
2021
{
2028
    ASSERT(program);
2022
    ASSERT(program);
2029
2023
Lines 2033-2039 GCGLint GraphicsContextGLOpenGL::getUniformLocation(PlatformGLObject program, co a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec160
2033
    return gl::GetUniformLocation(program, name.utf8().data());
2027
    return gl::GetUniformLocation(program, name.utf8().data());
2034
}
2028
}
2035
2029
2036
GCGLsizeiptr GraphicsContextGLOpenGL::getVertexAttribOffset(GCGLuint index, GCGLenum pname)
2030
GCGLsizeiptr GraphicsContextGLANGLE::getVertexAttribOffset(GCGLuint index, GCGLenum pname)
2037
{
2031
{
2038
    if (!makeContextCurrent())
2032
    if (!makeContextCurrent())
2039
        return 0;
2033
        return 0;
Lines 2043-2049 GCGLsizeiptr GraphicsContextGLOpenGL::getVertexAttribOffset(GCGLuint index, GCGL a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec161
2043
    return static_cast<GCGLsizeiptr>(reinterpret_cast<intptr_t>(pointer));
2037
    return static_cast<GCGLsizeiptr>(reinterpret_cast<intptr_t>(pointer));
2044
}
2038
}
2045
2039
2046
PlatformGLObject GraphicsContextGLOpenGL::createBuffer()
2040
PlatformGLObject GraphicsContextGLANGLE::createBuffer()
2047
{
2041
{
2048
    if (!makeContextCurrent())
2042
    if (!makeContextCurrent())
2049
        return 0;
2043
        return 0;
Lines 2053-2059 PlatformGLObject GraphicsContextGLOpenGL::createBuffer() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec162
2053
    return o;
2047
    return o;
2054
}
2048
}
2055
2049
2056
PlatformGLObject GraphicsContextGLOpenGL::createFramebuffer()
2050
PlatformGLObject GraphicsContextGLANGLE::createFramebuffer()
2057
{
2051
{
2058
    if (!makeContextCurrent())
2052
    if (!makeContextCurrent())
2059
        return 0;
2053
        return 0;
Lines 2063-2069 PlatformGLObject GraphicsContextGLOpenGL::createFramebuffer() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec163
2063
    return o;
2057
    return o;
2064
}
2058
}
2065
2059
2066
PlatformGLObject GraphicsContextGLOpenGL::createProgram()
2060
PlatformGLObject GraphicsContextGLANGLE::createProgram()
2067
{
2061
{
2068
    if (!makeContextCurrent())
2062
    if (!makeContextCurrent())
2069
        return 0;
2063
        return 0;
Lines 2071-2077 PlatformGLObject GraphicsContextGLOpenGL::createProgram() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec164
2071
    return gl::CreateProgram();
2065
    return gl::CreateProgram();
2072
}
2066
}
2073
2067
2074
PlatformGLObject GraphicsContextGLOpenGL::createRenderbuffer()
2068
PlatformGLObject GraphicsContextGLANGLE::createRenderbuffer()
2075
{
2069
{
2076
    if (!makeContextCurrent())
2070
    if (!makeContextCurrent())
2077
        return 0;
2071
        return 0;
Lines 2081-2087 PlatformGLObject GraphicsContextGLOpenGL::createRenderbuffer() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec165
2081
    return o;
2075
    return o;
2082
}
2076
}
2083
2077
2084
PlatformGLObject GraphicsContextGLOpenGL::createShader(GCGLenum type)
2078
PlatformGLObject GraphicsContextGLANGLE::createShader(GCGLenum type)
2085
{
2079
{
2086
    if (!makeContextCurrent())
2080
    if (!makeContextCurrent())
2087
        return 0;
2081
        return 0;
Lines 2089-2095 PlatformGLObject GraphicsContextGLOpenGL::createShader(GCGLenum type) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec166
2089
    return gl::CreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
2083
    return gl::CreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
2090
}
2084
}
2091
2085
2092
PlatformGLObject GraphicsContextGLOpenGL::createTexture()
2086
PlatformGLObject GraphicsContextGLANGLE::createTexture()
2093
{
2087
{
2094
    if (!makeContextCurrent())
2088
    if (!makeContextCurrent())
2095
        return 0;
2089
        return 0;
Lines 2100-2106 PlatformGLObject GraphicsContextGLOpenGL::createTexture() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec167
2100
    return o;
2094
    return o;
2101
}
2095
}
2102
2096
2103
void GraphicsContextGLOpenGL::deleteBuffer(PlatformGLObject buffer)
2097
void GraphicsContextGLANGLE::deleteBuffer(PlatformGLObject buffer)
2104
{
2098
{
2105
    if (!makeContextCurrent())
2099
    if (!makeContextCurrent())
2106
        return;
2100
        return;
Lines 2108-2114 void GraphicsContextGLOpenGL::deleteBuffer(PlatformGLObject buffer) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec168
2108
    gl::DeleteBuffers(1, &buffer);
2102
    gl::DeleteBuffers(1, &buffer);
2109
}
2103
}
2110
2104
2111
void GraphicsContextGLOpenGL::deleteFramebuffer(PlatformGLObject framebuffer)
2105
void GraphicsContextGLANGLE::deleteFramebuffer(PlatformGLObject framebuffer)
2112
{
2106
{
2113
    if (!makeContextCurrent())
2107
    if (!makeContextCurrent())
2114
        return;
2108
        return;
Lines 2125-2131 void GraphicsContextGLOpenGL::deleteFramebuffer(PlatformGLObject framebuffer) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec169
2125
    gl::DeleteFramebuffers(1, &framebuffer);
2119
    gl::DeleteFramebuffers(1, &framebuffer);
2126
}
2120
}
2127
2121
2128
void GraphicsContextGLOpenGL::deleteProgram(PlatformGLObject program)
2122
void GraphicsContextGLANGLE::deleteProgram(PlatformGLObject program)
2129
{
2123
{
2130
    if (!makeContextCurrent())
2124
    if (!makeContextCurrent())
2131
        return;
2125
        return;
Lines 2133-2139 void GraphicsContextGLOpenGL::deleteProgram(PlatformGLObject program) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec170
2133
    gl::DeleteProgram(program);
2127
    gl::DeleteProgram(program);
2134
}
2128
}
2135
2129
2136
void GraphicsContextGLOpenGL::deleteRenderbuffer(PlatformGLObject renderbuffer)
2130
void GraphicsContextGLANGLE::deleteRenderbuffer(PlatformGLObject renderbuffer)
2137
{
2131
{
2138
    if (!makeContextCurrent())
2132
    if (!makeContextCurrent())
2139
        return;
2133
        return;
Lines 2141-2147 void GraphicsContextGLOpenGL::deleteRenderbuffer(PlatformGLObject renderbuffer) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec171
2141
    gl::DeleteRenderbuffers(1, &renderbuffer);
2135
    gl::DeleteRenderbuffers(1, &renderbuffer);
2142
}
2136
}
2143
2137
2144
void GraphicsContextGLOpenGL::deleteShader(PlatformGLObject shader)
2138
void GraphicsContextGLANGLE::deleteShader(PlatformGLObject shader)
2145
{
2139
{
2146
    if (!makeContextCurrent())
2140
    if (!makeContextCurrent())
2147
        return;
2141
        return;
Lines 2149-2155 void GraphicsContextGLOpenGL::deleteShader(PlatformGLObject shader) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec172
2149
    gl::DeleteShader(shader);
2143
    gl::DeleteShader(shader);
2150
}
2144
}
2151
2145
2152
void GraphicsContextGLOpenGL::deleteTexture(PlatformGLObject texture)
2146
void GraphicsContextGLANGLE::deleteTexture(PlatformGLObject texture)
2153
{
2147
{
2154
    if (!makeContextCurrent())
2148
    if (!makeContextCurrent())
2155
        return;
2149
        return;
Lines 2161-2167 void GraphicsContextGLOpenGL::deleteTexture(PlatformGLObject texture) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec173
2161
    m_state.textureSeedCount.removeAll(texture);
2155
    m_state.textureSeedCount.removeAll(texture);
2162
}
2156
}
2163
2157
2164
void GraphicsContextGLOpenGL::synthesizeGLError(GCGLenum error)
2158
void GraphicsContextGLANGLE::synthesizeGLError(GCGLenum error)
2165
{
2159
{
2166
    // Need to move the current errors to the synthetic error list to
2160
    // Need to move the current errors to the synthetic error list to
2167
    // preserve the order of errors, so a caller to getError will get
2161
    // preserve the order of errors, so a caller to getError will get
Lines 2170-2194 void GraphicsContextGLOpenGL::synthesizeGLError(GCGLenum error) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec174
2170
    m_syntheticErrors.add(error);
2164
    m_syntheticErrors.add(error);
2171
}
2165
}
2172
2166
2173
void GraphicsContextGLOpenGL::forceContextLost()
2167
void GraphicsContextGLANGLE::forceContextLost()
2174
{
2168
{
2175
    for (auto* client : copyToVector(m_clients))
2169
    for (auto* client : copyToVector(m_clients))
2176
        client->forceContextLost();
2170
        client->forceContextLost();
2177
}
2171
}
2178
2172
2179
void GraphicsContextGLOpenGL::recycleContext()
2173
void GraphicsContextGLANGLE::recycleContext()
2180
{
2174
{
2181
    for (auto* client : copyToVector(m_clients))
2175
    for (auto* client : copyToVector(m_clients))
2182
        client->recycleContext();
2176
        client->recycleContext();
2183
}
2177
}
2184
2178
2185
void GraphicsContextGLOpenGL::dispatchContextChangedNotification()
2179
void GraphicsContextGLANGLE::dispatchContextChangedNotification()
2186
{
2180
{
2187
    for (auto* client : copyToVector(m_clients))
2181
    for (auto* client : copyToVector(m_clients))
2188
        client->dispatchContextChangedNotification();
2182
        client->dispatchContextChangedNotification();
2189
}
2183
}
2190
2184
2191
void GraphicsContextGLOpenGL::drawArraysInstanced(GCGLenum mode, GCGLint first, GCGLsizei count, GCGLsizei primcount)
2185
void GraphicsContextGLANGLE::drawArraysInstanced(GCGLenum mode, GCGLint first, GCGLsizei count, GCGLsizei primcount)
2192
{
2186
{
2193
    if (!makeContextCurrent())
2187
    if (!makeContextCurrent())
2194
        return;
2188
        return;
Lines 2200-2206 void GraphicsContextGLOpenGL::drawArraysInstanced(GCGLenum mode, GCGLint first, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec175
2200
    checkGPUStatus();
2194
    checkGPUStatus();
2201
}
2195
}
2202
2196
2203
void GraphicsContextGLOpenGL::drawElementsInstanced(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset, GCGLsizei primcount)
2197
void GraphicsContextGLANGLE::drawElementsInstanced(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset, GCGLsizei primcount)
2204
{
2198
{
2205
    if (!makeContextCurrent())
2199
    if (!makeContextCurrent())
2206
        return;
2200
        return;
Lines 2212-2218 void GraphicsContextGLOpenGL::drawElementsInstanced(GCGLenum mode, GCGLsizei cou a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec176
2212
    checkGPUStatus();
2206
    checkGPUStatus();
2213
}
2207
}
2214
2208
2215
void GraphicsContextGLOpenGL::vertexAttribDivisor(GCGLuint index, GCGLuint divisor)
2209
void GraphicsContextGLANGLE::vertexAttribDivisor(GCGLuint index, GCGLuint divisor)
2216
{
2210
{
2217
    if (!makeContextCurrent())
2211
    if (!makeContextCurrent())
2218
        return;
2212
        return;
Lines 2223-2229 void GraphicsContextGLOpenGL::vertexAttribDivisor(GCGLuint index, GCGLuint divis a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec177
2223
        gl::VertexAttribDivisorANGLE(index, divisor);
2217
        gl::VertexAttribDivisorANGLE(index, divisor);
2224
}
2218
}
2225
2219
2226
GCGLuint GraphicsContextGLOpenGL::getUniformBlockIndex(PlatformGLObject program, const String& uniformBlockName)
2220
GCGLuint GraphicsContextGLANGLE::getUniformBlockIndex(PlatformGLObject program, const String& uniformBlockName)
2227
{
2221
{
2228
    ASSERT(program);
2222
    ASSERT(program);
2229
    if (!makeContextCurrent())
2223
    if (!makeContextCurrent())
Lines 2232-2238 GCGLuint GraphicsContextGLOpenGL::getUniformBlockIndex(PlatformGLObject program, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec178
2232
    return gl::GetUniformBlockIndex(program, uniformBlockName.utf8().data());
2226
    return gl::GetUniformBlockIndex(program, uniformBlockName.utf8().data());
2233
}
2227
}
2234
2228
2235
String GraphicsContextGLOpenGL::getActiveUniformBlockName(PlatformGLObject program, GCGLuint uniformBlockIndex)
2229
String GraphicsContextGLANGLE::getActiveUniformBlockName(PlatformGLObject program, GCGLuint uniformBlockIndex)
2236
{
2230
{
2237
    ASSERT(program);
2231
    ASSERT(program);
2238
    if (!makeContextCurrent())
2232
    if (!makeContextCurrent())
Lines 2252-2258 String GraphicsContextGLOpenGL::getActiveUniformBlockName(PlatformGLObject progr a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec179
2252
    return String(buffer.data(), length);
2246
    return String(buffer.data(), length);
2253
}
2247
}
2254
2248
2255
void GraphicsContextGLOpenGL::uniformBlockBinding(PlatformGLObject program, GCGLuint uniformBlockIndex, GCGLuint uniformBlockBinding)
2249
void GraphicsContextGLANGLE::uniformBlockBinding(PlatformGLObject program, GCGLuint uniformBlockIndex, GCGLuint uniformBlockBinding)
2256
{
2250
{
2257
    ASSERT(program);
2251
    ASSERT(program);
2258
    if (!makeContextCurrent())
2252
    if (!makeContextCurrent())
Lines 2263-2269 void GraphicsContextGLOpenGL::uniformBlockBinding(PlatformGLObject program, GCGL a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec180
2263
2257
2264
// Query Functions
2258
// Query Functions
2265
2259
2266
PlatformGLObject GraphicsContextGLOpenGL::createQuery()
2260
PlatformGLObject GraphicsContextGLANGLE::createQuery()
2267
{
2261
{
2268
    if (!makeContextCurrent())
2262
    if (!makeContextCurrent())
2269
        return 0;
2263
        return 0;
Lines 2273-2279 PlatformGLObject GraphicsContextGLOpenGL::createQuery() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec181
2273
    return name;
2267
    return name;
2274
}
2268
}
2275
2269
2276
void GraphicsContextGLOpenGL::beginQuery(GCGLenum target, PlatformGLObject query)
2270
void GraphicsContextGLANGLE::beginQuery(GCGLenum target, PlatformGLObject query)
2277
{
2271
{
2278
    if (!makeContextCurrent())
2272
    if (!makeContextCurrent())
2279
        return;
2273
        return;
Lines 2281-2287 void GraphicsContextGLOpenGL::beginQuery(GCGLenum target, PlatformGLObject query a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec182
2281
    gl::BeginQuery(target, query);
2275
    gl::BeginQuery(target, query);
2282
}
2276
}
2283
2277
2284
void GraphicsContextGLOpenGL::endQuery(GCGLenum target)
2278
void GraphicsContextGLANGLE::endQuery(GCGLenum target)
2285
{
2279
{
2286
    if (!makeContextCurrent())
2280
    if (!makeContextCurrent())
2287
        return;
2281
        return;
Lines 2289-2295 void GraphicsContextGLOpenGL::endQuery(GCGLenum target) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec183
2289
    gl::EndQuery(target);
2283
    gl::EndQuery(target);
2290
}
2284
}
2291
2285
2292
GCGLuint GraphicsContextGLOpenGL::getQueryObjectui(GCGLuint id, GCGLenum pname)
2286
GCGLuint GraphicsContextGLANGLE::getQueryObjectui(GCGLuint id, GCGLenum pname)
2293
{
2287
{
2294
    GCGLuint value = 0;
2288
    GCGLuint value = 0;
2295
    if (!makeContextCurrent())
2289
    if (!makeContextCurrent())
Lines 2300-2306 GCGLuint GraphicsContextGLOpenGL::getQueryObjectui(GCGLuint id, GCGLenum pname) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec184
2300
2294
2301
// Transform Feedback Functions
2295
// Transform Feedback Functions
2302
2296
2303
PlatformGLObject GraphicsContextGLOpenGL::createTransformFeedback()
2297
PlatformGLObject GraphicsContextGLANGLE::createTransformFeedback()
2304
{
2298
{
2305
    if (!makeContextCurrent())
2299
    if (!makeContextCurrent())
2306
        return 0;
2300
        return 0;
Lines 2310-2316 PlatformGLObject GraphicsContextGLOpenGL::createTransformFeedback() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec185
2310
    return name;
2304
    return name;
2311
}
2305
}
2312
2306
2313
void GraphicsContextGLOpenGL::deleteTransformFeedback(PlatformGLObject transformFeedback)
2307
void GraphicsContextGLANGLE::deleteTransformFeedback(PlatformGLObject transformFeedback)
2314
{
2308
{
2315
    if (!makeContextCurrent())
2309
    if (!makeContextCurrent())
2316
        return;
2310
        return;
Lines 2318-2324 void GraphicsContextGLOpenGL::deleteTransformFeedback(PlatformGLObject transform a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec186
2318
    gl::DeleteTransformFeedbacks(1, &transformFeedback);
2312
    gl::DeleteTransformFeedbacks(1, &transformFeedback);
2319
}
2313
}
2320
2314
2321
GCGLboolean GraphicsContextGLOpenGL::isTransformFeedback(PlatformGLObject transformFeedback)
2315
GCGLboolean GraphicsContextGLANGLE::isTransformFeedback(PlatformGLObject transformFeedback)
2322
{
2316
{
2323
    if (!makeContextCurrent())
2317
    if (!makeContextCurrent())
2324
        return GL_FALSE;
2318
        return GL_FALSE;
Lines 2326-2332 GCGLboolean GraphicsContextGLOpenGL::isTransformFeedback(PlatformGLObject transf a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec187
2326
    return gl::IsTransformFeedback(transformFeedback);
2320
    return gl::IsTransformFeedback(transformFeedback);
2327
}
2321
}
2328
2322
2329
void GraphicsContextGLOpenGL::bindTransformFeedback(GCGLenum target, PlatformGLObject transformFeedback)
2323
void GraphicsContextGLANGLE::bindTransformFeedback(GCGLenum target, PlatformGLObject transformFeedback)
2330
{
2324
{
2331
    if (!makeContextCurrent())
2325
    if (!makeContextCurrent())
2332
        return;
2326
        return;
Lines 2334-2340 void GraphicsContextGLOpenGL::bindTransformFeedback(GCGLenum target, PlatformGLO a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec188
2334
    gl::BindTransformFeedback(target, transformFeedback);
2328
    gl::BindTransformFeedback(target, transformFeedback);
2335
}
2329
}
2336
2330
2337
void GraphicsContextGLOpenGL::beginTransformFeedback(GCGLenum primitiveMode)
2331
void GraphicsContextGLANGLE::beginTransformFeedback(GCGLenum primitiveMode)
2338
{
2332
{
2339
    if (!makeContextCurrent())
2333
    if (!makeContextCurrent())
2340
        return;
2334
        return;
Lines 2342-2348 void GraphicsContextGLOpenGL::beginTransformFeedback(GCGLenum primitiveMode) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec189
2342
    gl::BeginTransformFeedback(primitiveMode);
2336
    gl::BeginTransformFeedback(primitiveMode);
2343
}
2337
}
2344
2338
2345
void GraphicsContextGLOpenGL::endTransformFeedback()
2339
void GraphicsContextGLANGLE::endTransformFeedback()
2346
{
2340
{
2347
    if (!makeContextCurrent())
2341
    if (!makeContextCurrent())
2348
        return;
2342
        return;
Lines 2350-2356 void GraphicsContextGLOpenGL::endTransformFeedback() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec190
2350
    gl::EndTransformFeedback();
2344
    gl::EndTransformFeedback();
2351
}
2345
}
2352
2346
2353
void GraphicsContextGLOpenGL::transformFeedbackVaryings(PlatformGLObject program, const Vector<String>& varyings, GCGLenum bufferMode)
2347
void GraphicsContextGLANGLE::transformFeedbackVaryings(PlatformGLObject program, const Vector<String>& varyings, GCGLenum bufferMode)
2354
{
2348
{
2355
    if (!makeContextCurrent())
2349
    if (!makeContextCurrent())
2356
        return;
2350
        return;
Lines 2365-2377 void GraphicsContextGLOpenGL::transformFeedbackVaryings(PlatformGLObject program a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec191
2365
    gl::TransformFeedbackVaryings(program, pointersToVaryings.size(), pointersToVaryings.data(), bufferMode);
2359
    gl::TransformFeedbackVaryings(program, pointersToVaryings.size(), pointersToVaryings.data(), bufferMode);
2366
}
2360
}
2367
2361
2368
void GraphicsContextGLOpenGL::getTransformFeedbackVarying(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
2362
void GraphicsContextGLANGLE::getTransformFeedbackVarying(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
2369
{
2363
{
2370
    if (!makeContextCurrent())
2364
    if (!makeContextCurrent())
2371
        return;
2365
        return;
2372
2366
2373
    GCGLsizei bufSize = 0;
2367
    GCGLsizei bufSize = 0;
2374
    gl::GetProgramiv(program, GraphicsContextGLOpenGL::TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, &bufSize);
2368
    gl::GetProgramiv(program, GraphicsContextGLANGLE::TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, &bufSize);
2375
    if (!bufSize)
2369
    if (!bufSize)
2376
        return;
2370
        return;
2377
2371
Lines 2387-2393 void GraphicsContextGLOpenGL::getTransformFeedbackVarying(PlatformGLObject progr a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec192
2387
    info.type = type;
2381
    info.type = type;
2388
}
2382
}
2389
2383
2390
void GraphicsContextGLOpenGL::bindBufferBase(GCGLenum target, GCGLuint index, PlatformGLObject buffer)
2384
void GraphicsContextGLANGLE::bindBufferBase(GCGLenum target, GCGLuint index, PlatformGLObject buffer)
2391
{
2385
{
2392
    if (!makeContextCurrent())
2386
    if (!makeContextCurrent())
2393
        return;
2387
        return;
Lines 2395-2401 void GraphicsContextGLOpenGL::bindBufferBase(GCGLenum target, GCGLuint index, Pl a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec193
2395
    gl::BindBufferBase(target, index, buffer);
2389
    gl::BindBufferBase(target, index, buffer);
2396
}
2390
}
2397
2391
2398
void GraphicsContextGLOpenGL::blitFramebuffer(GCGLint srcX0, GCGLint srcY0, GCGLint srcX1, GCGLint srcY1, GCGLint dstX0, GCGLint dstY0, GCGLint dstX1, GCGLint dstY1, GCGLbitfield mask, GCGLenum filter)
2392
void GraphicsContextGLANGLE::blitFramebuffer(GCGLint srcX0, GCGLint srcY0, GCGLint srcX1, GCGLint srcY1, GCGLint dstX0, GCGLint dstY0, GCGLint dstX1, GCGLint dstY1, GCGLbitfield mask, GCGLenum filter)
2399
{
2393
{
2400
    if (!makeContextCurrent())
2394
    if (!makeContextCurrent())
2401
        return;
2395
        return;
Lines 2403-2409 void GraphicsContextGLOpenGL::blitFramebuffer(GCGLint srcX0, GCGLint srcY0, GCGL a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec194
2403
    gl::BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
2397
    gl::BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
2404
}
2398
}
2405
2399
2406
void GraphicsContextGLOpenGL::framebufferTextureLayer(GCGLenum target, GCGLenum attachment, PlatformGLObject texture, GCGLint level, GCGLint layer)
2400
void GraphicsContextGLANGLE::framebufferTextureLayer(GCGLenum target, GCGLenum attachment, PlatformGLObject texture, GCGLint level, GCGLint layer)
2407
{
2401
{
2408
    if (!makeContextCurrent())
2402
    if (!makeContextCurrent())
2409
        return;
2403
        return;
Lines 2411-2417 void GraphicsContextGLOpenGL::framebufferTextureLayer(GCGLenum target, GCGLenum a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec195
2411
    gl::FramebufferTextureLayer(target, attachment, texture, level, layer);
2405
    gl::FramebufferTextureLayer(target, attachment, texture, level, layer);
2412
}
2406
}
2413
2407
2414
void GraphicsContextGLOpenGL::invalidateFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments)
2408
void GraphicsContextGLANGLE::invalidateFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments)
2415
{
2409
{
2416
    if (!makeContextCurrent())
2410
    if (!makeContextCurrent())
2417
        return;
2411
        return;
Lines 2419-2425 void GraphicsContextGLOpenGL::invalidateFramebuffer(GCGLenum target, GCGLSpan<co a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec196
2419
    gl::InvalidateFramebuffer(target, attachments.bufSize, attachments.data);
2413
    gl::InvalidateFramebuffer(target, attachments.bufSize, attachments.data);
2420
}
2414
}
2421
2415
2422
void GraphicsContextGLOpenGL::invalidateSubFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
2416
void GraphicsContextGLANGLE::invalidateSubFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
2423
{
2417
{
2424
    if (!makeContextCurrent())
2418
    if (!makeContextCurrent())
2425
        return;
2419
        return;
Lines 2427-2433 void GraphicsContextGLOpenGL::invalidateSubFramebuffer(GCGLenum target, GCGLSpan a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec197
2427
    gl::InvalidateSubFramebuffer(target, attachments.bufSize, attachments.data, x, y, width, height);
2421
    gl::InvalidateSubFramebuffer(target, attachments.bufSize, attachments.data, x, y, width, height);
2428
}
2422
}
2429
2423
2430
void GraphicsContextGLOpenGL::readBuffer(GCGLenum src)
2424
void GraphicsContextGLANGLE::readBuffer(GCGLenum src)
2431
{
2425
{
2432
    if (!makeContextCurrent())
2426
    if (!makeContextCurrent())
2433
        return;
2427
        return;
Lines 2435-2441 void GraphicsContextGLOpenGL::readBuffer(GCGLenum src) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec198
2435
    gl::ReadBuffer(src);
2429
    gl::ReadBuffer(src);
2436
}
2430
}
2437
2431
2438
void GraphicsContextGLOpenGL::copyTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
2432
void GraphicsContextGLANGLE::copyTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
2439
{
2433
{
2440
    if (!makeContextCurrent())
2434
    if (!makeContextCurrent())
2441
        return;
2435
        return;
Lines 2452-2458 void GraphicsContextGLOpenGL::copyTexSubImage3D(GCGLenum target, GCGLint level, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec199
2452
        gl::BindFramebuffer(framebufferTarget, m_multisampleFBO);
2446
        gl::BindFramebuffer(framebufferTarget, m_multisampleFBO);
2453
}
2447
}
2454
2448
2455
GCGLint GraphicsContextGLOpenGL::getFragDataLocation(PlatformGLObject program, const String& name)
2449
GCGLint GraphicsContextGLANGLE::getFragDataLocation(PlatformGLObject program, const String& name)
2456
{
2450
{
2457
    if (!makeContextCurrent())
2451
    if (!makeContextCurrent())
2458
        return -1;
2452
        return -1;
Lines 2460-2466 GCGLint GraphicsContextGLOpenGL::getFragDataLocation(PlatformGLObject program, c a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec200
2460
    return gl::GetFragDataLocation(program, name.utf8().data());
2454
    return gl::GetFragDataLocation(program, name.utf8().data());
2461
}
2455
}
2462
2456
2463
void GraphicsContextGLOpenGL::uniform1ui(GCGLint location, GCGLuint v0)
2457
void GraphicsContextGLANGLE::uniform1ui(GCGLint location, GCGLuint v0)
2464
{
2458
{
2465
    if (!makeContextCurrent())
2459
    if (!makeContextCurrent())
2466
        return;
2460
        return;
Lines 2468-2474 void GraphicsContextGLOpenGL::uniform1ui(GCGLint location, GCGLuint v0) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec201
2468
    gl::Uniform1ui(location, v0);
2462
    gl::Uniform1ui(location, v0);
2469
}
2463
}
2470
2464
2471
void GraphicsContextGLOpenGL::uniform2ui(GCGLint location, GCGLuint v0, GCGLuint v1)
2465
void GraphicsContextGLANGLE::uniform2ui(GCGLint location, GCGLuint v0, GCGLuint v1)
2472
{
2466
{
2473
    if (!makeContextCurrent())
2467
    if (!makeContextCurrent())
2474
        return;
2468
        return;
Lines 2476-2482 void GraphicsContextGLOpenGL::uniform2ui(GCGLint location, GCGLuint v0, GCGLuint a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec202
2476
    gl::Uniform2ui(location, v0, v1);
2470
    gl::Uniform2ui(location, v0, v1);
2477
}
2471
}
2478
2472
2479
void GraphicsContextGLOpenGL::uniform3ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2)
2473
void GraphicsContextGLANGLE::uniform3ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2)
2480
{
2474
{
2481
    if (!makeContextCurrent())
2475
    if (!makeContextCurrent())
2482
        return;
2476
        return;
Lines 2484-2490 void GraphicsContextGLOpenGL::uniform3ui(GCGLint location, GCGLuint v0, GCGLuint a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec203
2484
    gl::Uniform3ui(location, v0, v1, v2);
2478
    gl::Uniform3ui(location, v0, v1, v2);
2485
}
2479
}
2486
2480
2487
void GraphicsContextGLOpenGL::uniform4ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2, GCGLuint v3)
2481
void GraphicsContextGLANGLE::uniform4ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2, GCGLuint v3)
2488
{
2482
{
2489
    if (!makeContextCurrent())
2483
    if (!makeContextCurrent())
2490
        return;
2484
        return;
Lines 2492-2498 void GraphicsContextGLOpenGL::uniform4ui(GCGLint location, GCGLuint v0, GCGLuint a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec204
2492
    gl::Uniform4ui(location, v0, v1, v2, v3);
2486
    gl::Uniform4ui(location, v0, v1, v2, v3);
2493
}
2487
}
2494
2488
2495
void GraphicsContextGLOpenGL::uniform1uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2489
void GraphicsContextGLANGLE::uniform1uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2496
{
2490
{
2497
    if (!makeContextCurrent())
2491
    if (!makeContextCurrent())
2498
        return;
2492
        return;
Lines 2500-2506 void GraphicsContextGLOpenGL::uniform1uiv(GCGLint location, GCGLSpan<const GCGLu a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec205
2500
    gl::Uniform1uiv(location, data.bufSize, data.data);
2494
    gl::Uniform1uiv(location, data.bufSize, data.data);
2501
}
2495
}
2502
2496
2503
void GraphicsContextGLOpenGL::uniform2uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2497
void GraphicsContextGLANGLE::uniform2uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2504
{
2498
{
2505
    ASSERT(!(data.bufSize % 2));
2499
    ASSERT(!(data.bufSize % 2));
2506
    if (!makeContextCurrent())
2500
    if (!makeContextCurrent())
Lines 2509-2515 void GraphicsContextGLOpenGL::uniform2uiv(GCGLint location, GCGLSpan<const GCGLu a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec206
2509
    gl::Uniform2uiv(location, data.bufSize / 2, data.data);
2503
    gl::Uniform2uiv(location, data.bufSize / 2, data.data);
2510
}
2504
}
2511
2505
2512
void GraphicsContextGLOpenGL::uniform3uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2506
void GraphicsContextGLANGLE::uniform3uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2513
{
2507
{
2514
    ASSERT(!(data.bufSize % 3));
2508
    ASSERT(!(data.bufSize % 3));
2515
    if (!makeContextCurrent())
2509
    if (!makeContextCurrent())
Lines 2518-2524 void GraphicsContextGLOpenGL::uniform3uiv(GCGLint location, GCGLSpan<const GCGLu a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec207
2518
    gl::Uniform3uiv(location, data.bufSize / 3, data.data);
2512
    gl::Uniform3uiv(location, data.bufSize / 3, data.data);
2519
}
2513
}
2520
2514
2521
void GraphicsContextGLOpenGL::uniform4uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2515
void GraphicsContextGLANGLE::uniform4uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2522
{
2516
{
2523
    ASSERT(!(data.bufSize % 4));
2517
    ASSERT(!(data.bufSize % 4));
2524
    if (!makeContextCurrent())
2518
    if (!makeContextCurrent())
Lines 2527-2533 void GraphicsContextGLOpenGL::uniform4uiv(GCGLint location, GCGLSpan<const GCGLu a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec208
2527
    gl::Uniform4uiv(location, data.bufSize / 4, data.data);
2521
    gl::Uniform4uiv(location, data.bufSize / 4, data.data);
2528
}
2522
}
2529
2523
2530
void GraphicsContextGLOpenGL::uniformMatrix2x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2524
void GraphicsContextGLANGLE::uniformMatrix2x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2531
{
2525
{
2532
    ASSERT(!(data.bufSize % 6));
2526
    ASSERT(!(data.bufSize % 6));
2533
    if (!makeContextCurrent())
2527
    if (!makeContextCurrent())
Lines 2536-2542 void GraphicsContextGLOpenGL::uniformMatrix2x3fv(GCGLint location, GCGLboolean t a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec209
2536
    gl::UniformMatrix2x3fv(location, data.bufSize / 6, transpose, data.data);
2530
    gl::UniformMatrix2x3fv(location, data.bufSize / 6, transpose, data.data);
2537
}
2531
}
2538
2532
2539
void GraphicsContextGLOpenGL::uniformMatrix3x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2533
void GraphicsContextGLANGLE::uniformMatrix3x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2540
{
2534
{
2541
    ASSERT(!(data.bufSize % 6));
2535
    ASSERT(!(data.bufSize % 6));
2542
    if (!makeContextCurrent())
2536
    if (!makeContextCurrent())
Lines 2545-2551 void GraphicsContextGLOpenGL::uniformMatrix3x2fv(GCGLint location, GCGLboolean t a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec210
2545
    gl::UniformMatrix3x2fv(location, data.bufSize / 6, transpose, data.data);
2539
    gl::UniformMatrix3x2fv(location, data.bufSize / 6, transpose, data.data);
2546
}
2540
}
2547
2541
2548
void GraphicsContextGLOpenGL::uniformMatrix2x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2542
void GraphicsContextGLANGLE::uniformMatrix2x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2549
{
2543
{
2550
    ASSERT(!(data.bufSize % 8));
2544
    ASSERT(!(data.bufSize % 8));
2551
    if (!makeContextCurrent())
2545
    if (!makeContextCurrent())
Lines 2554-2560 void GraphicsContextGLOpenGL::uniformMatrix2x4fv(GCGLint location, GCGLboolean t a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec211
2554
    gl::UniformMatrix2x4fv(location, data.bufSize / 8, transpose, data.data);
2548
    gl::UniformMatrix2x4fv(location, data.bufSize / 8, transpose, data.data);
2555
}
2549
}
2556
2550
2557
void GraphicsContextGLOpenGL::uniformMatrix4x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2551
void GraphicsContextGLANGLE::uniformMatrix4x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2558
{
2552
{
2559
    ASSERT(!(data.bufSize % 8));
2553
    ASSERT(!(data.bufSize % 8));
2560
    if (!makeContextCurrent())
2554
    if (!makeContextCurrent())
Lines 2563-2569 void GraphicsContextGLOpenGL::uniformMatrix4x2fv(GCGLint location, GCGLboolean t a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec212
2563
    gl::UniformMatrix4x2fv(location, data.bufSize / 8, transpose, data.data);
2557
    gl::UniformMatrix4x2fv(location, data.bufSize / 8, transpose, data.data);
2564
}
2558
}
2565
2559
2566
void GraphicsContextGLOpenGL::uniformMatrix3x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2560
void GraphicsContextGLANGLE::uniformMatrix3x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2567
{
2561
{
2568
    ASSERT(!(data.bufSize % 12));
2562
    ASSERT(!(data.bufSize % 12));
2569
    if (!makeContextCurrent())
2563
    if (!makeContextCurrent())
Lines 2572-2578 void GraphicsContextGLOpenGL::uniformMatrix3x4fv(GCGLint location, GCGLboolean t a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec213
2572
    gl::UniformMatrix3x4fv(location, data.bufSize / 12, transpose, data.data);
2566
    gl::UniformMatrix3x4fv(location, data.bufSize / 12, transpose, data.data);
2573
}
2567
}
2574
2568
2575
void GraphicsContextGLOpenGL::uniformMatrix4x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2569
void GraphicsContextGLANGLE::uniformMatrix4x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2576
{
2570
{
2577
    ASSERT(!(data.bufSize % 12));
2571
    ASSERT(!(data.bufSize % 12));
2578
    if (!makeContextCurrent())
2572
    if (!makeContextCurrent())
Lines 2581-2587 void GraphicsContextGLOpenGL::uniformMatrix4x3fv(GCGLint location, GCGLboolean t a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec214
2581
    gl::UniformMatrix4x3fv(location, data.bufSize / 12, transpose, data.data);
2575
    gl::UniformMatrix4x3fv(location, data.bufSize / 12, transpose, data.data);
2582
}
2576
}
2583
2577
2584
void GraphicsContextGLOpenGL::vertexAttribI4i(GCGLuint index, GCGLint x, GCGLint y, GCGLint z, GCGLint w)
2578
void GraphicsContextGLANGLE::vertexAttribI4i(GCGLuint index, GCGLint x, GCGLint y, GCGLint z, GCGLint w)
2585
{
2579
{
2586
    if (!makeContextCurrent())
2580
    if (!makeContextCurrent())
2587
        return;
2581
        return;
Lines 2589-2595 void GraphicsContextGLOpenGL::vertexAttribI4i(GCGLuint index, GCGLint x, GCGLint a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec215
2589
    gl::VertexAttribI4i(index, x, y, z, w);
2583
    gl::VertexAttribI4i(index, x, y, z, w);
2590
}
2584
}
2591
2585
2592
void GraphicsContextGLOpenGL::vertexAttribI4iv(GCGLuint index, GCGLSpan<const GCGLint, 4> values)
2586
void GraphicsContextGLANGLE::vertexAttribI4iv(GCGLuint index, GCGLSpan<const GCGLint, 4> values)
2593
{
2587
{
2594
    if (!makeContextCurrent())
2588
    if (!makeContextCurrent())
2595
        return;
2589
        return;
Lines 2597-2603 void GraphicsContextGLOpenGL::vertexAttribI4iv(GCGLuint index, GCGLSpan<const GC a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec216
2597
    gl::VertexAttribI4iv(index, values.data);
2591
    gl::VertexAttribI4iv(index, values.data);
2598
}
2592
}
2599
2593
2600
void GraphicsContextGLOpenGL::vertexAttribI4ui(GCGLuint index, GCGLuint x, GCGLuint y, GCGLuint z, GCGLuint w)
2594
void GraphicsContextGLANGLE::vertexAttribI4ui(GCGLuint index, GCGLuint x, GCGLuint y, GCGLuint z, GCGLuint w)
2601
{
2595
{
2602
    if (!makeContextCurrent())
2596
    if (!makeContextCurrent())
2603
        return;
2597
        return;
Lines 2605-2611 void GraphicsContextGLOpenGL::vertexAttribI4ui(GCGLuint index, GCGLuint x, GCGLu a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec217
2605
    gl::VertexAttribI4ui(index, x, y, z, w);
2599
    gl::VertexAttribI4ui(index, x, y, z, w);
2606
}
2600
}
2607
2601
2608
void GraphicsContextGLOpenGL::vertexAttribI4uiv(GCGLuint index, GCGLSpan<const GCGLuint, 4> values)
2602
void GraphicsContextGLANGLE::vertexAttribI4uiv(GCGLuint index, GCGLSpan<const GCGLuint, 4> values)
2609
{
2603
{
2610
    if (!makeContextCurrent())
2604
    if (!makeContextCurrent())
2611
        return;
2605
        return;
Lines 2613-2619 void GraphicsContextGLOpenGL::vertexAttribI4uiv(GCGLuint index, GCGLSpan<const G a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec218
2613
    gl::VertexAttribI4uiv(index, values.data);
2607
    gl::VertexAttribI4uiv(index, values.data);
2614
}
2608
}
2615
2609
2616
void GraphicsContextGLOpenGL::drawRangeElements(GCGLenum mode, GCGLuint start, GCGLuint end, GCGLsizei count, GCGLenum type, GCGLintptr offset)
2610
void GraphicsContextGLANGLE::drawRangeElements(GCGLenum mode, GCGLuint start, GCGLuint end, GCGLsizei count, GCGLenum type, GCGLintptr offset)
2617
{
2611
{
2618
    if (!makeContextCurrent())
2612
    if (!makeContextCurrent())
2619
        return;
2613
        return;
Lines 2621-2627 void GraphicsContextGLOpenGL::drawRangeElements(GCGLenum mode, GCGLuint start, G a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec219
2621
    gl::DrawRangeElements(mode, start, end, count, type, reinterpret_cast<void*>(offset));
2615
    gl::DrawRangeElements(mode, start, end, count, type, reinterpret_cast<void*>(offset));
2622
}
2616
}
2623
2617
2624
void GraphicsContextGLOpenGL::drawBuffers(GCGLSpan<const GCGLenum> bufs)
2618
void GraphicsContextGLANGLE::drawBuffers(GCGLSpan<const GCGLenum> bufs)
2625
{
2619
{
2626
    if (!makeContextCurrent())
2620
    if (!makeContextCurrent())
2627
        return;
2621
        return;
Lines 2629-2635 void GraphicsContextGLOpenGL::drawBuffers(GCGLSpan<const GCGLenum> bufs) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec220
2629
    gl::DrawBuffers(bufs.bufSize, bufs.data);
2623
    gl::DrawBuffers(bufs.bufSize, bufs.data);
2630
}
2624
}
2631
2625
2632
void GraphicsContextGLOpenGL::clearBufferiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLint> values)
2626
void GraphicsContextGLANGLE::clearBufferiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLint> values)
2633
{
2627
{
2634
    if (!makeContextCurrent())
2628
    if (!makeContextCurrent())
2635
        return;
2629
        return;
Lines 2637-2643 void GraphicsContextGLOpenGL::clearBufferiv(GCGLenum buffer, GCGLint drawbuffer, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec221
2637
    gl::ClearBufferiv(buffer, drawbuffer, values.data);
2631
    gl::ClearBufferiv(buffer, drawbuffer, values.data);
2638
}
2632
}
2639
2633
2640
void GraphicsContextGLOpenGL::clearBufferuiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLuint> values)
2634
void GraphicsContextGLANGLE::clearBufferuiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLuint> values)
2641
{
2635
{
2642
    if (!makeContextCurrent())
2636
    if (!makeContextCurrent())
2643
        return;
2637
        return;
Lines 2645-2651 void GraphicsContextGLOpenGL::clearBufferuiv(GCGLenum buffer, GCGLint drawbuffer a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec222
2645
    gl::ClearBufferuiv(buffer, drawbuffer, values.data);
2639
    gl::ClearBufferuiv(buffer, drawbuffer, values.data);
2646
}
2640
}
2647
2641
2648
void GraphicsContextGLOpenGL::clearBufferfv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLfloat> values)
2642
void GraphicsContextGLANGLE::clearBufferfv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLfloat> values)
2649
{
2643
{
2650
    if (!makeContextCurrent())
2644
    if (!makeContextCurrent())
2651
        return;
2645
        return;
Lines 2653-2659 void GraphicsContextGLOpenGL::clearBufferfv(GCGLenum buffer, GCGLint drawbuffer, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec223
2653
    gl::ClearBufferfv(buffer, drawbuffer, values.data);
2647
    gl::ClearBufferfv(buffer, drawbuffer, values.data);
2654
}
2648
}
2655
2649
2656
void GraphicsContextGLOpenGL::clearBufferfi(GCGLenum buffer, GCGLint drawbuffer, GCGLfloat depth, GCGLint stencil)
2650
void GraphicsContextGLANGLE::clearBufferfi(GCGLenum buffer, GCGLint drawbuffer, GCGLfloat depth, GCGLint stencil)
2657
{
2651
{
2658
    if (!makeContextCurrent())
2652
    if (!makeContextCurrent())
2659
        return;
2653
        return;
Lines 2661-2667 void GraphicsContextGLOpenGL::clearBufferfi(GCGLenum buffer, GCGLint drawbuffer, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec224
2661
    gl::ClearBufferfi(buffer, drawbuffer, depth, stencil);
2655
    gl::ClearBufferfi(buffer, drawbuffer, depth, stencil);
2662
}
2656
}
2663
2657
2664
void GraphicsContextGLOpenGL::deleteQuery(PlatformGLObject query)
2658
void GraphicsContextGLANGLE::deleteQuery(PlatformGLObject query)
2665
{
2659
{
2666
    if (!makeContextCurrent())
2660
    if (!makeContextCurrent())
2667
        return;
2661
        return;
Lines 2669-2675 void GraphicsContextGLOpenGL::deleteQuery(PlatformGLObject query) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec225
2669
    gl::DeleteQueries(1, &query);
2663
    gl::DeleteQueries(1, &query);
2670
}
2664
}
2671
2665
2672
GCGLboolean GraphicsContextGLOpenGL::isQuery(PlatformGLObject query)
2666
GCGLboolean GraphicsContextGLANGLE::isQuery(PlatformGLObject query)
2673
{
2667
{
2674
    if (!makeContextCurrent())
2668
    if (!makeContextCurrent())
2675
        return GL_FALSE;
2669
        return GL_FALSE;
Lines 2677-2683 GCGLboolean GraphicsContextGLOpenGL::isQuery(PlatformGLObject query) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec226
2677
    return gl::IsQuery(query);
2671
    return gl::IsQuery(query);
2678
}
2672
}
2679
2673
2680
PlatformGLObject GraphicsContextGLOpenGL::getQuery(GCGLenum target, GCGLenum pname)
2674
PlatformGLObject GraphicsContextGLANGLE::getQuery(GCGLenum target, GCGLenum pname)
2681
{
2675
{
2682
    if (!makeContextCurrent())
2676
    if (!makeContextCurrent())
2683
        return 0;
2677
        return 0;
Lines 2687-2693 PlatformGLObject GraphicsContextGLOpenGL::getQuery(GCGLenum target, GCGLenum pna a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec227
2687
    return static_cast<PlatformGLObject>(value);
2681
    return static_cast<PlatformGLObject>(value);
2688
}
2682
}
2689
2683
2690
PlatformGLObject GraphicsContextGLOpenGL::createSampler()
2684
PlatformGLObject GraphicsContextGLANGLE::createSampler()
2691
{
2685
{
2692
    if (!makeContextCurrent())
2686
    if (!makeContextCurrent())
2693
        return 0;
2687
        return 0;
Lines 2697-2703 PlatformGLObject GraphicsContextGLOpenGL::createSampler() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec228
2697
    return name;
2691
    return name;
2698
}
2692
}
2699
2693
2700
void GraphicsContextGLOpenGL::deleteSampler(PlatformGLObject sampler)
2694
void GraphicsContextGLANGLE::deleteSampler(PlatformGLObject sampler)
2701
{
2695
{
2702
    if (!makeContextCurrent())
2696
    if (!makeContextCurrent())
2703
        return;
2697
        return;
Lines 2705-2711 void GraphicsContextGLOpenGL::deleteSampler(PlatformGLObject sampler) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec229
2705
    gl::DeleteSamplers(1, &sampler);
2699
    gl::DeleteSamplers(1, &sampler);
2706
}
2700
}
2707
2701
2708
GCGLboolean GraphicsContextGLOpenGL::isSampler(PlatformGLObject sampler)
2702
GCGLboolean GraphicsContextGLANGLE::isSampler(PlatformGLObject sampler)
2709
{
2703
{
2710
    if (!makeContextCurrent())
2704
    if (!makeContextCurrent())
2711
        return GL_FALSE;
2705
        return GL_FALSE;
Lines 2713-2719 GCGLboolean GraphicsContextGLOpenGL::isSampler(PlatformGLObject sampler) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec230
2713
    return gl::IsSampler(sampler);
2707
    return gl::IsSampler(sampler);
2714
}
2708
}
2715
2709
2716
void GraphicsContextGLOpenGL::bindSampler(GCGLuint unit, PlatformGLObject sampler)
2710
void GraphicsContextGLANGLE::bindSampler(GCGLuint unit, PlatformGLObject sampler)
2717
{
2711
{
2718
    if (!makeContextCurrent())
2712
    if (!makeContextCurrent())
2719
        return;
2713
        return;
Lines 2721-2727 void GraphicsContextGLOpenGL::bindSampler(GCGLuint unit, PlatformGLObject sample a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec231
2721
    gl::BindSampler(unit, sampler);
2715
    gl::BindSampler(unit, sampler);
2722
}
2716
}
2723
2717
2724
void GraphicsContextGLOpenGL::samplerParameteri(PlatformGLObject sampler, GCGLenum pname, GCGLint param)
2718
void GraphicsContextGLANGLE::samplerParameteri(PlatformGLObject sampler, GCGLenum pname, GCGLint param)
2725
{
2719
{
2726
    if (!makeContextCurrent())
2720
    if (!makeContextCurrent())
2727
        return;
2721
        return;
Lines 2729-2735 void GraphicsContextGLOpenGL::samplerParameteri(PlatformGLObject sampler, GCGLen a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec232
2729
    gl::SamplerParameteri(sampler, pname, param);
2723
    gl::SamplerParameteri(sampler, pname, param);
2730
}
2724
}
2731
2725
2732
void GraphicsContextGLOpenGL::samplerParameterf(PlatformGLObject sampler, GCGLenum pname, GCGLfloat param)
2726
void GraphicsContextGLANGLE::samplerParameterf(PlatformGLObject sampler, GCGLenum pname, GCGLfloat param)
2733
{
2727
{
2734
    if (!makeContextCurrent())
2728
    if (!makeContextCurrent())
2735
        return;
2729
        return;
Lines 2737-2743 void GraphicsContextGLOpenGL::samplerParameterf(PlatformGLObject sampler, GCGLen a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec233
2737
    gl::SamplerParameterf(sampler, pname, param);
2731
    gl::SamplerParameterf(sampler, pname, param);
2738
}
2732
}
2739
2733
2740
GCGLfloat GraphicsContextGLOpenGL::getSamplerParameterf(PlatformGLObject sampler, GCGLenum pname)
2734
GCGLfloat GraphicsContextGLANGLE::getSamplerParameterf(PlatformGLObject sampler, GCGLenum pname)
2741
{
2735
{
2742
    GCGLfloat value = 0.f;
2736
    GCGLfloat value = 0.f;
2743
    if (!makeContextCurrent())
2737
    if (!makeContextCurrent())
Lines 2747-2753 GCGLfloat GraphicsContextGLOpenGL::getSamplerParameterf(PlatformGLObject sampler a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec234
2747
    return value;
2741
    return value;
2748
}
2742
}
2749
2743
2750
GCGLint GraphicsContextGLOpenGL::getSamplerParameteri(PlatformGLObject sampler, GCGLenum pname)
2744
GCGLint GraphicsContextGLANGLE::getSamplerParameteri(PlatformGLObject sampler, GCGLenum pname)
2751
{
2745
{
2752
    GCGLint value = 0;
2746
    GCGLint value = 0;
2753
    if (!makeContextCurrent())
2747
    if (!makeContextCurrent())
Lines 2757-2763 GCGLint GraphicsContextGLOpenGL::getSamplerParameteri(PlatformGLObject sampler, a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec235
2757
    return value;
2751
    return value;
2758
}
2752
}
2759
2753
2760
GCGLsync GraphicsContextGLOpenGL::fenceSync(GCGLenum condition, GCGLbitfield flags)
2754
GCGLsync GraphicsContextGLANGLE::fenceSync(GCGLenum condition, GCGLbitfield flags)
2761
{
2755
{
2762
    if (!makeContextCurrent())
2756
    if (!makeContextCurrent())
2763
        return 0;
2757
        return 0;
Lines 2765-2771 GCGLsync GraphicsContextGLOpenGL::fenceSync(GCGLenum condition, GCGLbitfield fla a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec236
2765
    return gl::FenceSync(condition, flags);
2759
    return gl::FenceSync(condition, flags);
2766
}
2760
}
2767
2761
2768
GCGLboolean GraphicsContextGLOpenGL::isSync(GCGLsync sync)
2762
GCGLboolean GraphicsContextGLANGLE::isSync(GCGLsync sync)
2769
{
2763
{
2770
    if (!makeContextCurrent())
2764
    if (!makeContextCurrent())
2771
        return GL_FALSE;
2765
        return GL_FALSE;
Lines 2773-2779 GCGLboolean GraphicsContextGLOpenGL::isSync(GCGLsync sync) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec237
2773
    return gl::IsSync(sync);
2767
    return gl::IsSync(sync);
2774
}
2768
}
2775
2769
2776
void GraphicsContextGLOpenGL::deleteSync(GCGLsync sync)
2770
void GraphicsContextGLANGLE::deleteSync(GCGLsync sync)
2777
{
2771
{
2778
    if (!makeContextCurrent())
2772
    if (!makeContextCurrent())
2779
        return;
2773
        return;
Lines 2781-2787 void GraphicsContextGLOpenGL::deleteSync(GCGLsync sync) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec238
2781
    gl::DeleteSync(sync);
2775
    gl::DeleteSync(sync);
2782
}
2776
}
2783
2777
2784
GCGLenum GraphicsContextGLOpenGL::clientWaitSync(GCGLsync sync, GCGLbitfield flags, GCGLuint64 timeout)
2778
GCGLenum GraphicsContextGLANGLE::clientWaitSync(GCGLsync sync, GCGLbitfield flags, GCGLuint64 timeout)
2785
{
2779
{
2786
    if (!makeContextCurrent())
2780
    if (!makeContextCurrent())
2787
        return GL_WAIT_FAILED;
2781
        return GL_WAIT_FAILED;
Lines 2789-2795 GCGLenum GraphicsContextGLOpenGL::clientWaitSync(GCGLsync sync, GCGLbitfield fla a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec239
2789
    return gl::ClientWaitSync(sync, flags, timeout);
2783
    return gl::ClientWaitSync(sync, flags, timeout);
2790
}
2784
}
2791
2785
2792
void GraphicsContextGLOpenGL::waitSync(GCGLsync sync, GCGLbitfield flags, GCGLint64 timeout)
2786
void GraphicsContextGLANGLE::waitSync(GCGLsync sync, GCGLbitfield flags, GCGLint64 timeout)
2793
{
2787
{
2794
    if (!makeContextCurrent())
2788
    if (!makeContextCurrent())
2795
        return;
2789
        return;
Lines 2797-2803 void GraphicsContextGLOpenGL::waitSync(GCGLsync sync, GCGLbitfield flags, GCGLin a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec240
2797
    gl::WaitSync(sync, flags, timeout);
2791
    gl::WaitSync(sync, flags, timeout);
2798
}
2792
}
2799
2793
2800
GCGLint GraphicsContextGLOpenGL::getSynci(GCGLsync sync, GCGLenum pname)
2794
GCGLint GraphicsContextGLANGLE::getSynci(GCGLsync sync, GCGLenum pname)
2801
{
2795
{
2802
    GCGLint value = 0;
2796
    GCGLint value = 0;
2803
    if (!makeContextCurrent())
2797
    if (!makeContextCurrent())
Lines 2807-2813 GCGLint GraphicsContextGLOpenGL::getSynci(GCGLsync sync, GCGLenum pname) a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec241
2807
    return value;
2801
    return value;
2808
}
2802
}
2809
2803
2810
void GraphicsContextGLOpenGL::pauseTransformFeedback()
2804
void GraphicsContextGLANGLE::pauseTransformFeedback()
2811
{
2805
{
2812
    if (!makeContextCurrent())
2806
    if (!makeContextCurrent())
2813
        return;
2807
        return;
Lines 2815-2821 void GraphicsContextGLOpenGL::pauseTransformFeedback() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec242
2815
    gl::PauseTransformFeedback();
2809
    gl::PauseTransformFeedback();
2816
}
2810
}
2817
2811
2818
void GraphicsContextGLOpenGL::resumeTransformFeedback()
2812
void GraphicsContextGLANGLE::resumeTransformFeedback()
2819
{
2813
{
2820
    if (!makeContextCurrent())
2814
    if (!makeContextCurrent())
2821
        return;
2815
        return;
Lines 2823-2829 void GraphicsContextGLOpenGL::resumeTransformFeedback() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec243
2823
    gl::ResumeTransformFeedback();
2817
    gl::ResumeTransformFeedback();
2824
}
2818
}
2825
2819
2826
void GraphicsContextGLOpenGL::bindBufferRange(GCGLenum target, GCGLuint index, PlatformGLObject buffer, GCGLintptr offset, GCGLsizeiptr size)
2820
void GraphicsContextGLANGLE::bindBufferRange(GCGLenum target, GCGLuint index, PlatformGLObject buffer, GCGLintptr offset, GCGLsizeiptr size)
2827
{
2821
{
2828
    if (!makeContextCurrent())
2822
    if (!makeContextCurrent())
2829
        return;
2823
        return;
Lines 2831-2837 void GraphicsContextGLOpenGL::bindBufferRange(GCGLenum target, GCGLuint index, P a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec244
2831
    gl::BindBufferRange(target, index, buffer, offset, size);
2825
    gl::BindBufferRange(target, index, buffer, offset, size);
2832
}
2826
}
2833
2827
2834
Vector<GCGLuint> GraphicsContextGLOpenGL::getUniformIndices(PlatformGLObject program, const Vector<String>& uniformNames)
2828
Vector<GCGLuint> GraphicsContextGLANGLE::getUniformIndices(PlatformGLObject program, const Vector<String>& uniformNames)
2835
{
2829
{
2836
    ASSERT(program);
2830
    ASSERT(program);
2837
    if (!makeContextCurrent())
2831
    if (!makeContextCurrent())
Lines 2844-2857 Vector<GCGLuint> GraphicsContextGLOpenGL::getUniformIndices(PlatformGLObject pro a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec245
2844
    return result;
2838
    return result;
2845
}
2839
}
2846
2840
2847
void GraphicsContextGLOpenGL::getActiveUniformBlockiv(GCGLuint program, GCGLuint uniformBlockIndex, GCGLenum pname, GCGLSpan<GCGLint> params)
2841
void GraphicsContextGLANGLE::getActiveUniformBlockiv(GCGLuint program, GCGLuint uniformBlockIndex, GCGLenum pname, GCGLSpan<GCGLint> params)
2848
{
2842
{
2849
    if (!makeContextCurrent())
2843
    if (!makeContextCurrent())
2850
        return;
2844
        return;
2851
    gl::GetActiveUniformBlockivRobustANGLE(program, uniformBlockIndex, pname, params.bufSize, nullptr, params.data);
2845
    gl::GetActiveUniformBlockivRobustANGLE(program, uniformBlockIndex, pname, params.bufSize, nullptr, params.data);
2852
}
2846
}
2853
2847
2854
void GraphicsContextGLOpenGL::multiDrawArraysANGLE(GCGLenum mode, GCGLSpan<const GCGLint> firsts, GCGLSpan<const GCGLsizei> counts, GCGLsizei drawcount)
2848
void GraphicsContextGLANGLE::multiDrawArraysANGLE(GCGLenum mode, GCGLSpan<const GCGLint> firsts, GCGLSpan<const GCGLsizei> counts, GCGLsizei drawcount)
2855
{
2849
{
2856
    if (!makeContextCurrent())
2850
    if (!makeContextCurrent())
2857
        return;
2851
        return;
Lines 2859-2865 void GraphicsContextGLOpenGL::multiDrawArraysANGLE(GCGLenum mode, GCGLSpan<const a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec246
2859
    gl::MultiDrawArraysANGLE(mode, firsts.data, counts.data, drawcount);
2853
    gl::MultiDrawArraysANGLE(mode, firsts.data, counts.data, drawcount);
2860
}
2854
}
2861
2855
2862
void GraphicsContextGLOpenGL::multiDrawArraysInstancedANGLE(GCGLenum mode, GCGLSpan<const GCGLint> firsts, GCGLSpan<const GCGLsizei> counts, GCGLSpan<const GCGLsizei> instanceCounts, GCGLsizei drawcount)
2856
void GraphicsContextGLANGLE::multiDrawArraysInstancedANGLE(GCGLenum mode, GCGLSpan<const GCGLint> firsts, GCGLSpan<const GCGLsizei> counts, GCGLSpan<const GCGLsizei> instanceCounts, GCGLsizei drawcount)
2863
{
2857
{
2864
    if (!makeContextCurrent())
2858
    if (!makeContextCurrent())
2865
        return;
2859
        return;
Lines 2867-2873 void GraphicsContextGLOpenGL::multiDrawArraysInstancedANGLE(GCGLenum mode, GCGLS a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec247
2867
    gl::MultiDrawArraysInstancedANGLE(mode, firsts.data, counts.data, instanceCounts.data, drawcount);
2861
    gl::MultiDrawArraysInstancedANGLE(mode, firsts.data, counts.data, instanceCounts.data, drawcount);
2868
}
2862
}
2869
2863
2870
void GraphicsContextGLOpenGL::multiDrawElementsANGLE(GCGLenum mode, GCGLSpan<const GCGLsizei> counts, GCGLenum type, GCGLSpan<const GCGLint> offsets, GCGLsizei drawcount)
2864
void GraphicsContextGLANGLE::multiDrawElementsANGLE(GCGLenum mode, GCGLSpan<const GCGLsizei> counts, GCGLenum type, GCGLSpan<const GCGLint> offsets, GCGLsizei drawcount)
2871
{
2865
{
2872
    if (!makeContextCurrent())
2866
    if (!makeContextCurrent())
2873
        return;
2867
        return;
Lines 2880-2886 void GraphicsContextGLOpenGL::multiDrawElementsANGLE(GCGLenum mode, GCGLSpan<con a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec248
2880
    gl::MultiDrawElementsANGLE(mode, counts.data, type, pointers.data(), drawcount);
2874
    gl::MultiDrawElementsANGLE(mode, counts.data, type, pointers.data(), drawcount);
2881
}
2875
}
2882
2876
2883
void GraphicsContextGLOpenGL::multiDrawElementsInstancedANGLE(GCGLenum mode, GCGLSpan<const GCGLsizei> counts, GCGLenum type, GCGLSpan<const GCGLint> offsets, GCGLSpan<const GCGLsizei> instanceCounts, GCGLsizei drawcount)
2877
void GraphicsContextGLANGLE::multiDrawElementsInstancedANGLE(GCGLenum mode, GCGLSpan<const GCGLsizei> counts, GCGLenum type, GCGLSpan<const GCGLint> offsets, GCGLSpan<const GCGLsizei> instanceCounts, GCGLsizei drawcount)
2884
{
2878
{
2885
    if (!makeContextCurrent())
2879
    if (!makeContextCurrent())
2886
        return;
2880
        return;
Lines 2893-2899 void GraphicsContextGLOpenGL::multiDrawElementsInstancedANGLE(GCGLenum mode, GCG a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec249
2893
    gl::MultiDrawElementsInstancedANGLE(mode, counts.data, type, pointers.data(), instanceCounts.data, drawcount);
2887
    gl::MultiDrawElementsInstancedANGLE(mode, counts.data, type, pointers.data(), instanceCounts.data, drawcount);
2894
}
2888
}
2895
2889
2896
bool GraphicsContextGLOpenGL::waitAndUpdateOldestFrame()
2890
bool GraphicsContextGLANGLE::waitAndUpdateOldestFrame()
2897
{
2891
{
2898
    size_t oldestFrameCompletionFence = m_oldestFrameCompletionFence++ % maxPendingFrames;
2892
    size_t oldestFrameCompletionFence = m_oldestFrameCompletionFence++ % maxPendingFrames;
2899
    bool success = true;
2893
    bool success = true;
Lines 2914-2919 bool GraphicsContextGLOpenGL::waitAndUpdateOldestFrame() a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp_sec250
2914
    return success;
2908
    return success;
2915
}
2909
}
2916
2910
2911
void GraphicsContextGLANGLE::simulateEventForTesting(SimulatedEventForTesting event)
2912
{
2913
    if (event == SimulatedEventForTesting::ContextChange) {
2914
        GraphicsContextGLOpenGLManager::sharedManager().displayWasReconfigured();
2915
        return;
2916
    }
2917
    if (event == SimulatedEventForTesting::GPUStatusFailure) {
2918
        m_failNextStatusCheck = true;
2919
        return;
2920
    }
2921
}
2922
2923
bool GraphicsContextGLANGLE::isGLES2Compliant() const
2924
{
2925
    return m_isForWebGL2;
2926
}
2927
2928
void GraphicsContextGLANGLE::paintRenderingResultsToCanvas(ImageBuffer& imageBuffer)
2929
{
2930
    if (!makeContextCurrent())
2931
        return;
2932
    if (getInternalFramebufferSize().isEmpty())
2933
        return;
2934
    auto pixelBuffer = readRenderingResults();
2935
    if (!pixelBuffer)
2936
        return;
2937
    paintToCanvas(contextAttributes(), WTFMove(*pixelBuffer), imageBuffer.backendSize(), imageBuffer.context());
2938
}
2939
2940
void GraphicsContextGLANGLE::paintCompositedResultsToCanvas(ImageBuffer& imageBuffer)
2941
{
2942
    if (!makeContextCurrent())
2943
        return;
2944
    if (getInternalFramebufferSize().isEmpty())
2945
        return;
2946
    auto pixelBuffer = readCompositedResults();
2947
    if (!pixelBuffer)
2948
        return;
2949
    paintToCanvas(contextAttributes(), WTFMove(*pixelBuffer), imageBuffer.backendSize(), imageBuffer.context());
2950
}
2951
2952
std::optional<PixelBuffer> GraphicsContextGLANGLE::paintRenderingResultsToPixelBuffer()
2953
{
2954
    // Reading premultiplied alpha would involve unpremultiplying, which is lossy.
2955
    if (contextAttributes().premultipliedAlpha)
2956
        return std::nullopt;
2957
    auto results = readRenderingResultsForPainting();
2958
    if (results && !results->size().isEmpty()) {
2959
        ASSERT(results->format().pixelFormat == PixelFormat::RGBA8 || results->format().pixelFormat == PixelFormat::BGRA8);
2960
        // FIXME: Make PixelBufferConversions support negative rowBytes and in-place conversions.
2961
        const auto size = results->size();
2962
        const size_t rowStride = size.width() * 4;
2963
        uint8_t* top = results->data().data();
2964
        uint8_t* bottom = top + (size.height() - 1) * rowStride;
2965
        std::unique_ptr<uint8_t[]> temp(new uint8_t[rowStride]);
2966
        for (; top < bottom; top += rowStride, bottom -= rowStride) {
2967
            memcpy(temp.get(), bottom, rowStride);
2968
            memcpy(bottom, top, rowStride);
2969
            memcpy(top, temp.get(), rowStride);
2970
        }
2971
    }
2972
    return results;
2973
}
2974
2975
std::optional<PixelBuffer> GraphicsContextGLANGLE::readRenderingResultsForPainting()
2976
{
2977
    if (!makeContextCurrent())
2978
        return std::nullopt;
2979
    if (getInternalFramebufferSize().isEmpty())
2980
        return std::nullopt;
2981
    return readRenderingResults();
2982
}
2983
2984
std::optional<PixelBuffer> GraphicsContextGLANGLE::readCompositedResultsForPainting()
2985
{
2986
    if (!makeContextCurrent())
2987
        return std::nullopt;
2988
    if (getInternalFramebufferSize().isEmpty())
2989
        return std::nullopt;
2990
    return readCompositedResults();
2991
}
2992
2917
}
2993
}
2918
2994
2919
#endif // ENABLE(WEBGL) && USE(ANGLE)
2995
#endif // ENABLE(WEBGL) && USE(ANGLE)
- a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h +476 lines
Line 0 a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h_sec1
1
/*
2
 * Copyright (C) 2009, 2014-2019 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEBGL) && USE(ANGLE)
29
30
#include "ANGLEUtilities.h"
31
#include "GraphicsContextGL.h"
32
#include "GraphicsContextGLState.h"
33
#include <memory>
34
#include <wtf/ListHashSet.h>
35
36
#if PLATFORM(COCOA)
37
#include "GraphicsContextGLIOSurfaceSwapChain.h"
38
#include "IOSurface.h"
39
#endif
40
41
#if PLATFORM(MAC)
42
#include "ScopedHighPerformanceGPURequest.h"
43
#endif
44
45
#if USE(NICOSIA)
46
namespace Nicosia {
47
class GCGLLayer;
48
}
49
#endif
50
51
namespace WebCore {
52
53
class ExtensionsGL;
54
class ExtensionsGLANGLE;
55
class HostWindow;
56
class ImageBuffer;
57
class MediaPlayer;
58
class PixelBuffer;
59
60
#if USE(TEXTURE_MAPPER)
61
class TextureMapperGCGLPlatformLayer;
62
#endif
63
64
// Base class for GraphicsContextGL contexts that use ANGLE.
65
class WEBCORE_EXPORT GraphicsContextGLANGLE : public GraphicsContextGL {
66
public:
67
    virtual ~GraphicsContextGLANGLE();
68
69
    PlatformLayer* platformLayer() const override;
70
71
    PlatformGraphicsContextGLDisplay platformDisplay() const;
72
    PlatformGraphicsContextGLConfig platformConfig() const;
73
    GCGLenum drawingBufferTextureTarget();
74
    static GCGLenum drawingBufferTextureTargetQueryForDrawingTarget(GCGLenum drawingTarget);
75
    static GCGLint EGLDrawingBufferTextureTargetForDrawingTarget(GCGLenum drawingTarget);
76
    enum class ReleaseThreadResourceBehavior {
77
        // Releases current context after GraphicsContextGLANGLE calls done in the thread.
78
        ReleaseCurrentContext,
79
        // Releases all thread resources after GraphicsContextGLANGLE calls done in the thread.
80
        ReleaseThreadResources,
81
        // Releases all global state. Should be used only after all depending objects have
82
        // been released.
83
        TerminateAndReleaseThreadResources
84
    };
85
    static bool releaseThreadResources(ReleaseThreadResourceBehavior);
86
87
    // With multisampling on, blit from multisampleFBO to regular FBO.
88
    void prepareTexture();
89
90
    // Get an attribute location without checking the name -> mangledname mapping.
91
    int getAttribLocationDirect(PlatformGLObject program, const String& name);
92
93
    // Compile a shader without going through ANGLE.
94
    void compileShaderDirect(PlatformGLObject);
95
96
    // Equivalent to ::glTexImage2D(). Allows pixels==0 with no allocation.
97
    void texImage2DDirect(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, const void* pixels);
98
99
    // GraphicsContextGL overrides.
100
    bool isGLES2Compliant() const final;
101
    void activeTexture(GCGLenum texture) final;
102
    void attachShader(PlatformGLObject program, PlatformGLObject shader) final;
103
    void bindAttribLocation(PlatformGLObject, GCGLuint index, const String& name) final;
104
    void bindBuffer(GCGLenum target, PlatformGLObject) final;
105
    void bindFramebuffer(GCGLenum target, PlatformGLObject) final;
106
    void bindRenderbuffer(GCGLenum target, PlatformGLObject) final;
107
    void bindTexture(GCGLenum target, PlatformGLObject) final;
108
    void blendColor(GCGLclampf red, GCGLclampf green, GCGLclampf blue, GCGLclampf alpha) final;
109
    void blendEquation(GCGLenum mode) final;
110
    void blendEquationSeparate(GCGLenum modeRGB, GCGLenum modeAlpha) final;
111
    void blendFunc(GCGLenum sfactor, GCGLenum dfactor) final;
112
    void blendFuncSeparate(GCGLenum srcRGB, GCGLenum dstRGB, GCGLenum srcAlpha, GCGLenum dstAlpha) final;
113
    void bufferData(GCGLenum target, GCGLsizeiptr, GCGLenum usage) final;
114
    void bufferData(GCGLenum target, GCGLSpan<const GCGLvoid> data, GCGLenum usage) final;
115
    void bufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<const GCGLvoid> data) final;
116
    GCGLenum checkFramebufferStatus(GCGLenum target) final;
117
    void clear(GCGLbitfield mask) final;
118
    void clearColor(GCGLclampf red, GCGLclampf green, GCGLclampf blue, GCGLclampf alpha) final;
119
    void clearDepth(GCGLclampf depth) final;
120
    void clearStencil(GCGLint s) final;
121
    void colorMask(GCGLboolean red, GCGLboolean green, GCGLboolean blue, GCGLboolean alpha) final;
122
    void compileShader(PlatformGLObject) final;
123
    void copyTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLint border) final;
124
    void copyTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height) final;
125
    void cullFace(GCGLenum mode) final;
126
    void depthFunc(GCGLenum func) final;
127
    void depthMask(GCGLboolean flag) final;
128
    void depthRange(GCGLclampf zNear, GCGLclampf zFar) final;
129
    void detachShader(PlatformGLObject, PlatformGLObject) final;
130
    void disable(GCGLenum cap) final;
131
    void disableVertexAttribArray(GCGLuint index) final;
132
    void drawArrays(GCGLenum mode, GCGLint first, GCGLsizei count) final;
133
    void drawElements(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset) final;
134
    void enable(GCGLenum cap) final;
135
    void enableVertexAttribArray(GCGLuint index) final;
136
    void finish() final;
137
    void flush() final;
138
    void framebufferRenderbuffer(GCGLenum target, GCGLenum attachment, GCGLenum renderbuffertarget, PlatformGLObject) final;
139
    void framebufferTexture2D(GCGLenum target, GCGLenum attachment, GCGLenum textarget, PlatformGLObject, GCGLint level) final;
140
    void frontFace(GCGLenum mode) final;
141
    void generateMipmap(GCGLenum target) final;
142
    bool getActiveAttrib(PlatformGLObject program, GCGLuint index, ActiveInfo&) final;
143
    bool getActiveAttribImpl(PlatformGLObject program, GCGLuint index, ActiveInfo&);
144
    bool getActiveUniform(PlatformGLObject program, GCGLuint index, ActiveInfo&) final;
145
    bool getActiveUniformImpl(PlatformGLObject program, GCGLuint index, ActiveInfo&);
146
    void getAttachedShaders(PlatformGLObject program, GCGLsizei maxCount, GCGLsizei* count, PlatformGLObject* shaders);
147
    GCGLint getAttribLocation(PlatformGLObject, const String& name) final;
148
    void getBooleanv(GCGLenum pname, GCGLSpan<GCGLboolean> value) final;
149
    GCGLint getBufferParameteri(GCGLenum target, GCGLenum pname) final;
150
    GCGLenum getError() final;
151
    void getFloatv(GCGLenum pname, GCGLSpan<GCGLfloat> value) final;
152
    GCGLint getFramebufferAttachmentParameteri(GCGLenum target, GCGLenum attachment, GCGLenum pname) final;
153
    void getIntegerv(GCGLenum pname, GCGLSpan<GCGLint> value) final;
154
    GCGLint64 getInteger64(GCGLenum pname) final;
155
    GCGLint64 getInteger64i(GCGLenum pname, GCGLuint index) final;
156
    GCGLint getProgrami(PlatformGLObject program, GCGLenum pname) final;
157
    String getProgramInfoLog(PlatformGLObject) final;
158
    String getUnmangledInfoLog(PlatformGLObject[2], GCGLsizei, const String&);
159
    GCGLint getRenderbufferParameteri(GCGLenum target, GCGLenum pname) final;
160
    GCGLint getShaderi(PlatformGLObject, GCGLenum pname) final;
161
    String getShaderInfoLog(PlatformGLObject) final;
162
    void getShaderPrecisionFormat(GCGLenum shaderType, GCGLenum precisionType, GCGLSpan<GCGLint, 2> range, GCGLint* precision) final;
163
    String getShaderSource(PlatformGLObject) final;
164
    String getString(GCGLenum name) final;
165
    GCGLfloat getTexParameterf(GCGLenum target, GCGLenum pname) final;
166
    GCGLint getTexParameteri(GCGLenum target, GCGLenum pname) final;
167
    void getUniformfv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLfloat> value) final;
168
    void getUniformiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLint> value) final;
169
    void getUniformuiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLuint> value) final;
170
    GCGLint getUniformLocation(PlatformGLObject, const String& name) final;
171
    GCGLsizeiptr getVertexAttribOffset(GCGLuint index, GCGLenum pname) final;
172
    void hint(GCGLenum target, GCGLenum mode) final;
173
    GCGLboolean isBuffer(PlatformGLObject) final;
174
    GCGLboolean isEnabled(GCGLenum cap) final;
175
    GCGLboolean isFramebuffer(PlatformGLObject) final;
176
    GCGLboolean isProgram(PlatformGLObject) final;
177
    GCGLboolean isRenderbuffer(PlatformGLObject) final;
178
    GCGLboolean isShader(PlatformGLObject) final;
179
    GCGLboolean isTexture(PlatformGLObject) final;
180
    void lineWidth(GCGLfloat) final;
181
    void linkProgram(PlatformGLObject) final;
182
    void pixelStorei(GCGLenum pname, GCGLint param) final;
183
    void polygonOffset(GCGLfloat factor, GCGLfloat units) final;
184
    void readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<GCGLvoid> data) final;
185
    void readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset) final;
186
    void renderbufferStorage(GCGLenum target, GCGLenum internalformat, GCGLsizei width, GCGLsizei height) final;
187
    void sampleCoverage(GCGLclampf value, GCGLboolean invert) final;
188
    void scissor(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height) final;
189
    void shaderSource(PlatformGLObject, const String&) final;
190
    void stencilFunc(GCGLenum func, GCGLint ref, GCGLuint mask) final;
191
    void stencilFuncSeparate(GCGLenum face, GCGLenum func, GCGLint ref, GCGLuint mask) final;
192
    void stencilMask(GCGLuint mask) final;
193
    void stencilMaskSeparate(GCGLenum face, GCGLuint mask) final;
194
    void stencilOp(GCGLenum fail, GCGLenum zfail, GCGLenum zpass) final;
195
    void stencilOpSeparate(GCGLenum face, GCGLenum fail, GCGLenum zfail, GCGLenum zpass) final;
196
    void texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels) final;
197
    void texImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLintptr offset) final;
198
    void texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels) final;
199
    void texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset) final;
200
    void compressedTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data) final;
201
    void compressedTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLsizei imageSize, GCGLintptr offset) final;
202
    void compressedTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data) final;
203
    void compressedTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLintptr offset) final;
204
    void texParameterf(GCGLenum target, GCGLenum pname, GCGLfloat param) final;
205
    void texParameteri(GCGLenum target, GCGLenum pname, GCGLint param) final;
206
    void uniform1f(GCGLint location, GCGLfloat x) final;
207
    void uniform1fv(GCGLint location, GCGLSpan<const GCGLfloat> v) final;
208
    void uniform1i(GCGLint location, GCGLint x) final;
209
    void uniform1iv(GCGLint location, GCGLSpan<const GCGLint> v) final;
210
    void uniform2f(GCGLint location, GCGLfloat x, GCGLfloat y) final;
211
    void uniform2fv(GCGLint location, GCGLSpan<const GCGLfloat> v) final;
212
    void uniform2i(GCGLint location, GCGLint x, GCGLint y) final;
213
    void uniform2iv(GCGLint location, GCGLSpan<const GCGLint> v) final;
214
    void uniform3f(GCGLint location, GCGLfloat x, GCGLfloat y, GCGLfloat z) final;
215
    void uniform3fv(GCGLint location, GCGLSpan<const GCGLfloat> v) final;
216
    void uniform3i(GCGLint location, GCGLint x, GCGLint y, GCGLint z) final;
217
    void uniform3iv(GCGLint location, GCGLSpan<const GCGLint> v) final;
218
    void uniform4f(GCGLint location, GCGLfloat x, GCGLfloat y, GCGLfloat z, GCGLfloat w) final;
219
    void uniform4fv(GCGLint location, GCGLSpan<const GCGLfloat> v) final;
220
    void uniform4i(GCGLint location, GCGLint x, GCGLint y, GCGLint z, GCGLint w) final;
221
    void uniform4iv(GCGLint location, GCGLSpan<const GCGLint> v) final;
222
    void uniformMatrix2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> value) final;
223
    void uniformMatrix3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> value) final;
224
    void uniformMatrix4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> value) final;
225
    void useProgram(PlatformGLObject) final;
226
    void validateProgram(PlatformGLObject) final;
227
    void vertexAttrib1f(GCGLuint index, GCGLfloat x) final;
228
    void vertexAttrib1fv(GCGLuint index, GCGLSpan<const GCGLfloat, 1> values) final;
229
    void vertexAttrib2f(GCGLuint index, GCGLfloat x, GCGLfloat y) final;
230
    void vertexAttrib2fv(GCGLuint index, GCGLSpan<const GCGLfloat, 2> values) final;
231
    void vertexAttrib3f(GCGLuint index, GCGLfloat x, GCGLfloat y, GCGLfloat z) final;
232
    void vertexAttrib3fv(GCGLuint index, GCGLSpan<const GCGLfloat, 3> values) final;
233
    void vertexAttrib4f(GCGLuint index, GCGLfloat x, GCGLfloat y, GCGLfloat z, GCGLfloat w) final;
234
    void vertexAttrib4fv(GCGLuint index, GCGLSpan<const GCGLfloat, 4> values) final;
235
    void vertexAttribPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLboolean normalized, GCGLsizei stride, GCGLintptr offset) final;
236
    void viewport(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height) final;
237
    void reshape(int width, int height) final;
238
    void drawArraysInstanced(GCGLenum mode, GCGLint first, GCGLsizei count, GCGLsizei primcount) final;
239
    void drawElementsInstanced(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset, GCGLsizei primcount) final;
240
    void vertexAttribDivisor(GCGLuint index, GCGLuint divisor) final;
241
    PlatformGLObject createVertexArray() final;
242
    void deleteVertexArray(PlatformGLObject) final;
243
    GCGLboolean isVertexArray(PlatformGLObject) final;
244
    void bindVertexArray(PlatformGLObject) final;
245
    void copyBufferSubData(GCGLenum readTarget, GCGLenum writeTarget, GCGLintptr readOffset, GCGLintptr writeOffset, GCGLsizeiptr) final;
246
    void getBufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<GCGLvoid> data) final;
247
    void blitFramebuffer(GCGLint srcX0, GCGLint srcY0, GCGLint srcX1, GCGLint srcY1, GCGLint dstX0, GCGLint dstY0, GCGLint dstX1, GCGLint dstY1, GCGLbitfield mask, GCGLenum filter) final;
248
    void framebufferTextureLayer(GCGLenum target, GCGLenum attachment, PlatformGLObject texture, GCGLint level, GCGLint layer) final;
249
    void invalidateFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments) final;
250
    void invalidateSubFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height) final;
251
    void readBuffer(GCGLenum src) final;
252
    void getInternalformativ(GCGLenum target, GCGLenum internalformat, GCGLenum pname, GCGLSpan<GCGLint> data) final;
253
    void renderbufferStorageMultisample(GCGLenum target, GCGLsizei samples, GCGLenum internalformat, GCGLsizei width, GCGLsizei height) final;
254
    void texStorage2D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height) final;
255
    void texStorage3D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth) final;
256
    void texImage3D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels) final;
257
    void texImage3D(GCGLenum target, GCGLint level, GCGLint internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLenum format, GCGLenum type, GCGLintptr offset) final;
258
    void texSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels) final;
259
    void texSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLenum type, GCGLintptr offset) final;
260
    void copyTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height) final;
261
    void compressedTexImage3D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data) final;
262
    void compressedTexImage3D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLint border, GCGLsizei imageSize, GCGLintptr offset) final;
263
    void compressedTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data) final;
264
    void compressedTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLsizei width, GCGLsizei height, GCGLsizei depth, GCGLenum format, GCGLsizei imageSize, GCGLintptr offset) final;
265
    GCGLint getFragDataLocation(PlatformGLObject program, const String& name) final;
266
    void uniform1ui(GCGLint location, GCGLuint v0) final;
267
    void uniform2ui(GCGLint location, GCGLuint v0, GCGLuint v1) final;
268
    void uniform3ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2) final;
269
    void uniform4ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2, GCGLuint v3) final;
270
    void uniform1uiv(GCGLint location, GCGLSpan<const GCGLuint>) final;
271
    void uniform2uiv(GCGLint location, GCGLSpan<const GCGLuint>) final;
272
    void uniform3uiv(GCGLint location, GCGLSpan<const GCGLuint>) final;
273
    void uniform4uiv(GCGLint location, GCGLSpan<const GCGLuint>) final;
274
    void uniformMatrix2x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data) final;
275
    void uniformMatrix3x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data) final;
276
    void uniformMatrix2x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data) final;
277
    void uniformMatrix4x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data) final;
278
    void uniformMatrix3x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data) final;
279
    void uniformMatrix4x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data) final;
280
    void vertexAttribI4i(GCGLuint index, GCGLint x, GCGLint y, GCGLint z, GCGLint w) final;
281
    void vertexAttribI4iv(GCGLuint index, GCGLSpan<const GCGLint, 4> values) final;
282
    void vertexAttribI4ui(GCGLuint index, GCGLuint x, GCGLuint y, GCGLuint z, GCGLuint w) final;
283
    void vertexAttribI4uiv(GCGLuint index, GCGLSpan<const GCGLuint, 4> values) final;
284
    void vertexAttribIPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLsizei stride, GCGLintptr offset) final;
285
    void drawRangeElements(GCGLenum mode, GCGLuint start, GCGLuint end, GCGLsizei count, GCGLenum type, GCGLintptr offset) final;
286
    void drawBuffers(GCGLSpan<const GCGLenum> bufs) final;
287
    void clearBufferiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLint> values) final;
288
    void clearBufferuiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLuint> values) final;
289
    void clearBufferfv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLfloat> values) final;
290
    void clearBufferfi(GCGLenum buffer, GCGLint drawbuffer, GCGLfloat depth, GCGLint stencil) final;
291
    PlatformGLObject createQuery() final;
292
    void deleteQuery(PlatformGLObject query) final;
293
    GCGLboolean isQuery(PlatformGLObject query) final;
294
    void beginQuery(GCGLenum target, PlatformGLObject query) final;
295
    void endQuery(GCGLenum target) final;
296
    PlatformGLObject getQuery(GCGLenum target, GCGLenum pname) final;
297
    GCGLuint getQueryObjectui(PlatformGLObject query, GCGLenum pname) final;
298
    PlatformGLObject createSampler() final;
299
    void deleteSampler(PlatformGLObject sampler) final;
300
    GCGLboolean isSampler(PlatformGLObject sampler) final;
301
    void bindSampler(GCGLuint unit, PlatformGLObject sampler) final;
302
    void samplerParameteri(PlatformGLObject sampler, GCGLenum pname, GCGLint param) final;
303
    void samplerParameterf(PlatformGLObject sampler, GCGLenum pname, GCGLfloat param) final;
304
    GCGLfloat getSamplerParameterf(PlatformGLObject sampler, GCGLenum pname) final;
305
    GCGLint getSamplerParameteri(PlatformGLObject sampler, GCGLenum pname) final;
306
    GCGLsync fenceSync(GCGLenum condition, GCGLbitfield flags) final;
307
    GCGLboolean isSync(GCGLsync) final;
308
    void deleteSync(GCGLsync) final;
309
    GCGLenum clientWaitSync(GCGLsync, GCGLbitfield flags, GCGLuint64 timeout) final;
310
    void waitSync(GCGLsync, GCGLbitfield flags, GCGLint64 timeout) final;
311
    GCGLint getSynci(GCGLsync, GCGLenum pname) final;
312
    PlatformGLObject createTransformFeedback() final;
313
    void deleteTransformFeedback(PlatformGLObject id) final;
314
    GCGLboolean isTransformFeedback(PlatformGLObject id) final;
315
    void bindTransformFeedback(GCGLenum target, PlatformGLObject id) final;
316
    void beginTransformFeedback(GCGLenum primitiveMode) final;
317
    void endTransformFeedback() final;
318
    void transformFeedbackVaryings(PlatformGLObject program, const Vector<String>& varyings, GCGLenum bufferMode) final;
319
    void getTransformFeedbackVarying(PlatformGLObject program, GCGLuint index, ActiveInfo&) final;
320
    void pauseTransformFeedback() final;
321
    void resumeTransformFeedback() final;
322
    void bindBufferBase(GCGLenum target, GCGLuint index, PlatformGLObject buffer) final;
323
    void bindBufferRange(GCGLenum target, GCGLuint index, PlatformGLObject buffer, GCGLintptr offset, GCGLsizeiptr) final;
324
    Vector<GCGLuint> getUniformIndices(PlatformGLObject program, const Vector<String>& uniformNames) final;
325
    Vector<GCGLint> getActiveUniforms(PlatformGLObject program, const Vector<GCGLuint>& uniformIndices, GCGLenum pname) final;
326
    GCGLuint getUniformBlockIndex(PlatformGLObject program, const String& uniformBlockName) final;
327
    String getActiveUniformBlockName(PlatformGLObject program, GCGLuint uniformBlockIndex) final;
328
    void uniformBlockBinding(PlatformGLObject program, GCGLuint uniformBlockIndex, GCGLuint uniformBlockBinding) final;
329
    void getActiveUniformBlockiv(GCGLuint program, GCGLuint uniformBlockIndex, GCGLenum pname, GCGLSpan<GCGLint> params) final;
330
    void multiDrawArraysANGLE(GCGLenum mode, GCGLSpan<const GCGLint> firsts, GCGLSpan<const GCGLsizei> counts, GCGLsizei drawcount) override;
331
    void multiDrawArraysInstancedANGLE(GCGLenum mode, GCGLSpan<const GCGLint> firsts, GCGLSpan<const GCGLsizei> counts, GCGLSpan<const GCGLsizei> instanceCounts, GCGLsizei drawcount) override;
332
    void multiDrawElementsANGLE(GCGLenum mode, GCGLSpan<const GCGLsizei> counts, GCGLenum type, GCGLSpan<const GCGLint> offsets, GCGLsizei drawcount) override;
333
    void multiDrawElementsInstancedANGLE(GCGLenum mode, GCGLSpan<const GCGLsizei> counts, GCGLenum type, GCGLSpan<const GCGLint> offsets, GCGLSpan<const GCGLsizei> instanceCounts, GCGLsizei drawcount) override;
334
    PlatformGLObject createBuffer() final;
335
    PlatformGLObject createFramebuffer() final;
336
    PlatformGLObject createProgram() final;
337
    PlatformGLObject createRenderbuffer() final;
338
    PlatformGLObject createShader(GCGLenum) final;
339
    PlatformGLObject createTexture() final;
340
    void deleteBuffer(PlatformGLObject) final;
341
    void deleteFramebuffer(PlatformGLObject) final;
342
    void deleteProgram(PlatformGLObject) final;
343
    void deleteRenderbuffer(PlatformGLObject) final;
344
    void deleteShader(PlatformGLObject) final;
345
    void deleteTexture(PlatformGLObject) final;
346
    void synthesizeGLError(GCGLenum error) final;
347
    bool moveErrorsToSyntheticErrorList() final;
348
    ExtensionsGL& getExtensions() final;
349
    void simulateEventForTesting(SimulatedEventForTesting) override;
350
    void paintRenderingResultsToCanvas(ImageBuffer&) final;
351
    std::optional<PixelBuffer> paintRenderingResultsToPixelBuffer() final;
352
    void paintCompositedResultsToCanvas(ImageBuffer&) final;
353
    void setContextVisibility(bool) final;
354
#if ENABLE(MEDIA_STREAM)
355
    RefPtr<MediaSample> paintCompositedResultsToMediaSample() final;
356
#endif
357
    void prepareForDisplay() override;
358
359
    void forceContextLost();
360
    void recycleContext();
361
    void dispatchContextChangedNotification();
362
    std::optional<PixelBuffer> readRenderingResultsForPainting();
363
    std::optional<PixelBuffer> readCompositedResultsForPainting();
364
365
#if PLATFORM(COCOA)
366
    void displayWasReconfigured();
367
#endif
368
    unsigned textureSeed(GCGLuint texture) { return m_state.textureSeedCount.count(texture); }
369
370
    constexpr static EGLNativeDisplayType defaultDisplay = EGL_DEFAULT_DISPLAY;
371
#if PLATFORM(COCOA)
372
    constexpr static EGLNativeDisplayType lowPowerDisplay = EGL_CAST(EGLNativeDisplayType, -1);
373
    constexpr static EGLNativeDisplayType highPerformanceDisplay = EGL_CAST(EGLNativeDisplayType, -2);
374
#endif
375
376
protected:
377
    GraphicsContextGLANGLE(GraphicsContextGLAttributes);
378
    // Called once by all the public entry points that eventually call OpenGL.
379
    // Called once by all the public entry points of ExtensionsGL that eventually call OpenGL.
380
    bool makeContextCurrent() WARN_UNUSED_RETURN;
381
382
    // Take into account the user's requested context creation attributes,
383
    // in particular stencil and antialias, and determine which could or
384
    // could not be honored based on the capabilities of the OpenGL
385
    // implementation.
386
    void validateDepthStencil(const char* packedDepthStencilExtension);
387
    void validateAttributes();
388
389
    void readnPixelsImpl(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, GCGLsizei* length, GCGLsizei* columns, GCGLsizei* rows, GCGLvoid* data, bool readingToPixelBufferObject);
390
391
    // Did the most recent drawing operation leave the GPU in an acceptable state?
392
    void checkGPUStatus();
393
394
    std::optional<PixelBuffer> readRenderingResults();
395
    std::optional<PixelBuffer> readCompositedResults();
396
    std::optional<PixelBuffer> readPixelsForPaintResults();
397
398
    bool reshapeFBOs(const IntSize&);
399
    void prepareTextureImpl();
400
    void resolveMultisamplingIfNecessary(const IntRect& = IntRect());
401
    void attachDepthAndStencilBufferIfNeeded(GCGLuint internalDepthStencilFormat, int width, int height);
402
403
    bool reshapeDisplayBufferBacking();
404
#if PLATFORM(COCOA)
405
    bool allocateAndBindDisplayBufferBacking();
406
    bool bindDisplayBufferBacking(std::unique_ptr<IOSurface> backing, void* pbuffer);
407
    static bool makeCurrent(PlatformGraphicsContextGLDisplay, PlatformGraphicsContextGL);
408
#endif
409
    // Returns false if context should be lost due to timeout.
410
    bool waitAndUpdateOldestFrame() WARN_UNUSED_RETURN;
411
412
    // Platform specific behavior for releaseResources();
413
    static void platformReleaseThreadResources();
414
415
    GCGLuint m_texture { 0 };
416
    GCGLuint m_fbo { 0 };
417
    GCGLuint m_depthStencilBuffer { 0 };
418
    GCGLuint m_internalColorFormat { 0 };
419
    GCGLuint m_internalDepthStencilFormat { 0 };
420
    GCGLuint m_multisampleFBO { 0 };
421
    GCGLuint m_multisampleDepthStencilBuffer { 0 };
422
    GCGLuint m_multisampleColorBuffer { 0 };
423
    // For preserveDrawingBuffer:true without multisampling.
424
    GCGLuint m_preserveDrawingBufferTexture { 0 };
425
    // Attaches m_texture when m_preserveDrawingBufferTexture is non-zero.
426
    GCGLuint m_preserveDrawingBufferFBO { 0 };
427
    // Queried at display startup.
428
    EGLint m_drawingBufferTextureTarget { -1 };
429
    // Errors raised by synthesizeGLError().
430
    ListHashSet<GCGLenum> m_syntheticErrors;
431
    bool m_isForWebGL2 { false };
432
    unsigned m_statusCheckCount { 0 };
433
    bool m_failNextStatusCheck { false };
434
    bool m_useFenceSyncForDisplayRateLimit = false;
435
    static constexpr size_t maxPendingFrames = 3;
436
    size_t m_oldestFrameCompletionFence { 0 };
437
    ScopedGLFence m_frameCompletionFences[maxPendingFrames];
438
    GraphicsContextGLState m_state;
439
    std::unique_ptr<ExtensionsGLANGLE> m_extensions;
440
441
#if PLATFORM(COCOA)
442
    GraphicsContextGLIOSurfaceSwapChain m_swapChain;
443
    EGLDisplay m_displayObj { nullptr };
444
    PlatformGraphicsContextGL m_contextObj { nullptr };
445
    PlatformGraphicsContextGLConfig m_configObj { nullptr };
446
    // Backing store for the the buffer which is eventually used for display.
447
    // When preserveDrawingBuffer == false, this is the drawing buffer backing store.
448
    // When preserveDrawingBuffer == true, this is blitted to during display prepare.
449
    std::unique_ptr<IOSurface> m_displayBufferBacking;
450
    void* m_displayBufferPbuffer { nullptr };
451
#endif
452
#if PLATFORM(MAC)
453
    bool m_switchesGPUOnDisplayReconfiguration { false };
454
    ScopedHighPerformanceGPURequest m_highPerformanceGPURequest;
455
#endif
456
#if USE(COORDINATED_GRAPHICS)
457
    GCGLuint m_compositorTexture { 0 };
458
    GCGLuint m_intermediateTexture { 0 };
459
#endif
460
#if USE(NICOSIA)
461
    std::unique_ptr<Nicosia::GCGLLayer> m_nicosiaLayer;
462
#elif USE(TEXTURE_MAPPER)
463
    std::unique_ptr<TextureMapperGCGLPlatformLayer> m_texmapLayer;
464
#endif
465
466
    friend class ExtensionsGLANGLE;
467
#if USE(NICOSIA)
468
    friend class Nicosia::GCGLLayer;
469
#elif USE(TEXTURE_MAPPER)
470
    friend class TextureMapperGCGLPlatformLayer;
471
#endif
472
};
473
474
}
475
476
#endif
- a/Source/WebCore/platform/graphics/cairo/GraphicsContextGLCairo.cpp -1 / +1 lines
Lines 106-112 bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i a/Source/WebCore/platform/graphics/cairo/GraphicsContextGLCairo.cpp_sec1
106
    return true;
106
    return true;
107
}
107
}
108
108
109
void GraphicsContextGLOpenGL::paintToCanvas(const GraphicsContextGLAttributes& sourceContextAttributes, PixelBuffer&& pixelBuffer, const IntSize& canvasSize, GraphicsContext& context)
109
void GraphicsContextGL::paintToCanvas(const GraphicsContextGLAttributes& sourceContextAttributes, PixelBuffer&& pixelBuffer, const IntSize& canvasSize, GraphicsContext& context)
110
{
110
{
111
    ASSERT(!pixelBuffer.size().isEmpty());
111
    ASSERT(!pixelBuffer.size().isEmpty());
112
    if (canvasSize.isEmpty())
112
    if (canvasSize.isEmpty())
- a/Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp -1 / +1 lines
Lines 506-512 bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i a/Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp_sec1
506
    return true;
506
    return true;
507
}
507
}
508
508
509
void GraphicsContextGLOpenGL::paintToCanvas(const GraphicsContextGLAttributes& sourceContextAttributes, PixelBuffer&& pixelBuffer, const IntSize& canvasSize, GraphicsContext& context)
509
void GraphicsContextGL::paintToCanvas(const GraphicsContextGLAttributes& sourceContextAttributes, PixelBuffer&& pixelBuffer, const IntSize& canvasSize, GraphicsContext& context)
510
{
510
{
511
    ASSERT(!pixelBuffer.size().isEmpty());
511
    ASSERT(!pixelBuffer.size().isEmpty());
512
    if (canvasSize.isEmpty())
512
    if (canvasSize.isEmpty())
- a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h -3 / +21 lines
Lines 27-41 a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h_sec1
27
27
28
#if ENABLE(WEBGL)
28
#if ENABLE(WEBGL)
29
29
30
#include "GraphicsContextGLOpenGL.h"
30
#include "GraphicsContextGLANGLE.h"
31
#include "IOSurface.h"
31
#include "IOSurface.h"
32
32
33
#if ENABLE(VIDEO)
34
namespace WebCore {
35
class GraphicsContextGLCVCocoa;
36
}
37
#endif
38
33
namespace WebCore {
39
namespace WebCore {
34
40
35
class WEBCORE_EXPORT GraphicsContextGLCocoa : public GraphicsContextGLOpenGL {
41
class WEBCORE_EXPORT GraphicsContextGLCocoa : public GraphicsContextGLANGLE {
36
public:
42
public:
37
    static RefPtr<GraphicsContextGLCocoa> create(WebCore::GraphicsContextGLAttributes&&);
43
    static RefPtr<GraphicsContextGLCocoa> create(WebCore::GraphicsContextGLAttributes&&);
38
    ~GraphicsContextGLCocoa();
44
    ~GraphicsContextGLCocoa();
45
    PlatformGraphicsContextGLDisplay platformDisplay() const { return m_displayObj; }
46
    PlatformGraphicsContextGLConfig platformConfig() const { return m_configObj; }
39
    IOSurface* displayBuffer();
47
    IOSurface* displayBuffer();
40
    void markDisplayBufferInUse();
48
    void markDisplayBufferInUse();
41
49
Lines 49-62 public: a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h_sec2
49
    void detachIOSurfaceFromSharedTexture(void* handle);
57
    void detachIOSurfaceFromSharedTexture(void* handle);
50
#endif
58
#endif
51
59
52
    // GraphicsContextGLOpenGL overrides.
60
    // GraphicsContextGLANGLE overrides.
53
#if ENABLE(VIDEO)
61
#if ENABLE(VIDEO)
54
    bool copyTextureFromMedia(MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
62
    bool copyTextureFromMedia(MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
55
#endif
63
#endif
64
#if ENABLE(VIDEO) && PLATFORM(COCOA)
65
    GraphicsContextGLCV* asCV() final;
66
#endif
56
67
57
protected:
68
protected:
58
    GraphicsContextGLCocoa(WebCore::GraphicsContextGLAttributes&&);
69
    GraphicsContextGLCocoa(WebCore::GraphicsContextGLAttributes&&);
59
    bool isValid() const;
70
    bool isValid() const;
71
72
#if ENABLE(VIDEO) && PLATFORM(COCOA)
73
    std::unique_ptr<GraphicsContextGLCVCocoa> m_cv;
74
#endif
75
#if PLATFORM(COCOA)
76
    friend class GraphicsContextGLCVCocoa;
77
#endif
60
};
78
};
61
79
62
}
80
}
- a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm -44 / +27 lines
Lines 48-54 a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec1
48
#endif
48
#endif
49
49
50
#if ENABLE(VIDEO)
50
#if ENABLE(VIDEO)
51
#include "GraphicsContextGLCVANGLE.h"
51
#include "GraphicsContextGLCVCocoa.h"
52
#include "MediaPlayerPrivate.h"
52
#include "MediaPlayerPrivate.h"
53
#endif
53
#endif
54
54
Lines 70-76 bool platformIsANGLEAvailable() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec2
70
// In isCurrentContextPredictable() == true case this variable is accessed in single-threaded manner.
70
// In isCurrentContextPredictable() == true case this variable is accessed in single-threaded manner.
71
// In isCurrentContextPredictable() == false case this variable is accessed from multiple threads but always sequentially
71
// In isCurrentContextPredictable() == false case this variable is accessed from multiple threads but always sequentially
72
// and it always contains nullptr and nullptr is always written to it.
72
// and it always contains nullptr and nullptr is always written to it.
73
static GraphicsContextGLOpenGL* currentContext;
73
static GraphicsContextGLANGLE* currentContext;
74
74
75
static bool isCurrentContextPredictable()
75
static bool isCurrentContextPredictable()
76
{
76
{
Lines 147-153 static EGLDisplay initializeEGLDisplay(const GraphicsContextGLAttributes& attrs) a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec3
147
    }
147
    }
148
148
149
    LOG(WebGL, "Attempting to use ANGLE's %s backend.", attrs.useMetal ? "Metal" : "OpenGL");
149
    LOG(WebGL, "Attempting to use ANGLE's %s backend.", attrs.useMetal ? "Metal" : "OpenGL");
150
    EGLNativeDisplayType nativeDisplay = GraphicsContextGLOpenGL::defaultDisplay;
150
    EGLNativeDisplayType nativeDisplay = GraphicsContextGLANGLE::defaultDisplay;
151
    if (attrs.useMetal) {
151
    if (attrs.useMetal) {
152
        displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
152
        displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
153
        displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE);
153
        displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE);
Lines 157-167 static EGLDisplay initializeEGLDisplay(const GraphicsContextGLAttributes& attrs) a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec4
157
        if (powerPreference == GraphicsContextGLAttributes::PowerPreference::LowPower) {
157
        if (powerPreference == GraphicsContextGLAttributes::PowerPreference::LowPower) {
158
            displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
158
            displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
159
            displayAttributes.append(EGL_LOW_POWER_ANGLE);
159
            displayAttributes.append(EGL_LOW_POWER_ANGLE);
160
            nativeDisplay = GraphicsContextGLOpenGL::lowPowerDisplay;
160
            nativeDisplay = GraphicsContextGLANGLE::lowPowerDisplay;
161
        } else if (powerPreference == GraphicsContextGLAttributes::PowerPreference::HighPerformance) {
161
        } else if (powerPreference == GraphicsContextGLAttributes::PowerPreference::HighPerformance) {
162
            displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
162
            displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
163
            displayAttributes.append(EGL_HIGH_POWER_ANGLE);
163
            displayAttributes.append(EGL_HIGH_POWER_ANGLE);
164
            nativeDisplay = GraphicsContextGLOpenGL::highPerformanceDisplay;
164
            nativeDisplay = GraphicsContextGLANGLE::highPerformanceDisplay;
165
        }
165
        }
166
    }
166
    }
167
    displayAttributes.append(EGL_NONE);
167
    displayAttributes.append(EGL_NONE);
Lines 215-227 void GraphicsContextGLCocoa::markDisplayBufferInUse() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec5
215
}
215
}
216
216
217
GraphicsContextGLCocoa::GraphicsContextGLCocoa(WebCore::GraphicsContextGLAttributes&& attributes)
217
GraphicsContextGLCocoa::GraphicsContextGLCocoa(WebCore::GraphicsContextGLAttributes&& attributes)
218
    : GraphicsContextGLOpenGL(WTFMove(attributes))
218
    : GraphicsContextGLANGLE(WTFMove(attributes))
219
{
219
{
220
}
220
}
221
221
222
// FIXME: Below is functionality that should be moved to GraphicsContextGLCocoa to simplify the base class.
222
// FIXME: Below is functionality that should be moved to GraphicsContextGLCocoa to simplify the base class.
223
223
224
GraphicsContextGLOpenGL::GraphicsContextGLOpenGL(GraphicsContextGLAttributes attrs)
224
GraphicsContextGLANGLE::GraphicsContextGLANGLE(GraphicsContextGLAttributes attrs)
225
    : GraphicsContextGL(attrs)
225
    : GraphicsContextGL(attrs)
226
{
226
{
227
    m_isForWebGL2 = attrs.webGLVersion == GraphicsContextGLWebGLVersion::WebGL2;
227
    m_isForWebGL2 = attrs.webGLVersion == GraphicsContextGLWebGLVersion::WebGL2;
Lines 356-362 GraphicsContextGLOpenGL::GraphicsContextGLOpenGL(GraphicsContextGLAttributes att a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec6
356
        extensions.ensureEnabled(extension);
356
        extensions.ensureEnabled(extension);
357
    }
357
    }
358
    if (contextAttributes().useMetal) {
358
    if (contextAttributes().useMetal) {
359
        // GraphicsContextGLOpenGL uses sync objects to throttle display on Metal implementations.
359
        // GraphicsContextGLANGLE uses sync objects to throttle display on Metal implementations.
360
        // OpenGL sync objects are not signaling upon completion on Catalina-era drivers, so
360
        // OpenGL sync objects are not signaling upon completion on Catalina-era drivers, so
361
        // OpenGL cannot use this method of throttling. OpenGL drivers typically implement
361
        // OpenGL cannot use this method of throttling. OpenGL drivers typically implement
362
        // some sort of internal throttling.
362
        // some sort of internal throttling.
Lines 410-419 GraphicsContextGLOpenGL::GraphicsContextGLOpenGL(GraphicsContextGLAttributes att a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec7
410
410
411
    gl::ClearColor(0, 0, 0, 0);
411
    gl::ClearColor(0, 0, 0, 0);
412
412
413
    LOG(WebGL, "Created a GraphicsContextGLOpenGL (%p).", this);
413
    LOG(WebGL, "Created a GraphicsContextGLANGLE (%p).", this);
414
}
414
}
415
415
416
GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL()
416
GraphicsContextGLANGLE::~GraphicsContextGLANGLE()
417
{
417
{
418
    GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
418
    GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
419
    if (makeContextCurrent()) {
419
    if (makeContextCurrent()) {
Lines 454-460 GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec8
454
    }
454
    }
455
    ASSERT(currentContext != this);
455
    ASSERT(currentContext != this);
456
    m_drawingBufferTextureTarget = -1;
456
    m_drawingBufferTextureTarget = -1;
457
    LOG(WebGL, "Destroyed a GraphicsContextGLOpenGL (%p).", this);
457
    LOG(WebGL, "Destroyed a GraphicsContextGLANGLE (%p).", this);
458
}
458
}
459
459
460
bool GraphicsContextGLCocoa::isValid() const
460
bool GraphicsContextGLCocoa::isValid() const
Lines 462-473 bool GraphicsContextGLCocoa::isValid() const a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec9
462
    return m_texture;
462
    return m_texture;
463
}
463
}
464
464
465
PlatformLayer* GraphicsContextGLOpenGL::platformLayer() const
465
PlatformLayer* GraphicsContextGLANGLE::platformLayer() const
466
{
466
{
467
    return nullptr;
467
    return nullptr;
468
}
468
}
469
469
470
bool GraphicsContextGLOpenGL::makeContextCurrent()
470
bool GraphicsContextGLANGLE::makeContextCurrent()
471
{
471
{
472
    if (!m_contextObj)
472
    if (!m_contextObj)
473
        return false;
473
        return false;
Lines 485-491 bool GraphicsContextGLOpenGL::makeContextCurrent() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec10
485
    return true;
485
    return true;
486
}
486
}
487
487
488
void GraphicsContextGLOpenGL::checkGPUStatus()
488
void GraphicsContextGLANGLE::checkGPUStatus()
489
{
489
{
490
    if (m_failNextStatusCheck) {
490
    if (m_failNextStatusCheck) {
491
        LOG(WebGL, "Pretending the GPU has reset (%p). Lose the context.", this);
491
        LOG(WebGL, "Pretending the GPU has reset (%p). Lose the context.", this);
Lines 506-512 void GraphicsContextGLOpenGL::checkGPUStatus() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec11
506
    restartStatus = 0;
506
    restartStatus = 0;
507
}
507
}
508
508
509
void GraphicsContextGLOpenGL::setContextVisibility(bool isVisible)
509
void GraphicsContextGLANGLE::setContextVisibility(bool isVisible)
510
{
510
{
511
#if PLATFORM(MAC)
511
#if PLATFORM(MAC)
512
    if (!m_switchesGPUOnDisplayReconfiguration)
512
    if (!m_switchesGPUOnDisplayReconfiguration)
Lines 520-526 void GraphicsContextGLOpenGL::setContextVisibility(bool isVisible) a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec12
520
#endif
520
#endif
521
}
521
}
522
522
523
void GraphicsContextGLOpenGL::displayWasReconfigured()
523
void GraphicsContextGLANGLE::displayWasReconfigured()
524
{
524
{
525
#if PLATFORM(MAC)
525
#if PLATFORM(MAC)
526
    if (m_switchesGPUOnDisplayReconfiguration)
526
    if (m_switchesGPUOnDisplayReconfiguration)
Lines 529-535 void GraphicsContextGLOpenGL::displayWasReconfigured() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec13
529
    dispatchContextChangedNotification();
529
    dispatchContextChangedNotification();
530
}
530
}
531
531
532
bool GraphicsContextGLOpenGL::reshapeDisplayBufferBacking()
532
bool GraphicsContextGLANGLE::reshapeDisplayBufferBacking()
533
{
533
{
534
    ASSERT(!getInternalFramebufferSize().isEmpty());
534
    ASSERT(!getInternalFramebufferSize().isEmpty());
535
    // Reset the current backbuffer now before allocating a new one in order to slightly reduce memory pressure.
535
    // Reset the current backbuffer now before allocating a new one in order to slightly reduce memory pressure.
Lines 547-553 bool GraphicsContextGLOpenGL::reshapeDisplayBufferBacking() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec14
547
    return allocateAndBindDisplayBufferBacking();
547
    return allocateAndBindDisplayBufferBacking();
548
}
548
}
549
549
550
bool GraphicsContextGLOpenGL::allocateAndBindDisplayBufferBacking()
550
bool GraphicsContextGLANGLE::allocateAndBindDisplayBufferBacking()
551
{
551
{
552
    ASSERT(!getInternalFramebufferSize().isEmpty());
552
    ASSERT(!getInternalFramebufferSize().isEmpty());
553
    auto backing = IOSurface::create(getInternalFramebufferSize(), DestinationColorSpace::SRGB());
553
    auto backing = IOSurface::create(getInternalFramebufferSize(), DestinationColorSpace::SRGB());
Lines 576-582 bool GraphicsContextGLOpenGL::allocateAndBindDisplayBufferBacking() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec15
576
    return bindDisplayBufferBacking(WTFMove(backing), pbuffer);
576
    return bindDisplayBufferBacking(WTFMove(backing), pbuffer);
577
}
577
}
578
578
579
bool GraphicsContextGLOpenGL::bindDisplayBufferBacking(std::unique_ptr<IOSurface> backing, void* pbuffer)
579
bool GraphicsContextGLANGLE::bindDisplayBufferBacking(std::unique_ptr<IOSurface> backing, void* pbuffer)
580
{
580
{
581
    GCGLenum textureTarget = drawingBufferTextureTarget();
581
    GCGLenum textureTarget = drawingBufferTextureTarget();
582
    ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
582
    ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
Lines 590-596 bool GraphicsContextGLOpenGL::bindDisplayBufferBacking(std::unique_ptr<IOSurface a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec16
590
    return true;
590
    return true;
591
}
591
}
592
592
593
bool GraphicsContextGLOpenGL::makeCurrent(PlatformGraphicsContextGLDisplay display, PlatformGraphicsContextGL context)
593
bool GraphicsContextGLANGLE::makeCurrent(PlatformGraphicsContextGLDisplay display, PlatformGraphicsContextGL context)
594
{
594
{
595
    currentContext = nullptr;
595
    currentContext = nullptr;
596
    return EGL_MakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context);
596
    return EGL_MakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context);
Lines 598-604 bool GraphicsContextGLOpenGL::makeCurrent(PlatformGraphicsContextGLDisplay displ a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec17
598
598
599
void* GraphicsContextGLCocoa::createPbufferAndAttachIOSurface(GCGLenum target, PbufferAttachmentUsage usage, GCGLenum internalFormat, GCGLsizei width, GCGLsizei height, GCGLenum type, IOSurfaceRef surface, GCGLuint plane)
599
void* GraphicsContextGLCocoa::createPbufferAndAttachIOSurface(GCGLenum target, PbufferAttachmentUsage usage, GCGLenum internalFormat, GCGLsizei width, GCGLsizei height, GCGLenum type, IOSurfaceRef surface, GCGLuint plane)
600
{
600
{
601
    if (target != GraphicsContextGLOpenGL::drawingBufferTextureTarget()) {
601
    if (target != GraphicsContextGLANGLE::drawingBufferTextureTarget()) {
602
        LOG(WebGL, "Unknown texture target %d.", static_cast<int>(target));
602
        LOG(WebGL, "Unknown texture target %d.", static_cast<int>(target));
603
        return nullptr;
603
        return nullptr;
604
    }
604
    }
Lines 667-690 void GraphicsContextGLCocoa::detachIOSurfaceFromSharedTexture(void* handle) a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec18
667
}
667
}
668
#endif
668
#endif
669
669
670
bool GraphicsContextGLOpenGL::isGLES2Compliant() const
670
void GraphicsContextGLANGLE::prepareForDisplay()
671
{
672
    return m_isForWebGL2;
673
}
674
675
void GraphicsContextGLOpenGL::simulateEventForTesting(SimulatedEventForTesting event)
676
{
677
    if (event == SimulatedEventForTesting::ContextChange) {
678
        GraphicsContextGLOpenGLManager::sharedManager().displayWasReconfigured();
679
        return;
680
    }
681
    if (event == SimulatedEventForTesting::GPUStatusFailure) {
682
        m_failNextStatusCheck = true;
683
        return;
684
    }
685
}
686
687
void GraphicsContextGLOpenGL::prepareForDisplay()
688
{
671
{
689
    if (m_layerComposited)
672
    if (m_layerComposited)
690
        return;
673
        return;
Lines 724-738 void GraphicsContextGLOpenGL::prepareForDisplay() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec19
724
707
725
708
726
#if ENABLE(VIDEO)
709
#if ENABLE(VIDEO)
727
GraphicsContextGLCV* GraphicsContextGLOpenGL::asCV()
710
GraphicsContextGLCV* GraphicsContextGLCocoa::asCV()
728
{
711
{
729
    if (!m_cv)
712
    if (!m_cv)
730
        m_cv = GraphicsContextGLCVANGLE::create(*this);
713
        m_cv = GraphicsContextGLCVCocoa::create(*this);
731
    return m_cv.get();
714
    return m_cv.get();
732
}
715
}
733
#endif
716
#endif
734
717
735
std::optional<PixelBuffer> GraphicsContextGLOpenGL::readCompositedResults()
718
std::optional<PixelBuffer> GraphicsContextGLANGLE::readCompositedResults()
736
{
719
{
737
    auto& displayBuffer = m_swapChain.displayBuffer();
720
    auto& displayBuffer = m_swapChain.displayBuffer();
738
    if (!displayBuffer.surface || !displayBuffer.handle)
721
    if (!displayBuffer.surface || !displayBuffer.handle)
Lines 764-770 std::optional<PixelBuffer> GraphicsContextGLOpenGL::readCompositedResults() a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec20
764
}
747
}
765
748
766
#if ENABLE(MEDIA_STREAM)
749
#if ENABLE(MEDIA_STREAM)
767
RefPtr<MediaSample> GraphicsContextGLOpenGL::paintCompositedResultsToMediaSample()
750
RefPtr<MediaSample> GraphicsContextGLANGLE::paintCompositedResultsToMediaSample()
768
{
751
{
769
    auto &displayBuffer = m_swapChain.displayBuffer();
752
    auto &displayBuffer = m_swapChain.displayBuffer();
770
    if (!displayBuffer.surface || !displayBuffer.handle)
753
    if (!displayBuffer.surface || !displayBuffer.handle)
Lines 779-785 RefPtr<MediaSample> GraphicsContextGLOpenGL::paintCompositedResultsToMediaSample a/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm_sec21
779
}
762
}
780
#endif
763
#endif
781
764
782
void GraphicsContextGLOpenGL::platformReleaseThreadResources()
765
void GraphicsContextGLANGLE::platformReleaseThreadResources()
783
{
766
{
784
    currentContext = nullptr;
767
    currentContext = nullptr;
785
}
768
}
- a/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVANGLE.cpp -689 lines
Lines 1-689 a/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVANGLE.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 * 
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "GraphicsContextGLCVANGLE.h"
28
29
#if ENABLE(WEBGL) && ENABLE(VIDEO) && USE(AVFOUNDATION)
30
31
#include "ANGLEUtilitiesCocoa.h"
32
#include "FourCC.h"
33
#include "GraphicsContextGLOpenGL.h"
34
#include "Logging.h"
35
#include <pal/spi/cf/CoreVideoSPI.h>
36
#include <pal/spi/cocoa/IOSurfaceSPI.h>
37
#include <wtf/NeverDestroyed.h>
38
#include <wtf/Scope.h>
39
#include <wtf/StdMap.h>
40
#include <wtf/cf/TypeCastsCF.h>
41
#include <wtf/text/StringBuilder.h>
42
43
#include "CoreVideoSoftLink.h"
44
45
namespace WebCore {
46
47
static constexpr auto s_yuvVertexShaderTexture2D {
48
    "attribute vec2 a_position;"
49
    "uniform vec2 u_yTextureSize;"
50
    "uniform vec2 u_uvTextureSize;"
51
    "uniform int u_flipY;"
52
    "varying vec2 v_yTextureCoordinate;"
53
    "varying vec2 v_uvTextureCoordinate;"
54
    "void main()"
55
    "{"
56
    "    gl_Position = vec4(a_position, 0, 1.0);"
57
    "    vec2 normalizedPosition = a_position * .5 + .5;"
58
    "    if (u_flipY == 1)"
59
    "        normalizedPosition.y = 1.0 - normalizedPosition.y;"
60
    "    v_yTextureCoordinate = normalizedPosition;"
61
    "    v_uvTextureCoordinate = normalizedPosition;"
62
    "}"_s
63
};
64
65
static constexpr auto s_yuvVertexShaderTextureRectangle {
66
    "attribute vec2 a_position;"
67
    "uniform vec2 u_yTextureSize;"
68
    "uniform vec2 u_uvTextureSize;"
69
    "uniform int u_flipY;"
70
    "varying vec2 v_yTextureCoordinate;"
71
    "varying vec2 v_uvTextureCoordinate;"
72
    "void main()"
73
    "{"
74
    "    gl_Position = vec4(a_position, 0, 1.0);"
75
    "    vec2 normalizedPosition = a_position * .5 + .5;"
76
    "    if (u_flipY == 1)"
77
    "        normalizedPosition.y = 1.0 - normalizedPosition.y;"
78
    "    v_yTextureCoordinate = normalizedPosition * u_yTextureSize;"
79
    "    v_uvTextureCoordinate = normalizedPosition * u_uvTextureSize;"
80
    "}"_s
81
};
82
83
constexpr auto s_yuvFragmentShaderTexture2D {
84
    "precision mediump float;"
85
    "uniform sampler2D u_yTexture;"
86
    "uniform sampler2D u_uvTexture;"
87
    "uniform mat4 u_colorMatrix;"
88
    "varying vec2 v_yTextureCoordinate;"
89
    "varying vec2 v_uvTextureCoordinate;"
90
    "void main()"
91
    "{"
92
    "    vec4 yuv;"
93
    "    yuv.r = texture2D(u_yTexture, v_yTextureCoordinate).r;"
94
    "    yuv.gb = texture2D(u_uvTexture, v_uvTextureCoordinate).rg;"
95
    "    yuv.a = 1.0;"
96
    "    gl_FragColor = yuv * u_colorMatrix;"
97
    "}"_s
98
};
99
100
static constexpr auto s_yuvFragmentShaderTextureRectangle {
101
    "precision mediump float;"
102
    "uniform sampler2DRect u_yTexture;"
103
    "uniform sampler2DRect u_uvTexture;"
104
    "uniform mat4 u_colorMatrix;"
105
    "varying vec2 v_yTextureCoordinate;"
106
    "varying vec2 v_uvTextureCoordinate;"
107
    "void main()"
108
    "{"
109
    "    vec4 yuv;"
110
    "    yuv.r = texture2DRect(u_yTexture, v_yTextureCoordinate).r;"
111
    "    yuv.gb = texture2DRect(u_uvTexture, v_uvTextureCoordinate).rg;"
112
    "    yuv.a = 1.0;"
113
    "    gl_FragColor = yuv * u_colorMatrix;"
114
    "}"_s
115
};
116
117
enum class PixelRange {
118
    Unknown,
119
    Video,
120
    Full,
121
};
122
123
enum class TransferFunctionCV {
124
    Unknown,
125
    kITU_R_709_2,
126
    kITU_R_601_4,
127
    kSMPTE_240M_1995,
128
    kDCI_P3,
129
    kP3_D65,
130
    kITU_R_2020,
131
};
132
133
static PixelRange pixelRangeFromPixelFormat(OSType pixelFormat)
134
{
135
    switch (pixelFormat) {
136
    case kCVPixelFormatType_4444AYpCbCr8:
137
    case kCVPixelFormatType_4444AYpCbCr16:
138
    case kCVPixelFormatType_422YpCbCr_4A_8BiPlanar:
139
    case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
140
    case kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange:
141
    case kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange:
142
    case kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange:
143
#if HAVE(COREVIDEO_COMPRESSED_PIXEL_FORMAT_TYPES)
144
    case kCVPixelFormatType_AGX_420YpCbCr8BiPlanarVideoRange:
145
#endif
146
        return PixelRange::Video;
147
    case kCVPixelFormatType_420YpCbCr8PlanarFullRange:
148
    case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange:
149
    case kCVPixelFormatType_422YpCbCr8FullRange:
150
    case kCVPixelFormatType_ARGB2101010LEPacked:
151
    case kCVPixelFormatType_420YpCbCr10BiPlanarFullRange:
152
    case kCVPixelFormatType_422YpCbCr10BiPlanarFullRange:
153
    case kCVPixelFormatType_444YpCbCr10BiPlanarFullRange:
154
#if HAVE(COREVIDEO_COMPRESSED_PIXEL_FORMAT_TYPES)
155
    case kCVPixelFormatType_AGX_420YpCbCr8BiPlanarFullRange:
156
#endif
157
        return PixelRange::Full;
158
    default:
159
        return PixelRange::Unknown;
160
    }
161
}
162
163
static TransferFunctionCV transferFunctionFromString(CFStringRef string)
164
{
165
    if (!string)
166
        return TransferFunctionCV::Unknown;
167
    if (CFEqual(string, kCVImageBufferYCbCrMatrix_ITU_R_709_2))
168
        return TransferFunctionCV::kITU_R_709_2;
169
    if (CFEqual(string, kCVImageBufferYCbCrMatrix_ITU_R_601_4))
170
        return TransferFunctionCV::kITU_R_601_4;
171
    if (CFEqual(string, kCVImageBufferYCbCrMatrix_SMPTE_240M_1995))
172
        return TransferFunctionCV::kSMPTE_240M_1995;
173
    if (canLoad_CoreVideo_kCVImageBufferYCbCrMatrix_DCI_P3() && CFEqual(string, kCVImageBufferYCbCrMatrix_DCI_P3))
174
        return TransferFunctionCV::kDCI_P3;
175
    if (canLoad_CoreVideo_kCVImageBufferYCbCrMatrix_P3_D65() && CFEqual(string, kCVImageBufferYCbCrMatrix_P3_D65))
176
        return TransferFunctionCV::kP3_D65;
177
    if (canLoad_CoreVideo_kCVImageBufferYCbCrMatrix_ITU_R_2020() && CFEqual(string, kCVImageBufferYCbCrMatrix_ITU_R_2020))
178
        return TransferFunctionCV::kITU_R_2020;
179
    return TransferFunctionCV::Unknown;
180
}
181
182
struct GLfloatColor {
183
    union {
184
        struct {
185
            GLfloat r;
186
            GLfloat g;
187
            GLfloat b;
188
        } rgb;
189
        struct {
190
            GLfloat y;
191
            GLfloat cb;
192
            GLfloat cr;
193
        } ycbcr;
194
    };
195
196
    constexpr GLfloatColor(GLfloat r, GLfloat g, GLfloat b)
197
        : rgb { r, g, b }
198
    {
199
    }
200
201
    constexpr GLfloatColor(int r, int g, int b, GLfloat scale)
202
        : rgb { r / scale, g / scale, b / scale}
203
    {
204
    }
205
206
    static constexpr GLfloat abs(GLfloat value)
207
    {
208
        return value >= 0 ? value : -value;
209
    }
210
211
    constexpr bool isApproximatelyEqualTo(const GLfloatColor& color, GLfloat maxDelta) const
212
    {
213
        return abs(rgb.r - color.rgb.r) < abs(maxDelta)
214
            && abs(rgb.g - color.rgb.g) < abs(maxDelta)
215
            && abs(rgb.b - color.rgb.b) < abs(maxDelta);
216
    }
217
};
218
219
struct GLfloatColors {
220
    static constexpr GLfloatColor black   {0, 0, 0};
221
    static constexpr GLfloatColor white   {1, 1, 1};
222
    static constexpr GLfloatColor red     {1, 0, 0};
223
    static constexpr GLfloatColor green   {0, 1, 0};
224
    static constexpr GLfloatColor blue    {0, 0, 1};
225
    static constexpr GLfloatColor cyan    {0, 1, 1};
226
    static constexpr GLfloatColor magenta {1, 0, 1};
227
    static constexpr GLfloatColor yellow  {1, 1, 0};
228
};
229
230
struct YCbCrMatrix {
231
        GLfloat rows[4][4];
232
233
    constexpr YCbCrMatrix(PixelRange, GLfloat cbCoefficient, GLfloat crCoefficient);
234
235
    operator const GLfloat*() const
236
    {
237
        return &rows[0][0];
238
    }
239
240
    constexpr GLfloatColor operator*(const GLfloatColor&) const;
241
};
242
243
constexpr YCbCrMatrix::YCbCrMatrix(PixelRange range, GLfloat cbCoefficient, GLfloat crCoefficient)
244
    : rows { }
245
{
246
    // The conversion from YCbCr -> RGB generally takes the form:
247
    // Y = Kr * R + Kg * G + Kb * B
248
    // Cb = (B - Y) / (2 * (1 - Kb))
249
    // Cr = (R - Y) / (2 * (1 - Kr))
250
    // Where the values of Kb and Kr are defined in a specification and Kg is derived from: Kr + Kg + Kb = 1
251
    //
252
    // Solving the above equations for R, B, and G derives the following:
253
    // R = Y + (2 * (1 - Kr)) * Cr
254
    // B = Y + (2 * (1 - Kb)) * Cb
255
    // G = Y - (2 * (1 - Kb)) * (Kb / Kg) * Cb - ((1 - Kr) * 2) * (Kr / Kg) * Cr
256
    //
257
    // When the color values are Video range, Y has a range of [16, 235] with a width of 219, and Cb & Cr have
258
    // a range of [16, 240] with a width of 224. When the color values are Full range, Y, Cb, and Cr all have
259
    // a range of [0, 255] with a width of 256.
260
261
    GLfloat cgCoefficient = 1 - cbCoefficient - crCoefficient;
262
    GLfloat yScalingFactor = range == PixelRange::Full ? 1.f : 255.f / 219.f;
263
    GLfloat cbcrScalingFactor = range == PixelRange::Full ? 1.f : 255.f / 224.f;
264
265
    rows[0][0] = yScalingFactor;
266
    rows[0][1] = 0;
267
    rows[0][2] = cbcrScalingFactor * 2 * (1 - crCoefficient);
268
    rows[0][3] = 0;
269
270
    rows[1][0] = yScalingFactor;
271
    rows[1][1] = -cbcrScalingFactor * 2 * (1 - cbCoefficient) * (cbCoefficient / cgCoefficient);
272
    rows[1][2] = -cbcrScalingFactor * 2 * (1 - crCoefficient) * (crCoefficient / cgCoefficient);
273
    rows[1][3] = 0;
274
275
    rows[2][0] = yScalingFactor;
276
    rows[2][1] = cbcrScalingFactor * 2 * (1 - cbCoefficient);
277
    rows[2][2] = 0;
278
    rows[2][3] = 0;
279
280
    rows[3][0] = 0;
281
    rows[3][1] = 0;
282
    rows[3][2] = 0;
283
    rows[3][3] = 1;
284
285
    // Configure the final column of the matrix to convert Cb and Cr to [-128, 128]
286
    // and, in the case of video-range, to convert Y to [16, 240]:
287
    for (auto rowNumber = 0; rowNumber < 3; ++rowNumber) {
288
        auto& row = rows[rowNumber];
289
        auto& x = row[0];
290
        auto& y = row[1];
291
        auto& z = row[2];
292
        auto& w = row[3];
293
294
        w -= (y + z) * 128 / 255;
295
        if (range == PixelRange::Video)
296
            w -= x * 16 / 255;
297
    }
298
}
299
300
constexpr GLfloatColor YCbCrMatrix::operator*(const GLfloatColor& color) const
301
{
302
    return GLfloatColor(
303
        rows[0][0] * color.rgb.r + rows[0][1] * color.rgb.g + rows[0][2] * color.rgb.b + rows[0][3],
304
        rows[1][0] * color.rgb.r + rows[1][1] * color.rgb.g + rows[1][2] * color.rgb.b + rows[1][3],
305
        rows[2][0] * color.rgb.r + rows[2][1] * color.rgb.g + rows[2][2] * color.rgb.b + rows[2][3]
306
    );
307
}
308
309
static const GLfloat* YCbCrToRGBMatrixForRangeAndTransferFunction(PixelRange range, TransferFunctionCV transferFunction)
310
{
311
    using MapKey = std::pair<PixelRange, TransferFunctionCV>;
312
    using MatrixMap = StdMap<MapKey, const YCbCrMatrix&>;
313
314
    static NeverDestroyed<MatrixMap> matrices;
315
    static dispatch_once_t onceToken;
316
317
    // Matrices are derived from the components in the ITU R.601 rev 4 specification
318
    // https://www.itu.int/rec/R-REC-BT.601
319
    constexpr static YCbCrMatrix r601VideoMatrix { PixelRange::Video, 0.114f, 0.299f };
320
    constexpr static YCbCrMatrix r601FullMatrix { PixelRange::Full, 0.114f, 0.299f };
321
322
    static_assert((r601VideoMatrix * GLfloatColor(16,  128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "r.610 video matrix does not produce black color");
323
    static_assert((r601VideoMatrix * GLfloatColor(235, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "r.610 video matrix does not produce white color");
324
    static_assert((r601VideoMatrix * GLfloatColor(81,  90,  240, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "r.610 video matrix does not produce red color");
325
    static_assert((r601VideoMatrix * GLfloatColor(145, 54,  34,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "r.610 video matrix does not produce green color");
326
    static_assert((r601VideoMatrix * GLfloatColor(41,  240, 110, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "r.610 video matrix does not produce blue color");
327
    static_assert((r601VideoMatrix * GLfloatColor(210, 16,  146, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "r.610 video matrix does not produce yellow color");
328
    static_assert((r601VideoMatrix * GLfloatColor(106, 202, 222, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "r.610 video matrix does not produce magenta color");
329
    static_assert((r601VideoMatrix * GLfloatColor(170, 166, 16,  255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "r.610 video matrix does not produce cyan color");
330
331
    static_assert((r601FullMatrix * GLfloatColor(0,   128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "r.610 full matrix does not produce black color");
332
    static_assert((r601FullMatrix * GLfloatColor(255, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "r.610 full matrix does not produce white color");
333
    static_assert((r601FullMatrix * GLfloatColor(76,  85,  255, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "r.610 full matrix does not produce red color");
334
    static_assert((r601FullMatrix * GLfloatColor(150, 44,  21,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "r.610 full matrix does not produce green color");
335
    static_assert((r601FullMatrix * GLfloatColor(29,  255, 107, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "r.610 full matrix does not produce blue color");
336
    static_assert((r601FullMatrix * GLfloatColor(226, 0,   149, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "r.610 full matrix does not produce yellow color");
337
    static_assert((r601FullMatrix * GLfloatColor(105, 212, 235, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "r.610 full matrix does not produce magenta color");
338
    static_assert((r601FullMatrix * GLfloatColor(179, 171, 1,   255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "r.610 full matrix does not produce cyan color");
339
340
    // Matrices are derived from the components in the ITU R.709 rev 2 specification
341
    // https://www.itu.int/rec/R-REC-BT.709-2-199510-S
342
    constexpr static YCbCrMatrix r709VideoMatrix { PixelRange::Video, 0.0722, 0.2126 };
343
    constexpr static YCbCrMatrix r709FullMatrix { PixelRange::Full, 0.0722, 0.2126 };
344
345
    static_assert((r709VideoMatrix * GLfloatColor(16,  128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "r.709 video matrix does not produce black color");
346
    static_assert((r709VideoMatrix * GLfloatColor(235, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "r.709 video matrix does not produce white color");
347
    static_assert((r709VideoMatrix * GLfloatColor(63,  102, 240, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "r.709 video matrix does not produce red color");
348
    static_assert((r709VideoMatrix * GLfloatColor(173, 42,  26,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "r.709 video matrix does not produce green color");
349
    static_assert((r709VideoMatrix * GLfloatColor(32,  240, 118, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "r.709 video matrix does not produce blue color");
350
    static_assert((r709VideoMatrix * GLfloatColor(219, 16,  138, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "r.709 video matrix does not produce yellow color");
351
    static_assert((r709VideoMatrix * GLfloatColor(78,  214, 230, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "r.709 video matrix does not produce magenta color");
352
    static_assert((r709VideoMatrix * GLfloatColor(188, 154, 16,  255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "r.709 video matrix does not produce cyan color");
353
354
    static_assert((r709FullMatrix * GLfloatColor(0,   128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "r.709 full matrix does not produce black color");
355
    static_assert((r709FullMatrix * GLfloatColor(255, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "r.709 full matrix does not produce white color");
356
    static_assert((r709FullMatrix * GLfloatColor(54,  99,  256, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "r.709 full matrix does not produce red color");
357
    static_assert((r709FullMatrix * GLfloatColor(182, 30,  12,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "r.709 full matrix does not produce green color");
358
    static_assert((r709FullMatrix * GLfloatColor(18,  256, 116, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "r.709 full matrix does not produce blue color");
359
    static_assert((r709FullMatrix * GLfloatColor(237, 1,   140, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "r.709 full matrix does not produce yellow color");
360
    static_assert((r709FullMatrix * GLfloatColor(73,  226, 244, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "r.709 full matrix does not produce magenta color");
361
    static_assert((r709FullMatrix * GLfloatColor(201, 157, 1,   255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "r.709 full matrix does not produce cyan color");
362
363
    // Matrices are derived from the components in the ITU-R BT.2020-2 specification
364
    // https://www.itu.int/rec/R-REC-BT.2020
365
    constexpr static YCbCrMatrix bt2020VideoMatrix { PixelRange::Video, 0.0593, 0.2627 };
366
    constexpr static YCbCrMatrix bt2020FullMatrix { PixelRange::Full, 0.0593, 0.2627 };
367
368
    static_assert((bt2020VideoMatrix * GLfloatColor(16,  128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "bt.2020 video matrix does not produce black color");
369
    static_assert((bt2020VideoMatrix * GLfloatColor(235, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "bt.2020 video matrix does not produce white color");
370
    static_assert((bt2020VideoMatrix * GLfloatColor(74,  97,  240, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "bt.2020 video matrix does not produce red color");
371
    static_assert((bt2020VideoMatrix * GLfloatColor(164, 47,  25,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "bt.2020 video matrix does not produce green color");
372
    static_assert((bt2020VideoMatrix * GLfloatColor(29,  240, 119, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "bt.2020 video matrix does not produce blue color");
373
    static_assert((bt2020VideoMatrix * GLfloatColor(222, 16,  137, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "bt.2020 video matrix does not produce yellow color");
374
    static_assert((bt2020VideoMatrix * GLfloatColor(87,  209, 231, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "bt.2020 video matrix does not produce magenta color");
375
    static_assert((bt2020VideoMatrix * GLfloatColor(177, 159, 16,  255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "bt.2020 video matrix does not produce cyan color");
376
377
    static_assert((bt2020FullMatrix * GLfloatColor(0,   128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "bt.2020 full matrix does not produce black color");
378
    static_assert((bt2020FullMatrix * GLfloatColor(255, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "bt.2020 full matrix does not produce white color");
379
    static_assert((bt2020FullMatrix * GLfloatColor(67,  92,  256, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "bt.2020 full matrix does not produce red color");
380
    static_assert((bt2020FullMatrix * GLfloatColor(173, 36,  11,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "bt.2020 full matrix does not produce green color");
381
    static_assert((bt2020FullMatrix * GLfloatColor(15,  256, 118, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "bt.2020 full matrix does not produce blue color");
382
    static_assert((bt2020FullMatrix * GLfloatColor(240, 0,   138, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "bt.2020 full matrix does not produce yellow color");
383
    static_assert((bt2020FullMatrix * GLfloatColor(82,  220, 245, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "bt.2020 full matrix does not produce magenta color");
384
    static_assert((bt2020FullMatrix * GLfloatColor(188, 164, 1,   255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "bt.2020 full matrix does not produce cyan color");
385
386
    // Matrices are derived from the components in the SMPTE 240M-1999 specification
387
    // http://ieeexplore.ieee.org/document/7291461/
388
    constexpr static YCbCrMatrix smpte240MVideoMatrix { PixelRange::Video, 0.087, 0.212 };
389
    constexpr static YCbCrMatrix smpte240MFullMatrix { PixelRange::Full, 0.087, 0.212 };
390
391
    static_assert((smpte240MVideoMatrix * GLfloatColor(16,  128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "SMPTE 240M video matrix does not produce black color");
392
    static_assert((smpte240MVideoMatrix * GLfloatColor(235, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "SMPTE 240M video matrix does not produce white color");
393
    static_assert((smpte240MVideoMatrix * GLfloatColor(62,  102, 240, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "SMPTE 240M video matrix does not produce red color");
394
    static_assert((smpte240MVideoMatrix * GLfloatColor(170, 42,  28,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "SMPTE 240M video matrix does not produce green color");
395
    static_assert((smpte240MVideoMatrix * GLfloatColor(35,  240, 116, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "SMPTE 240M video matrix does not produce blue color");
396
    static_assert((smpte240MVideoMatrix * GLfloatColor(216, 16,  140, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "SMPTE 240M video matrix does not produce yellow color");
397
    static_assert((smpte240MVideoMatrix * GLfloatColor(81,  214, 228, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "SMPTE 240M video matrix does not produce magenta color");
398
    static_assert((smpte240MVideoMatrix * GLfloatColor(189, 154, 16,  255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "SMPTE 240M video matrix does not produce cyan color");
399
400
    static_assert((smpte240MFullMatrix * GLfloatColor(0,   128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "SMPTE 240M full matrix does not produce black color");
401
    static_assert((smpte240MFullMatrix * GLfloatColor(255, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "SMPTE 240M full matrix does not produce white color");
402
    static_assert((smpte240MFullMatrix * GLfloatColor(54,  98,  256, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "SMPTE 240M full matrix does not produce red color");
403
    static_assert((smpte240MFullMatrix * GLfloatColor(179, 30,  15,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "SMPTE 240M full matrix does not produce green color");
404
    static_assert((smpte240MFullMatrix * GLfloatColor(22,  256, 114, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "SMPTE 240M full matrix does not produce blue color");
405
    static_assert((smpte240MFullMatrix * GLfloatColor(233, 1,   142, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "SMPTE 240M full matrix does not produce yellow color");
406
    static_assert((smpte240MFullMatrix * GLfloatColor(76,  226, 241, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "SMPTE 240M full matrix does not produce magenta color");
407
    static_assert((smpte240MFullMatrix * GLfloatColor(201, 158, 1,   255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "SMPTE 240M full matrix does not produce cyan color");
408
409
    dispatch_once(&onceToken, ^{
410
        matrices.get().emplace(MapKey(PixelRange::Video, TransferFunctionCV::kITU_R_601_4), r601VideoMatrix);
411
        matrices.get().emplace(MapKey(PixelRange::Full, TransferFunctionCV::kITU_R_601_4), r601FullMatrix);
412
        matrices.get().emplace(MapKey(PixelRange::Video, TransferFunctionCV::kITU_R_709_2), r709VideoMatrix);
413
        matrices.get().emplace(MapKey(PixelRange::Full, TransferFunctionCV::kITU_R_709_2), r709FullMatrix);
414
        matrices.get().emplace(MapKey(PixelRange::Video, TransferFunctionCV::kITU_R_2020), bt2020VideoMatrix);
415
        matrices.get().emplace(MapKey(PixelRange::Full, TransferFunctionCV::kITU_R_2020), bt2020FullMatrix);
416
        matrices.get().emplace(MapKey(PixelRange::Video, TransferFunctionCV::kSMPTE_240M_1995), smpte240MVideoMatrix);
417
        matrices.get().emplace(MapKey(PixelRange::Full, TransferFunctionCV::kSMPTE_240M_1995), smpte240MFullMatrix);
418
    });
419
420
    // We should never be asked to handle a Pixel Format whose range value is unknown.
421
    ASSERT(range != PixelRange::Unknown);
422
    if (range == PixelRange::Unknown)
423
        range = PixelRange::Full;
424
425
    auto iterator = matrices.get().find({range, transferFunction});
426
427
    // Assume unknown transfer functions are r.601:
428
    if (iterator == matrices.get().end())
429
        iterator = matrices.get().find({range, TransferFunctionCV::kITU_R_601_4});
430
431
    ASSERT(iterator != matrices.get().end());
432
    return iterator->second;
433
}
434
435
std::unique_ptr<GraphicsContextGLCVANGLE> GraphicsContextGLCVANGLE::create(GraphicsContextGLOpenGL& context)
436
{
437
    std::unique_ptr<GraphicsContextGLCVANGLE> cv { new GraphicsContextGLCVANGLE(context) };
438
    if (!cv->m_context)
439
        return nullptr;
440
    return cv;
441
}
442
443
GraphicsContextGLCVANGLE::~GraphicsContextGLCVANGLE()
444
{
445
    if (!m_context || !GraphicsContextGLOpenGL::makeCurrent(m_display, m_context))
446
        return;
447
    gl::DeleteBuffers(1, &m_yuvVertexBuffer);
448
    gl::DeleteFramebuffers(1, &m_framebuffer);
449
    EGL_DestroyContext(m_display, m_context);
450
}
451
452
GraphicsContextGLCVANGLE::GraphicsContextGLCVANGLE(GraphicsContextGLOpenGL& owner)
453
    : m_owner(owner)
454
{
455
    // Create compatible context that shares state with owner, but one that does not
456
    // have robustness or WebGL compatibility.
457
    const EGLint contextAttributes[] = {
458
        EGL_CONTEXT_CLIENT_VERSION,
459
        owner.m_isForWebGL2 ? 3 : 2,
460
        EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE,
461
        EGL_FALSE,
462
        EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE,
463
        EGL_FALSE,
464
        EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM,
465
        EGL_FALSE,
466
        EGL_NONE
467
    };
468
    EGLDisplay display = owner.platformDisplay();
469
    EGLConfig config = owner.platformConfig();
470
    EGLContext context = EGL_CreateContext(display, config, owner.m_contextObj, contextAttributes);
471
    if (context == EGL_NO_CONTEXT)
472
        return;
473
    GraphicsContextGLOpenGL::makeCurrent(display, context);
474
475
    auto contextCleanup = makeScopeExit([display, context] {
476
        GraphicsContextGLOpenGL::makeCurrent(display, EGL_NO_CONTEXT);
477
        EGL_DestroyContext(display, context);
478
    });
479
480
    const bool useTexture2D = m_owner.drawingBufferTextureTarget() == GL_TEXTURE_2D;
481
482
#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
483
    if (!useTexture2D) {
484
        gl::RequestExtensionANGLE("GL_ANGLE_texture_rectangle");
485
        gl::RequestExtensionANGLE("GL_EXT_texture_format_BGRA8888");
486
        if (gl::GetError() != GL_NO_ERROR)
487
            return;
488
    }
489
#endif
490
491
    GLint vertexShader = gl::CreateShader(GL_VERTEX_SHADER);
492
    GLint fragmentShader = gl::CreateShader(GL_FRAGMENT_SHADER);
493
    GLuint yuvProgram = gl::CreateProgram();
494
    auto programCleanup = makeScopeExit([vertexShader, fragmentShader, yuvProgram] {
495
        gl::DeleteShader(vertexShader);
496
        gl::DeleteShader(fragmentShader);
497
        gl::DeleteProgram(yuvProgram);
498
    });
499
    // These are written so strlen might be compile-time.
500
    GLint vsLength = useTexture2D ? s_yuvVertexShaderTexture2D.length() : s_yuvVertexShaderTextureRectangle.length();
501
    GLint fsLength = useTexture2D ? s_yuvFragmentShaderTexture2D.length() : s_yuvFragmentShaderTextureRectangle.length();
502
    const char* vertexShaderSource = useTexture2D ? s_yuvVertexShaderTexture2D : s_yuvVertexShaderTextureRectangle;
503
    const char* fragmentShaderSource = useTexture2D ? s_yuvFragmentShaderTexture2D : s_yuvFragmentShaderTextureRectangle;
504
505
    gl::ShaderSource(vertexShader, 1, &vertexShaderSource, &vsLength);
506
    gl::ShaderSource(fragmentShader, 1, &fragmentShaderSource, &fsLength);
507
    gl::CompileShader(vertexShader);
508
    gl::CompileShader(fragmentShader);
509
    gl::AttachShader(yuvProgram, vertexShader);
510
    gl::AttachShader(yuvProgram, fragmentShader);
511
    gl::LinkProgram(yuvProgram);
512
    // Link status is checked afterwards for theoretical parallel compilation benefit.
513
514
    GLuint yuvVertexBuffer = 0;
515
    gl::GenBuffers(1, &yuvVertexBuffer);
516
    auto yuvVertexBufferCleanup = makeScopeExit([yuvVertexBuffer] {
517
        gl::DeleteBuffers(1, &yuvVertexBuffer);
518
    });
519
    float vertices[12] = { -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1 };
520
    gl::BindBuffer(GL_ARRAY_BUFFER, yuvVertexBuffer);
521
    gl::BufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
522
523
    GLuint framebuffer = 0;
524
    gl::GenFramebuffers(1, &framebuffer);
525
    auto framebufferCleanup = makeScopeExit([framebuffer] {
526
        gl::DeleteFramebuffers(1, &framebuffer);
527
    });
528
529
    GLint status = 0;
530
    gl::GetProgramivRobustANGLE(yuvProgram, GL_LINK_STATUS, 1, nullptr, &status);
531
    if (!status) {
532
        GLint vsStatus = 0;
533
        gl::GetShaderivRobustANGLE(vertexShader, GL_COMPILE_STATUS, 1, nullptr, &vsStatus);
534
        GLint fsStatus = 0;
535
        gl::GetShaderivRobustANGLE(fragmentShader, GL_COMPILE_STATUS, 1, nullptr, &fsStatus);
536
        LOG(WebGL, "GraphicsContextGLCVANGLE(%p) - YUV program failed to link: %d, %d, %d.", this, status, vsStatus, fsStatus);
537
        return;
538
    }
539
    contextCleanup.release();
540
    yuvVertexBufferCleanup.release();
541
    framebufferCleanup.release();
542
    m_display = display;
543
    m_context = context;
544
    m_config = config;
545
    m_yuvVertexBuffer = yuvVertexBuffer;
546
    m_framebuffer = framebuffer;
547
    m_yTextureUniformLocation = gl::GetUniformLocation(yuvProgram, "u_yTexture");
548
    m_uvTextureUniformLocation = gl::GetUniformLocation(yuvProgram, "u_uvTexture");
549
    m_colorMatrixUniformLocation = gl::GetUniformLocation(yuvProgram, "u_colorMatrix");
550
    m_yuvFlipYUniformLocation = gl::GetUniformLocation(yuvProgram, "u_flipY");
551
    m_yTextureSizeUniformLocation = gl::GetUniformLocation(yuvProgram, "u_yTextureSize");
552
    m_uvTextureSizeUniformLocation = gl::GetUniformLocation(yuvProgram, "u_uvTextureSize");
553
    m_yuvPositionAttributeLocation = gl::GetAttribLocation(yuvProgram, "a_position");
554
    // Program is deleted by the cleanup while the program binary stays in use.
555
    gl::UseProgram(yuvProgram);
556
    gl::EnableVertexAttribArray(m_yuvPositionAttributeLocation);
557
    gl::VertexAttribPointer(m_yuvPositionAttributeLocation, 2, GL_FLOAT, false, 0, 0);
558
    gl::ClearColor(0, 0, 0, 0);
559
    gl::BindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
560
}
561
562
bool GraphicsContextGLCVANGLE::copyPixelBufferToTexture(CVPixelBufferRef image, PlatformGLObject outputTexture, GLint level, GLenum internalFormat, GLenum format, GLenum type, FlipY flipY)
563
{
564
    // FIXME: This currently only supports '420v' and '420f' pixel formats. Investigate supporting more pixel formats.
565
    OSType pixelFormat = CVPixelBufferGetPixelFormatType(image);
566
    if (pixelFormat != kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
567
        && pixelFormat != kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
568
#if HAVE(COREVIDEO_COMPRESSED_PIXEL_FORMAT_TYPES)
569
        && pixelFormat != kCVPixelFormatType_AGX_420YpCbCr8BiPlanarVideoRange
570
        && pixelFormat != kCVPixelFormatType_AGX_420YpCbCr8BiPlanarFullRange
571
#endif
572
        ) {
573
        LOG(WebGL, "GraphicsContextGLCVANGLE::copyVideoTextureToPlatformTexture(%p) - Asked to copy an unsupported pixel format ('%s').", this, FourCC(pixelFormat).toString().utf8().data());
574
        return false;
575
    }
576
    IOSurfaceRef surface = CVPixelBufferGetIOSurface(image);
577
    if (!surface)
578
        return false;
579
580
    auto newSurfaceSeed = IOSurfaceGetSeed(surface);
581
    if (flipY == m_lastFlipY
582
        && surface == m_lastSurface
583
        && newSurfaceSeed == m_lastSurfaceSeed
584
        && lastTextureSeed(outputTexture) == m_owner.textureSeed(outputTexture)) {
585
        // If the texture hasn't been modified since the last time we copied to it, and the
586
        // image hasn't been modified since the last time it was copied, this is a no-op.
587
        return true;
588
    }
589
    if (!m_context || !GraphicsContextGLOpenGL::makeCurrent(m_display, m_context))
590
        return false;
591
592
    size_t width = CVPixelBufferGetWidth(image);
593
    size_t height = CVPixelBufferGetHeight(image);
594
595
    gl::Viewport(0, 0, width, height);
596
597
    // The outputTexture might contain uninitialized content on early-outs. Clear it in cases
598
    // autoClearTextureOnError is not reset.
599
    auto autoClearTextureOnError = makeScopeExit([outputTexture, level, internalFormat, format, type] {
600
        gl::BindTexture(GL_TEXTURE_2D, outputTexture);
601
        gl::TexImage2D(GL_TEXTURE_2D, level, internalFormat, 0, 0, 0, format, type, nullptr);
602
        gl::BindTexture(GL_TEXTURE_2D, 0);
603
    });
604
    // Allocate memory for the output texture.
605
    gl::BindTexture(GL_TEXTURE_2D, outputTexture);
606
    gl::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
607
    gl::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
608
    gl::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
609
    gl::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
610
    gl::TexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, 0, format, type, nullptr);
611
612
    gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, outputTexture, level);
613
    GLenum status = gl::CheckFramebufferStatus(GL_FRAMEBUFFER);
614
    if (status != GL_FRAMEBUFFER_COMPLETE) {
615
        LOG(WebGL, "GraphicsContextGLCVANGLE::copyVideoTextureToPlatformTexture(%p) - Unable to create framebuffer for outputTexture.", this);
616
        return false;
617
    }
618
    gl::BindTexture(GL_TEXTURE_2D, 0);
619
620
    // Bind and set up the textures for the video source.
621
    auto yPlaneWidth = IOSurfaceGetWidthOfPlane(surface, 0);
622
    auto yPlaneHeight = IOSurfaceGetHeightOfPlane(surface, 0);
623
    auto uvPlaneWidth = IOSurfaceGetWidthOfPlane(surface, 1);
624
    auto uvPlaneHeight = IOSurfaceGetHeightOfPlane(surface, 1);
625
626
    GLenum videoTextureTarget = m_owner.drawingBufferTextureTarget();
627
628
    GLuint uvTexture = 0;
629
    gl::GenTextures(1, &uvTexture);
630
    auto uvTextureCleanup = makeScopeExit([uvTexture] {
631
        gl::DeleteTextures(1, &uvTexture);
632
    });
633
    gl::ActiveTexture(GL_TEXTURE1);
634
    gl::BindTexture(videoTextureTarget, uvTexture);
635
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
636
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
637
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
638
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
639
    auto uvHandle = WebCore::createPbufferAndAttachIOSurface(m_display, m_config, videoTextureTarget, EGL_IOSURFACE_READ_HINT_ANGLE, GL_RG, uvPlaneWidth, uvPlaneHeight, GL_UNSIGNED_BYTE, surface, 1);
640
    if (!uvHandle)
641
        return false;
642
    auto uvHandleCleanup = makeScopeExit([display = m_display, uvHandle] {
643
        WebCore::destroyPbufferAndDetachIOSurface(display, uvHandle);
644
    });
645
646
    GLuint yTexture = 0;
647
    gl::GenTextures(1, &yTexture);
648
    auto yTextureCleanup = makeScopeExit([yTexture] {
649
        gl::DeleteTextures(1, &yTexture);
650
    });
651
    gl::ActiveTexture(GL_TEXTURE0);
652
    gl::BindTexture(videoTextureTarget, yTexture);
653
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
654
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
655
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
656
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
657
    auto yHandle = WebCore::createPbufferAndAttachIOSurface(m_display, m_config, videoTextureTarget, EGL_IOSURFACE_READ_HINT_ANGLE, GL_RED, yPlaneWidth, yPlaneHeight, GL_UNSIGNED_BYTE, surface, 0);
658
    if (!yHandle)
659
        return false;
660
    auto yHandleCleanup = makeScopeExit([display = m_display, yHandle] {
661
        destroyPbufferAndDetachIOSurface(display, yHandle);
662
    });
663
664
    // Configure the drawing parameters.
665
    gl::Uniform1i(m_yTextureUniformLocation, 0);
666
    gl::Uniform1i(m_uvTextureUniformLocation, 1);
667
    gl::Uniform1i(m_yuvFlipYUniformLocation, flipY == FlipY::Yes ? 1 : 0);
668
    gl::Uniform2f(m_yTextureSizeUniformLocation, yPlaneWidth, yPlaneHeight);
669
    gl::Uniform2f(m_uvTextureSizeUniformLocation, uvPlaneWidth, uvPlaneHeight);
670
671
    auto range = pixelRangeFromPixelFormat(pixelFormat);
672
    auto transferFunction = transferFunctionFromString(dynamic_cf_cast<CFStringRef>(CVBufferGetAttachment(image, kCVImageBufferYCbCrMatrixKey, nil)));
673
    auto colorMatrix = YCbCrToRGBMatrixForRangeAndTransferFunction(range, transferFunction);
674
    gl::UniformMatrix4fv(m_colorMatrixUniformLocation, 1, GL_FALSE, colorMatrix);
675
676
    // Do the actual drawing.
677
    gl::DrawArrays(GL_TRIANGLES, 0, 6);
678
679
    m_lastSurface = surface;
680
    m_lastSurfaceSeed = newSurfaceSeed;
681
    m_lastTextureSeed.set(outputTexture, m_owner.textureSeed(outputTexture));
682
    m_lastFlipY = flipY;
683
    autoClearTextureOnError.release();
684
    return true;
685
}
686
687
}
688
689
#endif
- a/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVANGLE.h -82 lines
Lines 1-82 a/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVANGLE.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEBGL) && ENABLE(VIDEO) && USE(AVFOUNDATION)
29
30
#include "GraphicsContextGLCV.h"
31
32
#include <memory>
33
#include <wtf/UnsafePointer.h>
34
35
namespace WebCore {
36
class GraphicsContextGLOpenGL;
37
38
// GraphicsContextGLCV implementation for ANGLE flavour of GraphicsContextGLOpenGL.
39
// This class is part of the internal implementation of GraphicsContextGLOpenGL for ANGLE Cocoa.
40
class GraphicsContextGLCVANGLE final : public GraphicsContextGLCV {
41
    WTF_MAKE_FAST_ALLOCATED;
42
public:
43
    static std::unique_ptr<GraphicsContextGLCVANGLE> create(GraphicsContextGLOpenGL&);
44
45
    ~GraphicsContextGLCVANGLE() final;
46
47
    bool copyPixelBufferToTexture(CVPixelBufferRef, PlatformGLObject outputTexture, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, FlipY) final;
48
49
private:
50
    GraphicsContextGLCVANGLE(GraphicsContextGLOpenGL&);
51
52
    unsigned lastTextureSeed(GCGLuint texture)
53
    {
54
        return m_lastTextureSeed.get(texture);
55
    }
56
57
    GraphicsContextGLOpenGL& m_owner;
58
    PlatformGraphicsContextGLDisplay m_display { nullptr };
59
    PlatformGraphicsContextGL m_context { nullptr };
60
    PlatformGraphicsContextGLConfig m_config { nullptr };
61
62
    PlatformGLObject m_framebuffer { 0 };
63
    PlatformGLObject m_yuvVertexBuffer { 0 };
64
    GCGLint m_yTextureUniformLocation { -1 };
65
    GCGLint m_uvTextureUniformLocation { -1 };
66
    GCGLint m_yuvFlipYUniformLocation { -1 };
67
    GCGLint m_colorMatrixUniformLocation { -1 };
68
    GCGLint m_yuvPositionAttributeLocation { -1 };
69
    GCGLint m_yTextureSizeUniformLocation { -1 };
70
    GCGLint m_uvTextureSizeUniformLocation { -1 };
71
72
    FlipY m_lastFlipY { FlipY::No };
73
    UnsafePointer<IOSurfaceRef> m_lastSurface;
74
    uint32_t m_lastSurfaceSeed { 0 };
75
76
    using TextureSeedMap = HashMap<GCGLuint, unsigned, IntHash<GCGLuint>, WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>>;
77
    TextureSeedMap m_lastTextureSeed;
78
};
79
80
}
81
82
#endif
- a/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.cpp +689 lines
Line 0 a/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 * 
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "GraphicsContextGLCVCocoa.h"
28
29
#if ENABLE(WEBGL) && ENABLE(VIDEO) && USE(AVFOUNDATION)
30
31
#include "ANGLEUtilitiesCocoa.h"
32
#include "FourCC.h"
33
#include "GraphicsContextGLCocoa.h"
34
#include "Logging.h"
35
#include <pal/spi/cf/CoreVideoSPI.h>
36
#include <pal/spi/cocoa/IOSurfaceSPI.h>
37
#include <wtf/NeverDestroyed.h>
38
#include <wtf/Scope.h>
39
#include <wtf/StdMap.h>
40
#include <wtf/cf/TypeCastsCF.h>
41
#include <wtf/text/StringBuilder.h>
42
43
#include "CoreVideoSoftLink.h"
44
45
namespace WebCore {
46
47
static constexpr auto s_yuvVertexShaderTexture2D {
48
    "attribute vec2 a_position;"
49
    "uniform vec2 u_yTextureSize;"
50
    "uniform vec2 u_uvTextureSize;"
51
    "uniform int u_flipY;"
52
    "varying vec2 v_yTextureCoordinate;"
53
    "varying vec2 v_uvTextureCoordinate;"
54
    "void main()"
55
    "{"
56
    "    gl_Position = vec4(a_position, 0, 1.0);"
57
    "    vec2 normalizedPosition = a_position * .5 + .5;"
58
    "    if (u_flipY == 1)"
59
    "        normalizedPosition.y = 1.0 - normalizedPosition.y;"
60
    "    v_yTextureCoordinate = normalizedPosition;"
61
    "    v_uvTextureCoordinate = normalizedPosition;"
62
    "}"_s
63
};
64
65
static constexpr auto s_yuvVertexShaderTextureRectangle {
66
    "attribute vec2 a_position;"
67
    "uniform vec2 u_yTextureSize;"
68
    "uniform vec2 u_uvTextureSize;"
69
    "uniform int u_flipY;"
70
    "varying vec2 v_yTextureCoordinate;"
71
    "varying vec2 v_uvTextureCoordinate;"
72
    "void main()"
73
    "{"
74
    "    gl_Position = vec4(a_position, 0, 1.0);"
75
    "    vec2 normalizedPosition = a_position * .5 + .5;"
76
    "    if (u_flipY == 1)"
77
    "        normalizedPosition.y = 1.0 - normalizedPosition.y;"
78
    "    v_yTextureCoordinate = normalizedPosition * u_yTextureSize;"
79
    "    v_uvTextureCoordinate = normalizedPosition * u_uvTextureSize;"
80
    "}"_s
81
};
82
83
constexpr auto s_yuvFragmentShaderTexture2D {
84
    "precision mediump float;"
85
    "uniform sampler2D u_yTexture;"
86
    "uniform sampler2D u_uvTexture;"
87
    "uniform mat4 u_colorMatrix;"
88
    "varying vec2 v_yTextureCoordinate;"
89
    "varying vec2 v_uvTextureCoordinate;"
90
    "void main()"
91
    "{"
92
    "    vec4 yuv;"
93
    "    yuv.r = texture2D(u_yTexture, v_yTextureCoordinate).r;"
94
    "    yuv.gb = texture2D(u_uvTexture, v_uvTextureCoordinate).rg;"
95
    "    yuv.a = 1.0;"
96
    "    gl_FragColor = yuv * u_colorMatrix;"
97
    "}"_s
98
};
99
100
static constexpr auto s_yuvFragmentShaderTextureRectangle {
101
    "precision mediump float;"
102
    "uniform sampler2DRect u_yTexture;"
103
    "uniform sampler2DRect u_uvTexture;"
104
    "uniform mat4 u_colorMatrix;"
105
    "varying vec2 v_yTextureCoordinate;"
106
    "varying vec2 v_uvTextureCoordinate;"
107
    "void main()"
108
    "{"
109
    "    vec4 yuv;"
110
    "    yuv.r = texture2DRect(u_yTexture, v_yTextureCoordinate).r;"
111
    "    yuv.gb = texture2DRect(u_uvTexture, v_uvTextureCoordinate).rg;"
112
    "    yuv.a = 1.0;"
113
    "    gl_FragColor = yuv * u_colorMatrix;"
114
    "}"_s
115
};
116
117
enum class PixelRange {
118
    Unknown,
119
    Video,
120
    Full,
121
};
122
123
enum class TransferFunctionCV {
124
    Unknown,
125
    kITU_R_709_2,
126
    kITU_R_601_4,
127
    kSMPTE_240M_1995,
128
    kDCI_P3,
129
    kP3_D65,
130
    kITU_R_2020,
131
};
132
133
static PixelRange pixelRangeFromPixelFormat(OSType pixelFormat)
134
{
135
    switch (pixelFormat) {
136
    case kCVPixelFormatType_4444AYpCbCr8:
137
    case kCVPixelFormatType_4444AYpCbCr16:
138
    case kCVPixelFormatType_422YpCbCr_4A_8BiPlanar:
139
    case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
140
    case kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange:
141
    case kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange:
142
    case kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange:
143
#if HAVE(COREVIDEO_COMPRESSED_PIXEL_FORMAT_TYPES)
144
    case kCVPixelFormatType_AGX_420YpCbCr8BiPlanarVideoRange:
145
#endif
146
        return PixelRange::Video;
147
    case kCVPixelFormatType_420YpCbCr8PlanarFullRange:
148
    case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange:
149
    case kCVPixelFormatType_422YpCbCr8FullRange:
150
    case kCVPixelFormatType_ARGB2101010LEPacked:
151
    case kCVPixelFormatType_420YpCbCr10BiPlanarFullRange:
152
    case kCVPixelFormatType_422YpCbCr10BiPlanarFullRange:
153
    case kCVPixelFormatType_444YpCbCr10BiPlanarFullRange:
154
#if HAVE(COREVIDEO_COMPRESSED_PIXEL_FORMAT_TYPES)
155
    case kCVPixelFormatType_AGX_420YpCbCr8BiPlanarFullRange:
156
#endif
157
        return PixelRange::Full;
158
    default:
159
        return PixelRange::Unknown;
160
    }
161
}
162
163
static TransferFunctionCV transferFunctionFromString(CFStringRef string)
164
{
165
    if (!string)
166
        return TransferFunctionCV::Unknown;
167
    if (CFEqual(string, kCVImageBufferYCbCrMatrix_ITU_R_709_2))
168
        return TransferFunctionCV::kITU_R_709_2;
169
    if (CFEqual(string, kCVImageBufferYCbCrMatrix_ITU_R_601_4))
170
        return TransferFunctionCV::kITU_R_601_4;
171
    if (CFEqual(string, kCVImageBufferYCbCrMatrix_SMPTE_240M_1995))
172
        return TransferFunctionCV::kSMPTE_240M_1995;
173
    if (canLoad_CoreVideo_kCVImageBufferYCbCrMatrix_DCI_P3() && CFEqual(string, kCVImageBufferYCbCrMatrix_DCI_P3))
174
        return TransferFunctionCV::kDCI_P3;
175
    if (canLoad_CoreVideo_kCVImageBufferYCbCrMatrix_P3_D65() && CFEqual(string, kCVImageBufferYCbCrMatrix_P3_D65))
176
        return TransferFunctionCV::kP3_D65;
177
    if (canLoad_CoreVideo_kCVImageBufferYCbCrMatrix_ITU_R_2020() && CFEqual(string, kCVImageBufferYCbCrMatrix_ITU_R_2020))
178
        return TransferFunctionCV::kITU_R_2020;
179
    return TransferFunctionCV::Unknown;
180
}
181
182
struct GLfloatColor {
183
    union {
184
        struct {
185
            GLfloat r;
186
            GLfloat g;
187
            GLfloat b;
188
        } rgb;
189
        struct {
190
            GLfloat y;
191
            GLfloat cb;
192
            GLfloat cr;
193
        } ycbcr;
194
    };
195
196
    constexpr GLfloatColor(GLfloat r, GLfloat g, GLfloat b)
197
        : rgb { r, g, b }
198
    {
199
    }
200
201
    constexpr GLfloatColor(int r, int g, int b, GLfloat scale)
202
        : rgb { r / scale, g / scale, b / scale }
203
    {
204
    }
205
206
    static constexpr GLfloat abs(GLfloat value)
207
    {
208
        return value >= 0 ? value : -value;
209
    }
210
211
    constexpr bool isApproximatelyEqualTo(const GLfloatColor& color, GLfloat maxDelta) const
212
    {
213
        return abs(rgb.r - color.rgb.r) < abs(maxDelta)
214
            && abs(rgb.g - color.rgb.g) < abs(maxDelta)
215
            && abs(rgb.b - color.rgb.b) < abs(maxDelta);
216
    }
217
};
218
219
struct GLfloatColors {
220
    static constexpr GLfloatColor black   { 0, 0, 0 };
221
    static constexpr GLfloatColor white   { 1, 1, 1 };
222
    static constexpr GLfloatColor red     { 1, 0, 0 };
223
    static constexpr GLfloatColor green   { 0, 1, 0 };
224
    static constexpr GLfloatColor blue    { 0, 0, 1 };
225
    static constexpr GLfloatColor cyan    { 0, 1, 1 };
226
    static constexpr GLfloatColor magenta { 1, 0, 1 };
227
    static constexpr GLfloatColor yellow  { 1, 1, 0 };
228
};
229
230
struct YCbCrMatrix {
231
    GLfloat rows[4][4];
232
233
    constexpr YCbCrMatrix(PixelRange, GLfloat cbCoefficient, GLfloat crCoefficient);
234
235
    operator const GLfloat*() const
236
    {
237
        return &rows[0][0];
238
    }
239
240
    constexpr GLfloatColor operator*(const GLfloatColor&) const;
241
};
242
243
constexpr YCbCrMatrix::YCbCrMatrix(PixelRange range, GLfloat cbCoefficient, GLfloat crCoefficient)
244
    : rows { }
245
{
246
    // The conversion from YCbCr -> RGB generally takes the form:
247
    // Y = Kr * R + Kg * G + Kb * B
248
    // Cb = (B - Y) / (2 * (1 - Kb))
249
    // Cr = (R - Y) / (2 * (1 - Kr))
250
    // Where the values of Kb and Kr are defined in a specification and Kg is derived from: Kr + Kg + Kb = 1
251
    //
252
    // Solving the above equations for R, B, and G derives the following:
253
    // R = Y + (2 * (1 - Kr)) * Cr
254
    // B = Y + (2 * (1 - Kb)) * Cb
255
    // G = Y - (2 * (1 - Kb)) * (Kb / Kg) * Cb - ((1 - Kr) * 2) * (Kr / Kg) * Cr
256
    //
257
    // When the color values are Video range, Y has a range of [16, 235] with a width of 219, and Cb & Cr have
258
    // a range of [16, 240] with a width of 224. When the color values are Full range, Y, Cb, and Cr all have
259
    // a range of [0, 255] with a width of 256.
260
261
    GLfloat cgCoefficient = 1 - cbCoefficient - crCoefficient;
262
    GLfloat yScalingFactor = range == PixelRange::Full ? 1.f : 255.f / 219.f;
263
    GLfloat cbcrScalingFactor = range == PixelRange::Full ? 1.f : 255.f / 224.f;
264
265
    rows[0][0] = yScalingFactor;
266
    rows[0][1] = 0;
267
    rows[0][2] = cbcrScalingFactor * 2 * (1 - crCoefficient);
268
    rows[0][3] = 0;
269
270
    rows[1][0] = yScalingFactor;
271
    rows[1][1] = -cbcrScalingFactor * 2 * (1 - cbCoefficient) * (cbCoefficient / cgCoefficient);
272
    rows[1][2] = -cbcrScalingFactor * 2 * (1 - crCoefficient) * (crCoefficient / cgCoefficient);
273
    rows[1][3] = 0;
274
275
    rows[2][0] = yScalingFactor;
276
    rows[2][1] = cbcrScalingFactor * 2 * (1 - cbCoefficient);
277
    rows[2][2] = 0;
278
    rows[2][3] = 0;
279
280
    rows[3][0] = 0;
281
    rows[3][1] = 0;
282
    rows[3][2] = 0;
283
    rows[3][3] = 1;
284
285
    // Configure the final column of the matrix to convert Cb and Cr to [-128, 128]
286
    // and, in the case of video-range, to convert Y to [16, 240]:
287
    for (auto rowNumber = 0; rowNumber < 3; ++rowNumber) {
288
        auto& row = rows[rowNumber];
289
        auto& x = row[0];
290
        auto& y = row[1];
291
        auto& z = row[2];
292
        auto& w = row[3];
293
294
        w -= (y + z) * 128 / 255;
295
        if (range == PixelRange::Video)
296
            w -= x * 16 / 255;
297
    }
298
}
299
300
constexpr GLfloatColor YCbCrMatrix::operator*(const GLfloatColor& color) const
301
{
302
    return GLfloatColor(
303
        rows[0][0] * color.rgb.r + rows[0][1] * color.rgb.g + rows[0][2] * color.rgb.b + rows[0][3],
304
        rows[1][0] * color.rgb.r + rows[1][1] * color.rgb.g + rows[1][2] * color.rgb.b + rows[1][3],
305
        rows[2][0] * color.rgb.r + rows[2][1] * color.rgb.g + rows[2][2] * color.rgb.b + rows[2][3]
306
    );
307
}
308
309
static const GLfloat* YCbCrToRGBMatrixForRangeAndTransferFunction(PixelRange range, TransferFunctionCV transferFunction)
310
{
311
    using MapKey = std::pair<PixelRange, TransferFunctionCV>;
312
    using MatrixMap = StdMap<MapKey, const YCbCrMatrix&>;
313
314
    static NeverDestroyed<MatrixMap> matrices;
315
    static dispatch_once_t onceToken;
316
317
    // Matrices are derived from the components in the ITU R.601 rev 4 specification
318
    // https://www.itu.int/rec/R-REC-BT.601
319
    constexpr static YCbCrMatrix r601VideoMatrix { PixelRange::Video, 0.114f, 0.299f };
320
    constexpr static YCbCrMatrix r601FullMatrix { PixelRange::Full, 0.114f, 0.299f };
321
322
    static_assert((r601VideoMatrix * GLfloatColor(16,  128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "r.610 video matrix does not produce black color");
323
    static_assert((r601VideoMatrix * GLfloatColor(235, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "r.610 video matrix does not produce white color");
324
    static_assert((r601VideoMatrix * GLfloatColor(81,  90,  240, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "r.610 video matrix does not produce red color");
325
    static_assert((r601VideoMatrix * GLfloatColor(145, 54,  34,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "r.610 video matrix does not produce green color");
326
    static_assert((r601VideoMatrix * GLfloatColor(41,  240, 110, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "r.610 video matrix does not produce blue color");
327
    static_assert((r601VideoMatrix * GLfloatColor(210, 16,  146, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "r.610 video matrix does not produce yellow color");
328
    static_assert((r601VideoMatrix * GLfloatColor(106, 202, 222, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "r.610 video matrix does not produce magenta color");
329
    static_assert((r601VideoMatrix * GLfloatColor(170, 166, 16,  255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "r.610 video matrix does not produce cyan color");
330
331
    static_assert((r601FullMatrix * GLfloatColor(0,   128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "r.610 full matrix does not produce black color");
332
    static_assert((r601FullMatrix * GLfloatColor(255, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "r.610 full matrix does not produce white color");
333
    static_assert((r601FullMatrix * GLfloatColor(76,  85,  255, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "r.610 full matrix does not produce red color");
334
    static_assert((r601FullMatrix * GLfloatColor(150, 44,  21,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "r.610 full matrix does not produce green color");
335
    static_assert((r601FullMatrix * GLfloatColor(29,  255, 107, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "r.610 full matrix does not produce blue color");
336
    static_assert((r601FullMatrix * GLfloatColor(226, 0,   149, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "r.610 full matrix does not produce yellow color");
337
    static_assert((r601FullMatrix * GLfloatColor(105, 212, 235, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "r.610 full matrix does not produce magenta color");
338
    static_assert((r601FullMatrix * GLfloatColor(179, 171, 1,   255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "r.610 full matrix does not produce cyan color");
339
340
    // Matrices are derived from the components in the ITU R.709 rev 2 specification
341
    // https://www.itu.int/rec/R-REC-BT.709-2-199510-S
342
    constexpr static YCbCrMatrix r709VideoMatrix { PixelRange::Video, 0.0722, 0.2126 };
343
    constexpr static YCbCrMatrix r709FullMatrix { PixelRange::Full, 0.0722, 0.2126 };
344
345
    static_assert((r709VideoMatrix * GLfloatColor(16,  128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "r.709 video matrix does not produce black color");
346
    static_assert((r709VideoMatrix * GLfloatColor(235, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "r.709 video matrix does not produce white color");
347
    static_assert((r709VideoMatrix * GLfloatColor(63,  102, 240, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "r.709 video matrix does not produce red color");
348
    static_assert((r709VideoMatrix * GLfloatColor(173, 42,  26,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "r.709 video matrix does not produce green color");
349
    static_assert((r709VideoMatrix * GLfloatColor(32,  240, 118, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "r.709 video matrix does not produce blue color");
350
    static_assert((r709VideoMatrix * GLfloatColor(219, 16,  138, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "r.709 video matrix does not produce yellow color");
351
    static_assert((r709VideoMatrix * GLfloatColor(78,  214, 230, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "r.709 video matrix does not produce magenta color");
352
    static_assert((r709VideoMatrix * GLfloatColor(188, 154, 16,  255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "r.709 video matrix does not produce cyan color");
353
354
    static_assert((r709FullMatrix * GLfloatColor(0,   128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "r.709 full matrix does not produce black color");
355
    static_assert((r709FullMatrix * GLfloatColor(255, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "r.709 full matrix does not produce white color");
356
    static_assert((r709FullMatrix * GLfloatColor(54,  99,  256, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "r.709 full matrix does not produce red color");
357
    static_assert((r709FullMatrix * GLfloatColor(182, 30,  12,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "r.709 full matrix does not produce green color");
358
    static_assert((r709FullMatrix * GLfloatColor(18,  256, 116, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "r.709 full matrix does not produce blue color");
359
    static_assert((r709FullMatrix * GLfloatColor(237, 1,   140, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "r.709 full matrix does not produce yellow color");
360
    static_assert((r709FullMatrix * GLfloatColor(73,  226, 244, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "r.709 full matrix does not produce magenta color");
361
    static_assert((r709FullMatrix * GLfloatColor(201, 157, 1,   255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "r.709 full matrix does not produce cyan color");
362
363
    // Matrices are derived from the components in the ITU-R BT.2020-2 specification
364
    // https://www.itu.int/rec/R-REC-BT.2020
365
    constexpr static YCbCrMatrix bt2020VideoMatrix { PixelRange::Video, 0.0593, 0.2627 };
366
    constexpr static YCbCrMatrix bt2020FullMatrix { PixelRange::Full, 0.0593, 0.2627 };
367
368
    static_assert((bt2020VideoMatrix * GLfloatColor(16,  128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "bt.2020 video matrix does not produce black color");
369
    static_assert((bt2020VideoMatrix * GLfloatColor(235, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "bt.2020 video matrix does not produce white color");
370
    static_assert((bt2020VideoMatrix * GLfloatColor(74,  97,  240, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "bt.2020 video matrix does not produce red color");
371
    static_assert((bt2020VideoMatrix * GLfloatColor(164, 47,  25,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "bt.2020 video matrix does not produce green color");
372
    static_assert((bt2020VideoMatrix * GLfloatColor(29,  240, 119, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "bt.2020 video matrix does not produce blue color");
373
    static_assert((bt2020VideoMatrix * GLfloatColor(222, 16,  137, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "bt.2020 video matrix does not produce yellow color");
374
    static_assert((bt2020VideoMatrix * GLfloatColor(87,  209, 231, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "bt.2020 video matrix does not produce magenta color");
375
    static_assert((bt2020VideoMatrix * GLfloatColor(177, 159, 16,  255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "bt.2020 video matrix does not produce cyan color");
376
377
    static_assert((bt2020FullMatrix * GLfloatColor(0,   128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "bt.2020 full matrix does not produce black color");
378
    static_assert((bt2020FullMatrix * GLfloatColor(255, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "bt.2020 full matrix does not produce white color");
379
    static_assert((bt2020FullMatrix * GLfloatColor(67,  92,  256, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "bt.2020 full matrix does not produce red color");
380
    static_assert((bt2020FullMatrix * GLfloatColor(173, 36,  11,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "bt.2020 full matrix does not produce green color");
381
    static_assert((bt2020FullMatrix * GLfloatColor(15,  256, 118, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "bt.2020 full matrix does not produce blue color");
382
    static_assert((bt2020FullMatrix * GLfloatColor(240, 0,   138, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "bt.2020 full matrix does not produce yellow color");
383
    static_assert((bt2020FullMatrix * GLfloatColor(82,  220, 245, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "bt.2020 full matrix does not produce magenta color");
384
    static_assert((bt2020FullMatrix * GLfloatColor(188, 164, 1,   255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "bt.2020 full matrix does not produce cyan color");
385
386
    // Matrices are derived from the components in the SMPTE 240M-1999 specification
387
    // http://ieeexplore.ieee.org/document/7291461/
388
    constexpr static YCbCrMatrix smpte240MVideoMatrix { PixelRange::Video, 0.087, 0.212 };
389
    constexpr static YCbCrMatrix smpte240MFullMatrix { PixelRange::Full, 0.087, 0.212 };
390
391
    static_assert((smpte240MVideoMatrix * GLfloatColor(16,  128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "SMPTE 240M video matrix does not produce black color");
392
    static_assert((smpte240MVideoMatrix * GLfloatColor(235, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "SMPTE 240M video matrix does not produce white color");
393
    static_assert((smpte240MVideoMatrix * GLfloatColor(62,  102, 240, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "SMPTE 240M video matrix does not produce red color");
394
    static_assert((smpte240MVideoMatrix * GLfloatColor(170, 42,  28,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "SMPTE 240M video matrix does not produce green color");
395
    static_assert((smpte240MVideoMatrix * GLfloatColor(35,  240, 116, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "SMPTE 240M video matrix does not produce blue color");
396
    static_assert((smpte240MVideoMatrix * GLfloatColor(216, 16,  140, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "SMPTE 240M video matrix does not produce yellow color");
397
    static_assert((smpte240MVideoMatrix * GLfloatColor(81,  214, 228, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "SMPTE 240M video matrix does not produce magenta color");
398
    static_assert((smpte240MVideoMatrix * GLfloatColor(189, 154, 16,  255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "SMPTE 240M video matrix does not produce cyan color");
399
400
    static_assert((smpte240MFullMatrix * GLfloatColor(0,   128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::black,   1.5f / 255.f), "SMPTE 240M full matrix does not produce black color");
401
    static_assert((smpte240MFullMatrix * GLfloatColor(255, 128, 128, 255)).isApproximatelyEqualTo(GLfloatColors::white,   1.5f / 255.f), "SMPTE 240M full matrix does not produce white color");
402
    static_assert((smpte240MFullMatrix * GLfloatColor(54,  98,  256, 255)).isApproximatelyEqualTo(GLfloatColors::red,     1.5f / 255.f), "SMPTE 240M full matrix does not produce red color");
403
    static_assert((smpte240MFullMatrix * GLfloatColor(179, 30,  15,  255)).isApproximatelyEqualTo(GLfloatColors::green,   1.5f / 255.f), "SMPTE 240M full matrix does not produce green color");
404
    static_assert((smpte240MFullMatrix * GLfloatColor(22,  256, 114, 255)).isApproximatelyEqualTo(GLfloatColors::blue,    1.5f / 255.f), "SMPTE 240M full matrix does not produce blue color");
405
    static_assert((smpte240MFullMatrix * GLfloatColor(233, 1,   142, 255)).isApproximatelyEqualTo(GLfloatColors::yellow,  1.5f / 255.f), "SMPTE 240M full matrix does not produce yellow color");
406
    static_assert((smpte240MFullMatrix * GLfloatColor(76,  226, 241, 255)).isApproximatelyEqualTo(GLfloatColors::magenta, 1.5f / 255.f), "SMPTE 240M full matrix does not produce magenta color");
407
    static_assert((smpte240MFullMatrix * GLfloatColor(201, 158, 1,   255)).isApproximatelyEqualTo(GLfloatColors::cyan,    1.5f / 255.f), "SMPTE 240M full matrix does not produce cyan color");
408
409
    dispatch_once(&onceToken, ^{
410
        matrices.get().emplace(MapKey(PixelRange::Video, TransferFunctionCV::kITU_R_601_4), r601VideoMatrix);
411
        matrices.get().emplace(MapKey(PixelRange::Full, TransferFunctionCV::kITU_R_601_4), r601FullMatrix);
412
        matrices.get().emplace(MapKey(PixelRange::Video, TransferFunctionCV::kITU_R_709_2), r709VideoMatrix);
413
        matrices.get().emplace(MapKey(PixelRange::Full, TransferFunctionCV::kITU_R_709_2), r709FullMatrix);
414
        matrices.get().emplace(MapKey(PixelRange::Video, TransferFunctionCV::kITU_R_2020), bt2020VideoMatrix);
415
        matrices.get().emplace(MapKey(PixelRange::Full, TransferFunctionCV::kITU_R_2020), bt2020FullMatrix);
416
        matrices.get().emplace(MapKey(PixelRange::Video, TransferFunctionCV::kSMPTE_240M_1995), smpte240MVideoMatrix);
417
        matrices.get().emplace(MapKey(PixelRange::Full, TransferFunctionCV::kSMPTE_240M_1995), smpte240MFullMatrix);
418
    });
419
420
    // We should never be asked to handle a Pixel Format whose range value is unknown.
421
    ASSERT(range != PixelRange::Unknown);
422
    if (range == PixelRange::Unknown)
423
        range = PixelRange::Full;
424
425
    auto iterator = matrices.get().find({ range, transferFunction });
426
427
    // Assume unknown transfer functions are r.601:
428
    if (iterator == matrices.get().end())
429
        iterator = matrices.get().find({ range, TransferFunctionCV::kITU_R_601_4 });
430
431
    ASSERT(iterator != matrices.get().end());
432
    return iterator->second;
433
}
434
435
std::unique_ptr<GraphicsContextGLCVCocoa> GraphicsContextGLCVCocoa::create(GraphicsContextGLCocoa& context)
436
{
437
    std::unique_ptr<GraphicsContextGLCVCocoa> cv { new GraphicsContextGLCVCocoa(context) };
438
    if (!cv->m_context)
439
        return nullptr;
440
    return cv;
441
}
442
443
GraphicsContextGLCVCocoa::~GraphicsContextGLCVCocoa()
444
{
445
    if (!m_context || !GraphicsContextGLCocoa::makeCurrent(m_display, m_context))
446
        return;
447
    gl::DeleteBuffers(1, &m_yuvVertexBuffer);
448
    gl::DeleteFramebuffers(1, &m_framebuffer);
449
    EGL_DestroyContext(m_display, m_context);
450
}
451
452
GraphicsContextGLCVCocoa::GraphicsContextGLCVCocoa(GraphicsContextGLCocoa& owner)
453
    : m_owner(owner)
454
{
455
    // Create compatible context that shares state with owner, but one that does not
456
    // have robustness or WebGL compatibility.
457
    const EGLint contextAttributes[] = {
458
        EGL_CONTEXT_CLIENT_VERSION,
459
        owner.m_isForWebGL2 ? 3 : 2,
460
        EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE,
461
        EGL_FALSE,
462
        EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE,
463
        EGL_FALSE,
464
        EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM,
465
        EGL_FALSE,
466
        EGL_NONE
467
    };
468
    EGLDisplay display = owner.platformDisplay();
469
    EGLConfig config = owner.platformConfig();
470
    EGLContext context = EGL_CreateContext(display, config, owner.m_contextObj, contextAttributes);
471
    if (context == EGL_NO_CONTEXT)
472
        return;
473
    GraphicsContextGLCocoa::makeCurrent(display, context);
474
475
    auto contextCleanup = makeScopeExit([display, context] {
476
        GraphicsContextGLCocoa::makeCurrent(display, EGL_NO_CONTEXT);
477
        EGL_DestroyContext(display, context);
478
    });
479
480
    const bool useTexture2D = m_owner.drawingBufferTextureTarget() == GL_TEXTURE_2D;
481
482
#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
483
    if (!useTexture2D) {
484
        gl::RequestExtensionANGLE("GL_ANGLE_texture_rectangle");
485
        gl::RequestExtensionANGLE("GL_EXT_texture_format_BGRA8888");
486
        if (gl::GetError() != GL_NO_ERROR)
487
            return;
488
    }
489
#endif
490
491
    GLint vertexShader = gl::CreateShader(GL_VERTEX_SHADER);
492
    GLint fragmentShader = gl::CreateShader(GL_FRAGMENT_SHADER);
493
    GLuint yuvProgram = gl::CreateProgram();
494
    auto programCleanup = makeScopeExit([vertexShader, fragmentShader, yuvProgram] {
495
        gl::DeleteShader(vertexShader);
496
        gl::DeleteShader(fragmentShader);
497
        gl::DeleteProgram(yuvProgram);
498
    });
499
    // These are written so strlen might be compile-time.
500
    GLint vsLength = useTexture2D ? s_yuvVertexShaderTexture2D.length() : s_yuvVertexShaderTextureRectangle.length();
501
    GLint fsLength = useTexture2D ? s_yuvFragmentShaderTexture2D.length() : s_yuvFragmentShaderTextureRectangle.length();
502
    const char* vertexShaderSource = useTexture2D ? s_yuvVertexShaderTexture2D : s_yuvVertexShaderTextureRectangle;
503
    const char* fragmentShaderSource = useTexture2D ? s_yuvFragmentShaderTexture2D : s_yuvFragmentShaderTextureRectangle;
504
505
    gl::ShaderSource(vertexShader, 1, &vertexShaderSource, &vsLength);
506
    gl::ShaderSource(fragmentShader, 1, &fragmentShaderSource, &fsLength);
507
    gl::CompileShader(vertexShader);
508
    gl::CompileShader(fragmentShader);
509
    gl::AttachShader(yuvProgram, vertexShader);
510
    gl::AttachShader(yuvProgram, fragmentShader);
511
    gl::LinkProgram(yuvProgram);
512
    // Link status is checked afterwards for theoretical parallel compilation benefit.
513
514
    GLuint yuvVertexBuffer = 0;
515
    gl::GenBuffers(1, &yuvVertexBuffer);
516
    auto yuvVertexBufferCleanup = makeScopeExit([yuvVertexBuffer] {
517
        gl::DeleteBuffers(1, &yuvVertexBuffer);
518
    });
519
    float vertices[12] = { -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1 };
520
    gl::BindBuffer(GL_ARRAY_BUFFER, yuvVertexBuffer);
521
    gl::BufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
522
523
    GLuint framebuffer = 0;
524
    gl::GenFramebuffers(1, &framebuffer);
525
    auto framebufferCleanup = makeScopeExit([framebuffer] {
526
        gl::DeleteFramebuffers(1, &framebuffer);
527
    });
528
529
    GLint status = 0;
530
    gl::GetProgramivRobustANGLE(yuvProgram, GL_LINK_STATUS, 1, nullptr, &status);
531
    if (!status) {
532
        GLint vsStatus = 0;
533
        gl::GetShaderivRobustANGLE(vertexShader, GL_COMPILE_STATUS, 1, nullptr, &vsStatus);
534
        GLint fsStatus = 0;
535
        gl::GetShaderivRobustANGLE(fragmentShader, GL_COMPILE_STATUS, 1, nullptr, &fsStatus);
536
        LOG(WebGL, "GraphicsContextGLCVCocoa(%p) - YUV program failed to link: %d, %d, %d.", this, status, vsStatus, fsStatus);
537
        return;
538
    }
539
    contextCleanup.release();
540
    yuvVertexBufferCleanup.release();
541
    framebufferCleanup.release();
542
    m_display = display;
543
    m_context = context;
544
    m_config = config;
545
    m_yuvVertexBuffer = yuvVertexBuffer;
546
    m_framebuffer = framebuffer;
547
    m_yTextureUniformLocation = gl::GetUniformLocation(yuvProgram, "u_yTexture");
548
    m_uvTextureUniformLocation = gl::GetUniformLocation(yuvProgram, "u_uvTexture");
549
    m_colorMatrixUniformLocation = gl::GetUniformLocation(yuvProgram, "u_colorMatrix");
550
    m_yuvFlipYUniformLocation = gl::GetUniformLocation(yuvProgram, "u_flipY");
551
    m_yTextureSizeUniformLocation = gl::GetUniformLocation(yuvProgram, "u_yTextureSize");
552
    m_uvTextureSizeUniformLocation = gl::GetUniformLocation(yuvProgram, "u_uvTextureSize");
553
    m_yuvPositionAttributeLocation = gl::GetAttribLocation(yuvProgram, "a_position");
554
    // Program is deleted by the cleanup while the program binary stays in use.
555
    gl::UseProgram(yuvProgram);
556
    gl::EnableVertexAttribArray(m_yuvPositionAttributeLocation);
557
    gl::VertexAttribPointer(m_yuvPositionAttributeLocation, 2, GL_FLOAT, false, 0, 0);
558
    gl::ClearColor(0, 0, 0, 0);
559
    gl::BindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
560
}
561
562
bool GraphicsContextGLCVCocoa::copyPixelBufferToTexture(CVPixelBufferRef image, PlatformGLObject outputTexture, GLint level, GLenum internalFormat, GLenum format, GLenum type, FlipY flipY)
563
{
564
    // FIXME: This currently only supports '420v' and '420f' pixel formats. Investigate supporting more pixel formats.
565
    OSType pixelFormat = CVPixelBufferGetPixelFormatType(image);
566
    if (pixelFormat != kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
567
        && pixelFormat != kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
568
#if HAVE(COREVIDEO_COMPRESSED_PIXEL_FORMAT_TYPES)
569
        && pixelFormat != kCVPixelFormatType_AGX_420YpCbCr8BiPlanarVideoRange
570
        && pixelFormat != kCVPixelFormatType_AGX_420YpCbCr8BiPlanarFullRange
571
#endif
572
        ) {
573
        LOG(WebGL, "GraphicsContextGLCVCocoa::copyVideoTextureToPlatformTexture(%p) - Asked to copy an unsupported pixel format ('%s').", this, FourCC(pixelFormat).toString().utf8().data());
574
        return false;
575
    }
576
    IOSurfaceRef surface = CVPixelBufferGetIOSurface(image);
577
    if (!surface)
578
        return false;
579
580
    auto newSurfaceSeed = IOSurfaceGetSeed(surface);
581
    if (flipY == m_lastFlipY
582
        && surface == m_lastSurface
583
        && newSurfaceSeed == m_lastSurfaceSeed
584
        && lastTextureSeed(outputTexture) == m_owner.textureSeed(outputTexture)) {
585
        // If the texture hasn't been modified since the last time we copied to it, and the
586
        // image hasn't been modified since the last time it was copied, this is a no-op.
587
        return true;
588
    }
589
    if (!m_context || !GraphicsContextGLCocoa::makeCurrent(m_display, m_context))
590
        return false;
591
592
    size_t width = CVPixelBufferGetWidth(image);
593
    size_t height = CVPixelBufferGetHeight(image);
594
595
    gl::Viewport(0, 0, width, height);
596
597
    // The outputTexture might contain uninitialized content on early-outs. Clear it in cases
598
    // autoClearTextureOnError is not reset.
599
    auto autoClearTextureOnError = makeScopeExit([outputTexture, level, internalFormat, format, type] {
600
        gl::BindTexture(GL_TEXTURE_2D, outputTexture);
601
        gl::TexImage2D(GL_TEXTURE_2D, level, internalFormat, 0, 0, 0, format, type, nullptr);
602
        gl::BindTexture(GL_TEXTURE_2D, 0);
603
    });
604
    // Allocate memory for the output texture.
605
    gl::BindTexture(GL_TEXTURE_2D, outputTexture);
606
    gl::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
607
    gl::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
608
    gl::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
609
    gl::TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
610
    gl::TexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, 0, format, type, nullptr);
611
612
    gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, outputTexture, level);
613
    GLenum status = gl::CheckFramebufferStatus(GL_FRAMEBUFFER);
614
    if (status != GL_FRAMEBUFFER_COMPLETE) {
615
        LOG(WebGL, "GraphicsContextGLCVCocoa::copyVideoTextureToPlatformTexture(%p) - Unable to create framebuffer for outputTexture.", this);
616
        return false;
617
    }
618
    gl::BindTexture(GL_TEXTURE_2D, 0);
619
620
    // Bind and set up the textures for the video source.
621
    auto yPlaneWidth = IOSurfaceGetWidthOfPlane(surface, 0);
622
    auto yPlaneHeight = IOSurfaceGetHeightOfPlane(surface, 0);
623
    auto uvPlaneWidth = IOSurfaceGetWidthOfPlane(surface, 1);
624
    auto uvPlaneHeight = IOSurfaceGetHeightOfPlane(surface, 1);
625
626
    GLenum videoTextureTarget = m_owner.drawingBufferTextureTarget();
627
628
    GLuint uvTexture = 0;
629
    gl::GenTextures(1, &uvTexture);
630
    auto uvTextureCleanup = makeScopeExit([uvTexture] {
631
        gl::DeleteTextures(1, &uvTexture);
632
    });
633
    gl::ActiveTexture(GL_TEXTURE1);
634
    gl::BindTexture(videoTextureTarget, uvTexture);
635
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
636
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
637
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
638
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
639
    auto uvHandle = WebCore::createPbufferAndAttachIOSurface(m_display, m_config, videoTextureTarget, EGL_IOSURFACE_READ_HINT_ANGLE, GL_RG, uvPlaneWidth, uvPlaneHeight, GL_UNSIGNED_BYTE, surface, 1);
640
    if (!uvHandle)
641
        return false;
642
    auto uvHandleCleanup = makeScopeExit([display = m_display, uvHandle] {
643
        WebCore::destroyPbufferAndDetachIOSurface(display, uvHandle);
644
    });
645
646
    GLuint yTexture = 0;
647
    gl::GenTextures(1, &yTexture);
648
    auto yTextureCleanup = makeScopeExit([yTexture] {
649
        gl::DeleteTextures(1, &yTexture);
650
    });
651
    gl::ActiveTexture(GL_TEXTURE0);
652
    gl::BindTexture(videoTextureTarget, yTexture);
653
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
654
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
655
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
656
    gl::TexParameteri(videoTextureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
657
    auto yHandle = WebCore::createPbufferAndAttachIOSurface(m_display, m_config, videoTextureTarget, EGL_IOSURFACE_READ_HINT_ANGLE, GL_RED, yPlaneWidth, yPlaneHeight, GL_UNSIGNED_BYTE, surface, 0);
658
    if (!yHandle)
659
        return false;
660
    auto yHandleCleanup = makeScopeExit([display = m_display, yHandle] {
661
        destroyPbufferAndDetachIOSurface(display, yHandle);
662
    });
663
664
    // Configure the drawing parameters.
665
    gl::Uniform1i(m_yTextureUniformLocation, 0);
666
    gl::Uniform1i(m_uvTextureUniformLocation, 1);
667
    gl::Uniform1i(m_yuvFlipYUniformLocation, flipY == FlipY::Yes ? 1 : 0);
668
    gl::Uniform2f(m_yTextureSizeUniformLocation, yPlaneWidth, yPlaneHeight);
669
    gl::Uniform2f(m_uvTextureSizeUniformLocation, uvPlaneWidth, uvPlaneHeight);
670
671
    auto range = pixelRangeFromPixelFormat(pixelFormat);
672
    auto transferFunction = transferFunctionFromString(dynamic_cf_cast<CFStringRef>(CVBufferGetAttachment(image, kCVImageBufferYCbCrMatrixKey, nil)));
673
    auto colorMatrix = YCbCrToRGBMatrixForRangeAndTransferFunction(range, transferFunction);
674
    gl::UniformMatrix4fv(m_colorMatrixUniformLocation, 1, GL_FALSE, colorMatrix);
675
676
    // Do the actual drawing.
677
    gl::DrawArrays(GL_TRIANGLES, 0, 6);
678
679
    m_lastSurface = surface;
680
    m_lastSurfaceSeed = newSurfaceSeed;
681
    m_lastTextureSeed.set(outputTexture, m_owner.textureSeed(outputTexture));
682
    m_lastFlipY = flipY;
683
    autoClearTextureOnError.release();
684
    return true;
685
}
686
687
}
688
689
#endif
- a/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.h +82 lines
Line 0 a/Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEBGL) && ENABLE(VIDEO) && USE(AVFOUNDATION)
29
30
#include "GraphicsContextGLCV.h"
31
32
#include <memory>
33
#include <wtf/UnsafePointer.h>
34
35
namespace WebCore {
36
class GraphicsContextGLCocoa;
37
38
// GraphicsContextGLCV implementation for GraphicsContextGLCocoa.
39
// This class is part of the internal implementation of GraphicsContextGLCocoa.
40
class GraphicsContextGLCVCocoa final : public GraphicsContextGLCV {
41
    WTF_MAKE_FAST_ALLOCATED;
42
public:
43
    static std::unique_ptr<GraphicsContextGLCVCocoa> create(GraphicsContextGLCocoa&);
44
45
    ~GraphicsContextGLCVCocoa() final;
46
47
    bool copyPixelBufferToTexture(CVPixelBufferRef, PlatformGLObject outputTexture, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, FlipY) final;
48
49
private:
50
    GraphicsContextGLCVCocoa(GraphicsContextGLCocoa&);
51
52
    unsigned lastTextureSeed(GCGLuint texture)
53
    {
54
        return m_lastTextureSeed.get(texture);
55
    }
56
57
    GraphicsContextGLCocoa& m_owner;
58
    PlatformGraphicsContextGLDisplay m_display { nullptr };
59
    PlatformGraphicsContextGL m_context { nullptr };
60
    PlatformGraphicsContextGLConfig m_config { nullptr };
61
62
    PlatformGLObject m_framebuffer { 0 };
63
    PlatformGLObject m_yuvVertexBuffer { 0 };
64
    GCGLint m_yTextureUniformLocation { -1 };
65
    GCGLint m_uvTextureUniformLocation { -1 };
66
    GCGLint m_yuvFlipYUniformLocation { -1 };
67
    GCGLint m_colorMatrixUniformLocation { -1 };
68
    GCGLint m_yuvPositionAttributeLocation { -1 };
69
    GCGLint m_yTextureSizeUniformLocation { -1 };
70
    GCGLint m_uvTextureSizeUniformLocation { -1 };
71
72
    FlipY m_lastFlipY { FlipY::No };
73
    UnsafePointer<IOSurfaceRef> m_lastSurface;
74
    uint32_t m_lastSurfaceSeed { 0 };
75
76
    using TextureSeedMap = HashMap<GCGLuint, unsigned, IntHash<GCGLuint>, WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>>;
77
    TextureSeedMap m_lastTextureSeed;
78
};
79
80
}
81
82
#endif
- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp -9 / +2851 lines
Lines 1-7 a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
2
 * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
3
 * Copyright (C) 2010 Google Inc. All rights reserved.
3
 * Copyright (C) 2011 Google Inc. All rights reserved.
4
 * Copyright (C) 2010 Mozilla Corporation. All rights reserved.
4
 * Copyright (C) 2012 ChangSeok Oh <shivamidow@gmail.com>
5
 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
5
 *
6
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * modification, are permitted provided that the following conditions
Lines 22-43 a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp_sec2
22
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
26
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27
 */
27
28
28
#include "config.h"
29
#include "config.h"
29
#include "GraphicsContextGLOpenGL.h"
30
#include "GraphicsContextGLOpenGL.h"
30
31
31
#if ENABLE(WEBGL)
32
#if ENABLE(WEBGL) && !USE(ANGLE)
32
33
33
#include "ExtensionsGL.h"
34
#include "ANGLEWebKitBridge.h"
35
#include "GraphicsContext.h"
34
#include "ImageBuffer.h"
36
#include "ImageBuffer.h"
37
#include "IntRect.h"
38
#include "IntSize.h"
39
#include "Logging.h"
35
#include "PixelBuffer.h"
40
#include "PixelBuffer.h"
36
#include <memory>
41
#include "TemporaryOpenGLSetting.h"
42
#include "WebGLRenderingContextBase.h"
43
#include <JavaScriptCore/RegularExpression.h>
44
#include <cstring>
45
#include <wtf/HexNumber.h>
46
#include <wtf/MainThread.h>
47
#include <wtf/ThreadSpecific.h>
37
#include <wtf/UniqueArray.h>
48
#include <wtf/UniqueArray.h>
49
#include <wtf/Vector.h>
50
#include <wtf/text/CString.h>
51
#include <wtf/text/StringBuilder.h>
52
53
#if USE(OPENGL_ES)
54
#include "ExtensionsGLOpenGLES.h"
55
#else
56
#include "ExtensionsGLOpenGL.h"
57
#endif
58
59
#if USE(LIBEPOXY)
60
#include "EpoxyShims.h"
61
#elif USE(OPENGL_ES)
62
#include "OpenGLESShims.h"
63
#elif PLATFORM(GTK) || PLATFORM(WIN)
64
#include "OpenGLShims.h"
65
#endif
38
66
39
namespace WebCore {
67
namespace WebCore {
40
68
69
static ThreadSpecific<ShaderNameHash*>& getCurrentNameHashMapForShader()
70
{
71
    static std::once_flag onceFlag;
72
    static ThreadSpecific<ShaderNameHash*>* sharedNameHash;
73
    std::call_once(onceFlag, [] {
74
        sharedNameHash = new ThreadSpecific<ShaderNameHash*>;
75
    });
76
77
    return *sharedNameHash;
78
}
79
80
static void setCurrentNameHashMapForShader(ShaderNameHash* shaderNameHash)
81
{
82
    *getCurrentNameHashMapForShader() = shaderNameHash;
83
}
84
85
// Hash function used by the ANGLE translator/compiler to do
86
// symbol name mangling. Since this is a static method, before
87
// calling compileShader we set currentNameHashMapForShader
88
// to point to the map kept by the current instance of GraphicsContextGLOpenGL.
89
90
static uint64_t nameHashForShader(const char* name, size_t length)
91
{
92
    if (!length)
93
        return 0;
94
95
    CString nameAsCString = CString(name);
96
97
    // Look up name in our local map.
98
    ShaderNameHash*& currentNameHashMapForShader = *getCurrentNameHashMapForShader();
99
    ShaderNameHash::iterator findResult = currentNameHashMapForShader->find(nameAsCString);
100
    if (findResult != currentNameHashMapForShader->end())
101
        return findResult->value;
102
103
    unsigned hashValue = nameAsCString.hash();
104
105
    // Convert the 32-bit hash from CString::hash into a 64-bit result
106
    // by shifting then adding the size of our table. Overflow would
107
    // only be a problem if we're already hashing to the same value (and
108
    // we're hoping that over the lifetime of the context we
109
    // don't have that many symbols).
110
111
    uint64_t result = hashValue;
112
    result = (result << 32) + (currentNameHashMapForShader->size() + 1);
113
114
    currentNameHashMapForShader->set(nameAsCString, result);
115
    return result;
116
}
117
118
void GraphicsContextGLOpenGL::validateDepthStencil(const char* packedDepthStencilExtension)
119
{
120
    auto attrs = contextAttributes();
121
122
    ExtensionsGLOpenGLCommon& extensions = getExtensions();
123
    if (attrs.stencil) {
124
        if (extensions.supports(packedDepthStencilExtension)) {
125
            extensions.ensureEnabled(packedDepthStencilExtension);
126
            // Force depth if stencil is true.
127
            attrs.depth = true;
128
        } else
129
            attrs.stencil = false;
130
        setContextAttributes(attrs);
131
    }
132
    if (attrs.antialias && !m_isForWebGL2) {
133
        if (!extensions.supports("GL_ANGLE_framebuffer_multisample")) {
134
            attrs.antialias = false;
135
            setContextAttributes(attrs);
136
        } else
137
            extensions.ensureEnabled("GL_ANGLE_framebuffer_multisample");
138
    }
139
}
140
141
void GraphicsContextGLOpenGL::prepareTexture()
142
{
143
    if (m_layerComposited)
144
        return;
145
146
    if (!makeContextCurrent())
147
        return;
148
149
150
#if !USE(COORDINATED_GRAPHICS)
151
    TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
152
    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
153
#endif
154
155
    if (contextAttributes().antialias)
156
        resolveMultisamplingIfNecessary();
157
158
#if USE(COORDINATED_GRAPHICS)
159
    std::swap(m_texture, m_compositorTexture);
160
    std::swap(m_texture, m_intermediateTexture);
161
    ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
162
    ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);
163
    glFlush();
164
165
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
166
    if (m_state.boundDrawFBO != m_fbo)
167
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
168
    else
169
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
170
    return;
171
#endif
172
173
    ::glActiveTexture(GL_TEXTURE0);
174
    ::glBindTexture(GL_TEXTURE_2D, m_state.boundTarget(GL_TEXTURE0) == GL_TEXTURE_2D ? m_state.boundTexture(GL_TEXTURE0) : 0);
175
    ::glActiveTexture(m_state.activeTextureUnit);
176
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
177
    if (m_state.boundDrawFBO != m_fbo)
178
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
179
    ::glFlush();
180
}
181
182
std::optional<PixelBuffer> GraphicsContextGLOpenGL::readRenderingResults()
183
{
184
    bool mustRestoreFBO = false;
185
    if (contextAttributes().antialias) {
186
        resolveMultisamplingIfNecessary();
187
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
188
        mustRestoreFBO = true;
189
    } else {
190
        ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
191
        if (m_state.boundDrawFBO != m_fbo) {
192
            mustRestoreFBO = true;
193
            ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
194
        }
195
    }
196
    auto result = readPixelsForPaintResults();
197
    if (mustRestoreFBO)
198
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
199
    return result;
200
}
201
202
void GraphicsContextGLOpenGL::reshape(int width, int height)
203
{
204
    if (width == m_currentWidth && height == m_currentHeight)
205
        return;
206
207
    ASSERT(width >= 0 && height >= 0);
208
    if (width < 0 || height < 0)
209
        return;
210
211
    if (!makeContextCurrent())
212
        return;
213
214
    markContextChanged();
215
216
    m_currentWidth = width;
217
    m_currentHeight = height;
218
219
    validateAttributes();
220
221
    TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
222
    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
223
    
224
    bool mustRestoreFBO = reshapeFBOs(IntSize(width, height));
225
226
    // Initialize renderbuffers to 0.
227
    GLfloat clearColor[] = { 0, 0, 0, 0 }, clearDepth = 0;
228
    GLint clearStencil = 0;
229
    GLboolean colorMask[] = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }, depthMask = GL_TRUE;
230
    GLuint stencilMask = 0xffffffff, stencilMaskBack = 0xffffffff;
231
    GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
232
    ::glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
233
    ::glClearColor(0, 0, 0, 0);
234
    ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
235
    ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
236
237
    auto attrs = contextAttributes();
238
239
    if (attrs.depth) {
240
        ::glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth);
241
        GraphicsContextGLOpenGL::clearDepth(1);
242
        ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
243
        ::glDepthMask(GL_TRUE);
244
        clearMask |= GL_DEPTH_BUFFER_BIT;
245
    }
246
    if (attrs.stencil) {
247
        ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil);
248
        ::glClearStencil(0);
249
        ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask));
250
        ::glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, reinterpret_cast<GLint*>(&stencilMaskBack));
251
        ::glStencilMaskSeparate(GL_FRONT, 0xffffffff);
252
        ::glStencilMaskSeparate(GL_BACK, 0xffffffff);
253
        clearMask |= GL_STENCIL_BUFFER_BIT;
254
    }
255
256
    ::glClear(clearMask);
257
258
    ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
259
    ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
260
    if (attrs.depth) {
261
        GraphicsContextGLOpenGL::clearDepth(clearDepth);
262
        ::glDepthMask(depthMask);
263
    }
264
    if (attrs.stencil) {
265
        ::glClearStencil(clearStencil);
266
        ::glStencilMaskSeparate(GL_FRONT, stencilMask);
267
        ::glStencilMaskSeparate(GL_BACK, stencilMaskBack);
268
    }
269
270
    if (mustRestoreFBO)
271
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
272
273
    auto error = ::glGetError();
274
    if (error != GL_NO_ERROR) {
275
        RELEASE_LOG(WebGL, "Fatal: OpenGL error during GraphicsContextGL buffer initialization (%d).", error);
276
        forceContextLost();
277
        return;
278
    }
279
280
    ::glFlush();
281
}
282
283
bool GraphicsContextGLOpenGL::checkVaryingsPacking(PlatformGLObject vertexShader, PlatformGLObject fragmentShader) const
284
{
285
    ASSERT(m_shaderSourceMap.contains(vertexShader));
286
    ASSERT(m_shaderSourceMap.contains(fragmentShader));
287
    const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value;
288
    const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value;
289
290
    HashMap<String, sh::ShaderVariable> combinedVaryings;
291
    for (const auto& vertexSymbol : vertexEntry.varyingMap) {
292
        const String& symbolName = vertexSymbol.key;
293
        // The varying map includes variables for each index of an array variable.
294
        // We only want a single variable to represent the array.
295
        if (symbolName.endsWith("]"))
296
            continue;
297
298
        // Don't count built in varyings.
299
        if (symbolName == "gl_FragCoord" || symbolName == "gl_FrontFacing" || symbolName == "gl_PointCoord")
300
            continue;
301
302
        const auto& fragmentSymbol = fragmentEntry.varyingMap.find(symbolName);
303
        if (fragmentSymbol != fragmentEntry.varyingMap.end())
304
            combinedVaryings.add(symbolName, fragmentSymbol->value);
305
    }
306
307
    size_t numVaryings = combinedVaryings.size();
308
    if (!numVaryings)
309
        return true;
310
311
    std::vector<sh::ShaderVariable> variables;
312
    variables.reserve(combinedVaryings.size());
313
    for (const auto& varyingSymbol : combinedVaryings.values())
314
        variables.push_back(varyingSymbol);
315
316
    GCGLint maxVaryingVectors = 0;
317
#if USE(OPENGL_ES)
318
    ::glGetIntegerv(MAX_VARYING_VECTORS, &maxVaryingVectors);
319
#else
320
    if (m_isForWebGL2)
321
        ::glGetIntegerv(GL_MAX_VARYING_VECTORS, &maxVaryingVectors);
322
    else {
323
        GCGLint maxVaryingFloats = 0;
324
        ::glGetIntegerv(GL_MAX_VARYING_FLOATS, &maxVaryingFloats);
325
        maxVaryingVectors = maxVaryingFloats / 4;
326
    }
327
#endif
328
    return sh::CheckVariablesWithinPackingLimits(maxVaryingVectors, variables);
329
}
330
331
bool GraphicsContextGLOpenGL::precisionsMatch(PlatformGLObject vertexShader, PlatformGLObject fragmentShader) const
332
{
333
    ASSERT(m_shaderSourceMap.contains(vertexShader));
334
    ASSERT(m_shaderSourceMap.contains(fragmentShader));
335
    const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value;
336
    const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value;
337
338
    HashMap<String, sh::GLenum> vertexSymbolPrecisionMap;
339
340
    for (const auto& entry : vertexEntry.uniformMap) {
341
        const std::string& mappedName = entry.value.get().mappedName;
342
        vertexSymbolPrecisionMap.add(String(mappedName.c_str(), mappedName.length()), entry.value.get().precision);
343
    }
344
345
    for (const auto& entry : fragmentEntry.uniformMap) {
346
        const std::string& mappedName = entry.value.get().mappedName;
347
        const auto& vertexSymbol = vertexSymbolPrecisionMap.find(String(mappedName.c_str(), mappedName.length()));
348
        if (vertexSymbol != vertexSymbolPrecisionMap.end() && vertexSymbol->value != entry.value.get().precision)
349
            return false;
350
    }
351
352
    return true;
353
}
354
355
void GraphicsContextGLOpenGL::activeTexture(GCGLenum texture)
356
{
357
    if (!makeContextCurrent())
358
        return;
359
360
    m_state.activeTextureUnit = texture;
361
    ::glActiveTexture(texture);
362
}
363
364
void GraphicsContextGLOpenGL::attachShader(PlatformGLObject program, PlatformGLObject shader)
365
{
366
    ASSERT(program);
367
    ASSERT(shader);
368
    if (!makeContextCurrent())
369
        return;
370
371
    m_shaderProgramSymbolCountMap.remove(program);
372
    ::glAttachShader(program, shader);
373
}
374
375
void GraphicsContextGLOpenGL::bindAttribLocation(PlatformGLObject program, GCGLuint index, const String& name)
376
{
377
    ASSERT(program);
378
    if (!makeContextCurrent())
379
        return;
380
381
    String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name);
382
    LOG(WebGL, "::bindAttribLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data());
383
    ::glBindAttribLocation(program, index, mappedName.utf8().data());
384
}
385
386
void GraphicsContextGLOpenGL::bindBuffer(GCGLenum target, PlatformGLObject buffer)
387
{
388
    if (!makeContextCurrent())
389
        return;
390
391
    ::glBindBuffer(target, buffer);
392
}
393
394
void GraphicsContextGLOpenGL::bindFramebuffer(GCGLenum target, PlatformGLObject buffer)
395
{
396
    if (!makeContextCurrent())
397
        return;
398
399
    GLuint fbo;
400
    if (buffer)
401
        fbo = buffer;
402
    else
403
        fbo = (contextAttributes().antialias ? m_multisampleFBO : m_fbo);
404
    ASSERT(target == GL_FRAMEBUFFER);
405
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
406
    if (fbo != m_state.boundDrawFBO) {
407
        ::glBindFramebufferEXT(target, fbo);
408
        m_state.boundDrawFBO = m_state.boundReadFBO = fbo;
409
    }
410
}
411
412
void GraphicsContextGLOpenGL::bindRenderbuffer(GCGLenum target, PlatformGLObject renderbuffer)
413
{
414
    if (!makeContextCurrent())
415
        return;
416
417
    ::glBindRenderbufferEXT(target, renderbuffer);
418
}
419
420
421
void GraphicsContextGLOpenGL::bindTexture(GCGLenum target, PlatformGLObject texture)
422
{
423
    if (!makeContextCurrent())
424
        return;
425
426
    m_state.setBoundTexture(m_state.activeTextureUnit, texture, target);
427
    ::glBindTexture(target, texture);
428
}
429
430
void GraphicsContextGLOpenGL::blendColor(GCGLclampf red, GCGLclampf green, GCGLclampf blue, GCGLclampf alpha)
431
{
432
    if (!makeContextCurrent())
433
        return;
434
435
    ::glBlendColor(red, green, blue, alpha);
436
}
437
438
void GraphicsContextGLOpenGL::blendEquation(GCGLenum mode)
439
{
440
    if (!makeContextCurrent())
441
        return;
442
443
    ::glBlendEquation(mode);
444
}
445
446
void GraphicsContextGLOpenGL::blendEquationSeparate(GCGLenum modeRGB, GCGLenum modeAlpha)
447
{
448
    if (!makeContextCurrent())
449
        return;
450
451
    ::glBlendEquationSeparate(modeRGB, modeAlpha);
452
}
453
454
455
void GraphicsContextGLOpenGL::blendFunc(GCGLenum sfactor, GCGLenum dfactor)
456
{
457
    if (!makeContextCurrent())
458
        return;
459
460
    ::glBlendFunc(sfactor, dfactor);
461
}       
462
463
void GraphicsContextGLOpenGL::blendFuncSeparate(GCGLenum srcRGB, GCGLenum dstRGB, GCGLenum srcAlpha, GCGLenum dstAlpha)
464
{
465
    if (!makeContextCurrent())
466
        return;
467
468
    ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
469
}
470
471
void GraphicsContextGLOpenGL::bufferData(GCGLenum target, GCGLsizeiptr size, GCGLenum usage)
472
{
473
    if (!makeContextCurrent())
474
        return;
475
476
    ::glBufferData(target, size, 0, usage);
477
}
478
479
void GraphicsContextGLOpenGL::bufferData(GCGLenum target, GCGLSpan<const void> data, GCGLenum usage)
480
{
481
    if (!makeContextCurrent())
482
        return;
483
484
    ::glBufferData(target, data.bufSize, data.data, usage);
485
}
486
487
void GraphicsContextGLOpenGL::bufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<const GCGLvoid> data)
488
{
489
    if (!makeContextCurrent())
490
        return;
491
492
    ::glBufferSubData(target, offset, data.bufSize, data.data);
493
}
494
495
GCGLenum GraphicsContextGLOpenGL::checkFramebufferStatus(GCGLenum target)
496
{
497
    if (!makeContextCurrent())
498
        return GL_INVALID_OPERATION;
499
500
    return ::glCheckFramebufferStatusEXT(target);
501
}
502
503
void GraphicsContextGLOpenGL::clearColor(GCGLclampf r, GCGLclampf g, GCGLclampf b, GCGLclampf a)
504
{
505
    if (!makeContextCurrent())
506
        return;
507
508
    ::glClearColor(r, g, b, a);
509
}
510
511
void GraphicsContextGLOpenGL::clear(GCGLbitfield mask)
512
{
513
    if (!makeContextCurrent())
514
        return;
515
516
    ::glClear(mask);
517
    checkGPUStatus();
518
}
519
520
void GraphicsContextGLOpenGL::clearStencil(GCGLint s)
521
{
522
    if (!makeContextCurrent())
523
        return;
524
525
    ::glClearStencil(s);
526
}
527
528
void GraphicsContextGLOpenGL::colorMask(GCGLboolean red, GCGLboolean green, GCGLboolean blue, GCGLboolean alpha)
529
{
530
    if (!makeContextCurrent())
531
        return;
532
533
    ::glColorMask(red, green, blue, alpha);
534
}
535
536
void GraphicsContextGLOpenGL::compileShader(PlatformGLObject shader)
537
{
538
    ASSERT(shader);
539
    if (!makeContextCurrent())
540
        return;
541
542
    // Turn on name mapping. Due to the way ANGLE name hashing works, we
543
    // point a global hashmap to the map owned by this context.
544
    ShBuiltInResources ANGLEResources = m_compiler.getResources();
545
    ShHashFunction64 previousHashFunction = ANGLEResources.HashFunction;
546
    ANGLEResources.HashFunction = nameHashForShader;
547
548
    if (!nameHashMapForShaders)
549
        nameHashMapForShaders = makeUnique<ShaderNameHash>();
550
    setCurrentNameHashMapForShader(nameHashMapForShaders.get());
551
    m_compiler.setResources(ANGLEResources);
552
553
    String translatedShaderSource = m_extensions->getTranslatedShaderSourceANGLE(shader);
554
555
    ANGLEResources.HashFunction = previousHashFunction;
556
    m_compiler.setResources(ANGLEResources);
557
    setCurrentNameHashMapForShader(nullptr);
558
559
    if (!translatedShaderSource.length())
560
        return;
561
562
    const CString& translatedShaderCString = translatedShaderSource.utf8();
563
    const char* translatedShaderPtr = translatedShaderCString.data();
564
    int translatedShaderLength = translatedShaderCString.length();
565
566
    LOG(WebGL, "--- begin original shader source ---\n%s\n--- end original shader source ---\n", getShaderSource(shader).utf8().data());
567
    LOG(WebGL, "--- begin translated shader source ---\n%s\n--- end translated shader source ---", translatedShaderPtr);
568
569
    ::glShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength);
570
    
571
    ::glCompileShader(shader);
572
    
573
    int compileStatus;
574
    
575
    ::glGetShaderiv(shader, COMPILE_STATUS, &compileStatus);
576
577
    ShaderSourceMap::iterator result = m_shaderSourceMap.find(shader);
578
    ShaderSourceEntry& entry = result->value;
579
580
    // Populate the shader log
581
    GLint length = 0;
582
    ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
583
584
    if (length) {
585
        GLsizei size = 0;
586
        Vector<GLchar> info(length);
587
        ::glGetShaderInfoLog(shader, length, &size, info.data());
588
589
        PlatformGLObject shaders[2] = { shader, 0 };
590
        entry.log = getUnmangledInfoLog(shaders, 1, String(info.data(), size));
591
    }
592
593
    if (compileStatus != GL_TRUE) {
594
        entry.isValid = false;
595
        LOG(WebGL, "Error: shader translator produced a shader that OpenGL would not compile.");
596
    }
597
}
598
599
void GraphicsContextGLOpenGL::compileShaderDirect(PlatformGLObject shader)
600
{
601
    ASSERT(shader);
602
    if (!makeContextCurrent())
603
        return;
604
605
    HashMap<PlatformGLObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
606
607
    if (result == m_shaderSourceMap.end())
608
        return;
609
610
    ShaderSourceEntry& entry = result->value;
611
612
    const CString& shaderSourceCString = entry.source.utf8();
613
    const char* shaderSourcePtr = shaderSourceCString.data();
614
    int shaderSourceLength = shaderSourceCString.length();
615
616
    LOG(WebGL, "--- begin direct shader source ---\n%s\n--- end direct shader source ---\n", shaderSourcePtr);
617
618
    ::glShaderSource(shader, 1, &shaderSourcePtr, &shaderSourceLength);
619
620
    ::glCompileShader(shader);
621
622
    int compileStatus;
623
624
    ::glGetShaderiv(shader, COMPILE_STATUS, &compileStatus);
625
626
    if (compileStatus == GL_TRUE) {
627
        entry.isValid = true;
628
        LOG(WebGL, "Direct compilation of shader succeeded.");
629
    } else {
630
        entry.isValid = false;
631
        LOG(WebGL, "Error: direct compilation of shader failed.");
632
    }
633
}
634
635
void GraphicsContextGLOpenGL::copyTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLint border)
636
{
637
    if (!makeContextCurrent())
638
        return;
639
640
    auto attrs = contextAttributes();
641
642
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
643
    if (attrs.antialias && m_state.boundDrawFBO == m_multisampleFBO) {
644
        resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
645
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
646
    }
647
    ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
648
    if (attrs.antialias && m_state.boundDrawFBO == m_multisampleFBO)
649
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_multisampleFBO);
650
}
651
652
void GraphicsContextGLOpenGL::copyTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
653
{
654
    if (!makeContextCurrent())
655
        return;
656
657
    auto attrs = contextAttributes();
658
659
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
660
    if (attrs.antialias && m_state.boundDrawFBO == m_multisampleFBO) {
661
        resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
662
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
663
    }
664
    ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
665
    if (attrs.antialias && m_state.boundDrawFBO == m_multisampleFBO)
666
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_multisampleFBO);
667
}
668
669
void GraphicsContextGLOpenGL::cullFace(GCGLenum mode)
670
{
671
    if (!makeContextCurrent())
672
        return;
673
674
    ::glCullFace(mode);
675
}
676
677
void GraphicsContextGLOpenGL::depthFunc(GCGLenum func)
678
{
679
    if (!makeContextCurrent())
680
        return;
681
682
    ::glDepthFunc(func);
683
}
684
685
void GraphicsContextGLOpenGL::depthMask(GCGLboolean flag)
686
{
687
    if (!makeContextCurrent())
688
        return;
689
690
    ::glDepthMask(flag);
691
}
692
693
void GraphicsContextGLOpenGL::detachShader(PlatformGLObject program, PlatformGLObject shader)
694
{
695
    ASSERT(program);
696
    ASSERT(shader);
697
    if (!makeContextCurrent())
698
        return;
699
700
    m_shaderProgramSymbolCountMap.remove(program);
701
    ::glDetachShader(program, shader);
702
}
703
704
void GraphicsContextGLOpenGL::disable(GCGLenum cap)
705
{
706
    if (!makeContextCurrent())
707
        return;
708
709
    ::glDisable(cap);
710
}
711
712
void GraphicsContextGLOpenGL::disableVertexAttribArray(GCGLuint index)
713
{
714
    if (!makeContextCurrent())
715
        return;
716
717
    ::glDisableVertexAttribArray(index);
718
}
719
720
void GraphicsContextGLOpenGL::drawArrays(GCGLenum mode, GCGLint first, GCGLsizei count)
721
{
722
    if (!makeContextCurrent())
723
        return;
724
725
    ::glDrawArrays(mode, first, count);
726
    checkGPUStatus();
727
}
728
729
void GraphicsContextGLOpenGL::drawElements(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset)
730
{
731
    if (!makeContextCurrent())
732
        return;
733
734
    ::glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
735
    checkGPUStatus();
736
}
737
738
void GraphicsContextGLOpenGL::enable(GCGLenum cap)
739
{
740
    if (!makeContextCurrent())
741
        return;
742
743
    ::glEnable(cap);
744
}
745
746
void GraphicsContextGLOpenGL::enableVertexAttribArray(GCGLuint index)
747
{
748
    if (!makeContextCurrent())
749
        return;
750
751
    ::glEnableVertexAttribArray(index);
752
}
753
754
void GraphicsContextGLOpenGL::finish()
755
{
756
    if (!makeContextCurrent())
757
        return;
758
759
    ::glFinish();
760
}
761
762
void GraphicsContextGLOpenGL::flush()
763
{
764
    if (!makeContextCurrent())
765
        return;
766
767
    ::glFlush();
768
}
769
770
void GraphicsContextGLOpenGL::framebufferRenderbuffer(GCGLenum target, GCGLenum attachment, GCGLenum renderbuffertarget, PlatformGLObject buffer)
771
{
772
    if (!makeContextCurrent())
773
        return;
774
775
    ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer);
776
}
777
778
void GraphicsContextGLOpenGL::framebufferTexture2D(GCGLenum target, GCGLenum attachment, GCGLenum textarget, PlatformGLObject texture, GCGLint level)
779
{
780
    if (!makeContextCurrent())
781
        return;
782
783
    ::glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
784
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
785
}
786
787
void GraphicsContextGLOpenGL::frontFace(GCGLenum mode)
788
{
789
    if (!makeContextCurrent())
790
        return;
791
792
    ::glFrontFace(mode);
793
}
794
795
void GraphicsContextGLOpenGL::generateMipmap(GCGLenum target)
796
{
797
    if (!makeContextCurrent())
798
        return;
799
800
    ::glGenerateMipmap(target);
801
}
802
803
bool GraphicsContextGLOpenGL::getActiveAttribImpl(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
804
{
805
    if (!program) {
806
        synthesizeGLError(INVALID_VALUE);
807
        return false;
808
    }
809
    if (!makeContextCurrent())
810
        return false;
811
812
    GLint maxAttributeSize = 0;
813
    ::glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize);
814
    Vector<GLchar> name(maxAttributeSize); // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination.
815
    GLsizei nameLength = 0;
816
    GLint size = 0;
817
    GLenum type = 0;
818
    ::glGetActiveAttrib(program, index, maxAttributeSize, &nameLength, &size, &type, name.data());
819
    if (!nameLength)
820
        return false;
821
    
822
    String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, String(name.data(), nameLength));
823
    
824
#ifndef NDEBUG
825
    String uniformName(name.data(), nameLength);
826
    LOG(WebGL, "Program %d is mapping active attribute %d from '%s' to '%s'", program, index, uniformName.utf8().data(), originalName.utf8().data());
827
#endif
828
829
    info.name = originalName;
830
    info.type = type;
831
    info.size = size;
832
    return true;
833
}
834
835
bool GraphicsContextGLOpenGL::getActiveAttrib(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
836
{
837
    GCGLint symbolCount;
838
    auto result = m_shaderProgramSymbolCountMap.find(program);
839
    if (result == m_shaderProgramSymbolCountMap.end()) {
840
        getNonBuiltInActiveSymbolCount(program, GraphicsContextGL::ACTIVE_ATTRIBUTES, &symbolCount);
841
        result = m_shaderProgramSymbolCountMap.find(program);
842
    }
843
    
844
    ActiveShaderSymbolCounts& symbolCounts = result->value;
845
    GCGLuint rawIndex = (index < symbolCounts.filteredToActualAttributeIndexMap.size()) ? symbolCounts.filteredToActualAttributeIndexMap[index] : -1;
846
847
    return getActiveAttribImpl(program, rawIndex, info);
848
}
849
850
bool GraphicsContextGLOpenGL::getActiveUniformImpl(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
851
{
852
    if (!program) {
853
        synthesizeGLError(INVALID_VALUE);
854
        return false;
855
    }
856
857
    if (!makeContextCurrent())
858
        return false;
859
860
    GLint maxUniformSize = 0;
861
    ::glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize);
862
863
    Vector<GLchar> name(maxUniformSize); // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination.
864
    GLsizei nameLength = 0;
865
    GLint size = 0;
866
    GLenum type = 0;
867
    ::glGetActiveUniform(program, index, maxUniformSize, &nameLength, &size, &type, name.data());
868
    if (!nameLength)
869
        return false;
870
    
871
    String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, String(name.data(), nameLength));
872
    
873
#ifndef NDEBUG
874
    String uniformName(name.data(), nameLength);
875
    LOG(WebGL, "Program %d is mapping active uniform %d from '%s' to '%s'", program, index, uniformName.utf8().data(), originalName.utf8().data());
876
#endif
877
    
878
    info.name = originalName;
879
    info.type = type;
880
    info.size = size;
881
    return true;
882
}
883
884
bool GraphicsContextGLOpenGL::getActiveUniform(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
885
{
886
    GCGLint symbolCount;
887
    auto result = m_shaderProgramSymbolCountMap.find(program);
888
    if (result == m_shaderProgramSymbolCountMap.end()) {
889
        getNonBuiltInActiveSymbolCount(program, GraphicsContextGL::ACTIVE_UNIFORMS, &symbolCount);
890
        result = m_shaderProgramSymbolCountMap.find(program);
891
    }
892
    
893
    ActiveShaderSymbolCounts& symbolCounts = result->value;
894
    GCGLuint rawIndex = (index < symbolCounts.filteredToActualUniformIndexMap.size()) ? symbolCounts.filteredToActualUniformIndexMap[index] : -1;
895
    
896
    return getActiveUniformImpl(program, rawIndex, info);
897
}
898
899
void GraphicsContextGLOpenGL::getAttachedShaders(PlatformGLObject program, GCGLsizei maxCount, GCGLsizei* count, PlatformGLObject* shaders)
900
{
901
    if (!program) {
902
        synthesizeGLError(INVALID_VALUE);
903
        return;
904
    }
905
    if (!makeContextCurrent())
906
        return;
907
908
    ::glGetAttachedShaders(program, maxCount, count, shaders);
909
}
910
911
static String generateHashedName(const String& name)
912
{
913
    if (name.isEmpty())
914
        return name;
915
    uint64_t number = nameHashForShader(name.utf8().data(), name.length());
916
    return makeString("webgl_", hex(number, Lowercase));
917
}
918
919
std::optional<String> GraphicsContextGLOpenGL::mappedSymbolInShaderSourceMap(PlatformGLObject shader, ANGLEShaderSymbolType symbolType, const String& name)
920
{
921
    auto result = m_shaderSourceMap.find(shader);
922
    if (result == m_shaderSourceMap.end())
923
        return std::nullopt;
924
925
    const auto& symbolMap = result->value.symbolMap(symbolType);
926
    auto symbolEntry = symbolMap.find(name);
927
    if (symbolEntry == symbolMap.end())
928
        return std::nullopt;
929
930
    auto& mappedName = symbolEntry->value.get().mappedName;
931
    return String(mappedName.c_str(), mappedName.length());
932
}
933
934
String GraphicsContextGLOpenGL::mappedSymbolName(PlatformGLObject program, ANGLEShaderSymbolType symbolType, const String& name)
935
{
936
    GCGLsizei count = 0;
937
    PlatformGLObject shaders[2] = { };
938
    getAttachedShaders(program, 2, &count, shaders);
939
940
    for (GCGLsizei i = 0; i < count; ++i) {
941
        auto mappedName = mappedSymbolInShaderSourceMap(shaders[i], symbolType, name);
942
        if (mappedName)
943
            return mappedName.value();
944
    }
945
946
    // We might have detached or deleted the shaders after linking.
947
    auto result = m_linkedShaderMap.find(program);
948
    if (result != m_linkedShaderMap.end()) {
949
        auto linkedShaders = result->value;
950
        auto mappedName = mappedSymbolInShaderSourceMap(linkedShaders.first, symbolType, name);
951
        if (mappedName)
952
            return mappedName.value();
953
        mappedName = mappedSymbolInShaderSourceMap(linkedShaders.second, symbolType, name);
954
        if (mappedName)
955
            return mappedName.value();
956
    }
957
958
    if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE && !name.isEmpty()) {
959
        // Attributes are a special case: they may be requested before any shaders have been compiled,
960
        // and aren't even required to be used in any shader program.
961
        if (!nameHashMapForShaders)
962
            nameHashMapForShaders = makeUnique<ShaderNameHash>();
963
        setCurrentNameHashMapForShader(nameHashMapForShaders.get());
964
965
        auto generatedName = generateHashedName(name);
966
967
        setCurrentNameHashMapForShader(nullptr);
968
969
        m_possiblyUnusedAttributeMap.set(generatedName, name);
970
971
        return generatedName;
972
    }
973
974
    return name;
975
}
976
977
std::optional<String> GraphicsContextGLOpenGL::originalSymbolInShaderSourceMap(PlatformGLObject shader, ANGLEShaderSymbolType symbolType, const String& name)
978
{
979
    auto result = m_shaderSourceMap.find(shader);
980
    if (result == m_shaderSourceMap.end())
981
        return std::nullopt;
982
983
    const auto& symbolMap = result->value.symbolMap(symbolType);
984
    for (const auto& symbolEntry : symbolMap) {
985
        if (name == symbolEntry.value.get().mappedName.c_str())
986
            return symbolEntry.key;
987
    }
988
    return std::nullopt;
989
}
990
991
String GraphicsContextGLOpenGL::originalSymbolName(PlatformGLObject program, ANGLEShaderSymbolType symbolType, const String& name)
992
{
993
    GCGLsizei count;
994
    PlatformGLObject shaders[2];
995
    getAttachedShaders(program, 2, &count, shaders);
996
    
997
    for (GCGLsizei i = 0; i < count; ++i) {
998
        auto originalName = originalSymbolInShaderSourceMap(shaders[i], symbolType, name);
999
        if (originalName)
1000
            return originalName.value();
1001
    }
1002
1003
    // We might have detached or deleted the shaders after linking.
1004
    auto result = m_linkedShaderMap.find(program);
1005
    if (result != m_linkedShaderMap.end()) {
1006
        auto linkedShaders = result->value;
1007
        auto originalName = originalSymbolInShaderSourceMap(linkedShaders.first, symbolType, name);
1008
        if (originalName)
1009
            return originalName.value();
1010
        originalName = originalSymbolInShaderSourceMap(linkedShaders.second, symbolType, name);
1011
        if (originalName)
1012
            return originalName.value();
1013
    }
1014
1015
    if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE && !name.isEmpty()) {
1016
        // Attributes are a special case: they may be requested before any shaders have been compiled,
1017
        // and aren't even required to be used in any shader program.
1018
1019
        const auto& cached = m_possiblyUnusedAttributeMap.find(name);
1020
        if (cached != m_possiblyUnusedAttributeMap.end())
1021
            return cached->value;
1022
    }
1023
1024
    return name;
1025
}
1026
1027
String GraphicsContextGLOpenGL::mappedSymbolName(PlatformGLObject shaders[2], size_t count, const String& name)
1028
{
1029
    for (size_t symbolType = 0; symbolType <= static_cast<size_t>(SHADER_SYMBOL_TYPE_VARYING); ++symbolType) {
1030
        for (size_t i = 0; i < count; ++i) {
1031
            ShaderSourceMap::iterator result = m_shaderSourceMap.find(shaders[i]);
1032
            if (result == m_shaderSourceMap.end())
1033
                continue;
1034
            
1035
            const ShaderSymbolMap& symbolMap = result->value.symbolMap(static_cast<enum ANGLEShaderSymbolType>(symbolType));
1036
            for (const auto& symbolEntry : symbolMap) {
1037
                if (name == symbolEntry.value.get().mappedName.c_str())
1038
                    return symbolEntry.key;
1039
            }
1040
        }
1041
    }
1042
    return name;
1043
}
1044
1045
int GraphicsContextGLOpenGL::getAttribLocation(PlatformGLObject program, const String& name)
1046
{
1047
    if (!program)
1048
        return -1;
1049
1050
    if (!makeContextCurrent())
1051
        return -1;
1052
1053
1054
    String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name);
1055
    LOG(WebGL, "::glGetAttribLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data());
1056
    return ::glGetAttribLocation(program, mappedName.utf8().data());
1057
}
1058
1059
int GraphicsContextGLOpenGL::getAttribLocationDirect(PlatformGLObject program, const String& name)
1060
{
1061
    if (!program)
1062
        return -1;
1063
1064
    if (!makeContextCurrent())
1065
        return -1;
1066
1067
1068
    return ::glGetAttribLocation(program, name.utf8().data());
1069
}
1070
1071
bool GraphicsContextGLOpenGL::moveErrorsToSyntheticErrorList()
1072
{
1073
    if (!makeContextCurrent())
1074
        return false;
1075
1076
    bool movedAnError = false;
1077
1078
    // Set an arbitrary limit of 100 here to avoid creating a hang if
1079
    // a problem driver has a bug that causes it to never clear the error.
1080
    // Otherwise, we would just loop until we got NO_ERROR.
1081
    for (unsigned i = 0; i < 100; ++i) {
1082
        GCGLenum error = glGetError();
1083
        if (error == NO_ERROR)
1084
            break;
1085
        m_syntheticErrors.add(error);
1086
        movedAnError = true;
1087
    }
1088
1089
    return movedAnError;
1090
}
1091
1092
GCGLenum GraphicsContextGLOpenGL::getError()
1093
{
1094
    if (!m_syntheticErrors.isEmpty()) {
1095
        // Need to move the current errors to the synthetic error list in case
1096
        // that error is already there, since the expected behavior of both
1097
        // glGetError and getError is to only report each error code once.
1098
        moveErrorsToSyntheticErrorList();
1099
        return m_syntheticErrors.takeFirst();
1100
    }
1101
1102
    if (!makeContextCurrent())
1103
        return GL_INVALID_OPERATION;
1104
1105
    return ::glGetError();
1106
}
1107
1108
String GraphicsContextGLOpenGL::getString(GCGLenum name)
1109
{
1110
    if (!makeContextCurrent())
1111
        return String();
1112
1113
    return String(reinterpret_cast<const char*>(::glGetString(name)));
1114
}
1115
1116
void GraphicsContextGLOpenGL::hint(GCGLenum target, GCGLenum mode)
1117
{
1118
    if (!makeContextCurrent())
1119
        return;
1120
1121
    ::glHint(target, mode);
1122
}
1123
1124
GCGLboolean GraphicsContextGLOpenGL::isBuffer(PlatformGLObject buffer)
1125
{
1126
    if (!buffer)
1127
        return GL_FALSE;
1128
1129
    if (!makeContextCurrent())
1130
        return GL_FALSE;
1131
1132
    return ::glIsBuffer(buffer);
1133
}
1134
1135
GCGLboolean GraphicsContextGLOpenGL::isEnabled(GCGLenum cap)
1136
{
1137
    if (!makeContextCurrent())
1138
        return GL_FALSE;
1139
1140
    return ::glIsEnabled(cap);
1141
}
1142
1143
GCGLboolean GraphicsContextGLOpenGL::isFramebuffer(PlatformGLObject framebuffer)
1144
{
1145
    if (!framebuffer)
1146
        return GL_FALSE;
1147
1148
    if (!makeContextCurrent())
1149
        return GL_FALSE;
1150
1151
    return ::glIsFramebufferEXT(framebuffer);
1152
}
1153
1154
GCGLboolean GraphicsContextGLOpenGL::isProgram(PlatformGLObject program)
1155
{
1156
    if (!program)
1157
        return GL_FALSE;
1158
1159
    if (!makeContextCurrent())
1160
        return GL_FALSE;
1161
1162
    return ::glIsProgram(program);
1163
}
1164
1165
GCGLboolean GraphicsContextGLOpenGL::isRenderbuffer(PlatformGLObject renderbuffer)
1166
{
1167
    if (!renderbuffer)
1168
        return GL_FALSE;
1169
1170
    if (!makeContextCurrent())
1171
        return GL_FALSE;
1172
1173
    return ::glIsRenderbufferEXT(renderbuffer);
1174
}
1175
1176
GCGLboolean GraphicsContextGLOpenGL::isShader(PlatformGLObject shader)
1177
{
1178
    if (!shader)
1179
        return GL_FALSE;
1180
1181
    if (!makeContextCurrent())
1182
        return GL_FALSE;
1183
1184
    return ::glIsShader(shader);
1185
}
1186
1187
GCGLboolean GraphicsContextGLOpenGL::isTexture(PlatformGLObject texture)
1188
{
1189
    if (!texture)
1190
        return GL_FALSE;
1191
1192
    if (!makeContextCurrent())
1193
        return GL_FALSE;
1194
1195
    return ::glIsTexture(texture);
1196
}
1197
1198
void GraphicsContextGLOpenGL::lineWidth(GCGLfloat width)
1199
{
1200
    if (!makeContextCurrent())
1201
        return;
1202
1203
    ::glLineWidth(width);
1204
}
1205
1206
void GraphicsContextGLOpenGL::linkProgram(PlatformGLObject program)
1207
{
1208
    ASSERT(program);
1209
    if (!makeContextCurrent())
1210
        return;
1211
1212
1213
    GCGLsizei count = 0;
1214
    PlatformGLObject shaders[2] = { };
1215
    getAttachedShaders(program, 2, &count, shaders);
1216
1217
    if (count == 2)
1218
        m_linkedShaderMap.set(program, std::make_pair(shaders[0], shaders[1]));
1219
1220
    ::glLinkProgram(program);
1221
}
1222
1223
void GraphicsContextGLOpenGL::pixelStorei(GCGLenum pname, GCGLint param)
1224
{
1225
    if (!makeContextCurrent())
1226
        return;
1227
1228
    ::glPixelStorei(pname, param);
1229
}
1230
1231
void GraphicsContextGLOpenGL::polygonOffset(GCGLfloat factor, GCGLfloat units)
1232
{
1233
    if (!makeContextCurrent())
1234
        return;
1235
1236
    ::glPolygonOffset(factor, units);
1237
}
1238
1239
void GraphicsContextGLOpenGL::sampleCoverage(GCGLclampf value, GCGLboolean invert)
1240
{
1241
    if (!makeContextCurrent())
1242
        return;
1243
1244
    ::glSampleCoverage(value, invert);
1245
}
1246
1247
void GraphicsContextGLOpenGL::scissor(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1248
{
1249
    if (!makeContextCurrent())
1250
        return;
1251
1252
    ::glScissor(x, y, width, height);
1253
}
1254
1255
void GraphicsContextGLOpenGL::shaderSource(PlatformGLObject shader, const String& string)
1256
{
1257
    ASSERT(shader);
1258
1259
    if (!makeContextCurrent())
1260
        return;
1261
1262
1263
    ShaderSourceEntry entry;
1264
1265
    entry.source = string;
1266
1267
    m_shaderSourceMap.set(shader, WTFMove(entry));
1268
}
1269
1270
void GraphicsContextGLOpenGL::stencilFunc(GCGLenum func, GCGLint ref, GCGLuint mask)
1271
{
1272
    if (!makeContextCurrent())
1273
        return;
1274
1275
    ::glStencilFunc(func, ref, mask);
1276
}
1277
1278
void GraphicsContextGLOpenGL::stencilFuncSeparate(GCGLenum face, GCGLenum func, GCGLint ref, GCGLuint mask)
1279
{
1280
    if (!makeContextCurrent())
1281
        return;
1282
1283
    ::glStencilFuncSeparate(face, func, ref, mask);
1284
}
1285
1286
void GraphicsContextGLOpenGL::stencilMask(GCGLuint mask)
1287
{
1288
    if (!makeContextCurrent())
1289
        return;
1290
1291
    ::glStencilMask(mask);
1292
}
1293
1294
void GraphicsContextGLOpenGL::stencilMaskSeparate(GCGLenum face, GCGLuint mask)
1295
{
1296
    if (!makeContextCurrent())
1297
        return;
1298
1299
    ::glStencilMaskSeparate(face, mask);
1300
}
1301
1302
void GraphicsContextGLOpenGL::stencilOp(GCGLenum fail, GCGLenum zfail, GCGLenum zpass)
1303
{
1304
    if (!makeContextCurrent())
1305
        return;
1306
1307
    ::glStencilOp(fail, zfail, zpass);
1308
}
1309
1310
void GraphicsContextGLOpenGL::stencilOpSeparate(GCGLenum face, GCGLenum fail, GCGLenum zfail, GCGLenum zpass)
1311
{
1312
    if (!makeContextCurrent())
1313
        return;
1314
1315
    ::glStencilOpSeparate(face, fail, zfail, zpass);
1316
}
1317
1318
void GraphicsContextGLOpenGL::texParameterf(GCGLenum target, GCGLenum pname, GCGLfloat value)
1319
{
1320
    if (!makeContextCurrent())
1321
        return;
1322
1323
    ::glTexParameterf(target, pname, value);
1324
}
1325
1326
void GraphicsContextGLOpenGL::texParameteri(GCGLenum target, GCGLenum pname, GCGLint value)
1327
{
1328
    if (!makeContextCurrent())
1329
        return;
1330
1331
    ::glTexParameteri(target, pname, value);
1332
}
1333
1334
void GraphicsContextGLOpenGL::uniform1f(GCGLint location, GCGLfloat v0)
1335
{
1336
    if (!makeContextCurrent())
1337
        return;
1338
1339
    ::glUniform1f(location, v0);
1340
}
1341
1342
void GraphicsContextGLOpenGL::uniform1fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1343
{
1344
    if (!makeContextCurrent())
1345
        return;
1346
1347
    ::glUniform1fv(location, array.bufSize, array.data);
1348
}
1349
1350
void GraphicsContextGLOpenGL::uniform2f(GCGLint location, GCGLfloat v0, GCGLfloat v1)
1351
{
1352
    if (!makeContextCurrent())
1353
        return;
1354
1355
    ::glUniform2f(location, v0, v1);
1356
}
1357
1358
void GraphicsContextGLOpenGL::uniform2fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1359
{
1360
    ASSERT(!(array.bufSize % 2));
1361
    if (!makeContextCurrent())
1362
        return;
1363
1364
    ::glUniform2fv(location, array.bufSize / 2, array.data);
1365
}
1366
1367
void GraphicsContextGLOpenGL::uniform3f(GCGLint location, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2)
1368
{
1369
    if (!makeContextCurrent())
1370
        return;
1371
1372
    ::glUniform3f(location, v0, v1, v2);
1373
}
1374
1375
void GraphicsContextGLOpenGL::uniform3fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1376
{
1377
    ASSERT(!(array.bufSize % 3));
1378
    if (!makeContextCurrent())
1379
        return;
1380
1381
    ::glUniform3fv(location, array.bufSize / 3, array.data);
1382
}
1383
1384
void GraphicsContextGLOpenGL::uniform4f(GCGLint location, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2, GCGLfloat v3)
1385
{
1386
    if (!makeContextCurrent())
1387
        return;
1388
1389
    ::glUniform4f(location, v0, v1, v2, v3);
1390
}
1391
1392
void GraphicsContextGLOpenGL::uniform4fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1393
{
1394
    ASSERT(!(array.bufSize % 4));
1395
    if (!makeContextCurrent())
1396
        return;
1397
1398
    ::glUniform4fv(location, array.bufSize / 4, array.data);
1399
}
1400
1401
void GraphicsContextGLOpenGL::uniform1i(GCGLint location, GCGLint v0)
1402
{
1403
    if (!makeContextCurrent())
1404
        return;
1405
1406
    ::glUniform1i(location, v0);
1407
}
1408
1409
void GraphicsContextGLOpenGL::uniform1iv(GCGLint location, GCGLSpan<const GCGLint> array)
1410
{
1411
    if (!makeContextCurrent())
1412
        return;
1413
1414
    ::glUniform1iv(location, array.bufSize, array.data);
1415
}
1416
1417
void GraphicsContextGLOpenGL::uniform2i(GCGLint location, GCGLint v0, GCGLint v1)
1418
{
1419
    if (!makeContextCurrent())
1420
        return;
1421
1422
    ::glUniform2i(location, v0, v1);
1423
}
1424
1425
void GraphicsContextGLOpenGL::uniform2iv(GCGLint location, GCGLSpan<const GCGLint> array)
1426
{
1427
    ASSERT(!(array.bufSize % 2));
1428
    if (!makeContextCurrent())
1429
        return;
1430
1431
    ::glUniform2iv(location, array.bufSize / 2, array.data);
1432
}
1433
1434
void GraphicsContextGLOpenGL::uniform3i(GCGLint location, GCGLint v0, GCGLint v1, GCGLint v2)
1435
{
1436
    if (!makeContextCurrent())
1437
        return;
1438
1439
    ::glUniform3i(location, v0, v1, v2);
1440
}
1441
1442
void GraphicsContextGLOpenGL::uniform3iv(GCGLint location, GCGLSpan<const GCGLint> array)
1443
{
1444
    ASSERT(!(array.bufSize % 3));
1445
    if (!makeContextCurrent())
1446
        return;
1447
1448
    ::glUniform3iv(location, array.bufSize / 3, array.data);
1449
}
1450
1451
void GraphicsContextGLOpenGL::uniform4i(GCGLint location, GCGLint v0, GCGLint v1, GCGLint v2, GCGLint v3)
1452
{
1453
    if (!makeContextCurrent())
1454
        return;
1455
1456
    ::glUniform4i(location, v0, v1, v2, v3);
1457
}
1458
1459
void GraphicsContextGLOpenGL::uniform4iv(GCGLint location, GCGLSpan<const GCGLint> array)
1460
{
1461
    ASSERT(!(array.bufSize % 4));
1462
    if (!makeContextCurrent())
1463
        return;
1464
1465
    ::glUniform4iv(location, array.bufSize / 4, array.data);
1466
}
1467
1468
void GraphicsContextGLOpenGL::uniformMatrix2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1469
{
1470
    ASSERT(!(array.bufSize % 4));
1471
    if (!makeContextCurrent())
1472
        return;
1473
1474
    ::glUniformMatrix2fv(location, array.bufSize / 4, transpose, array.data);
1475
}
1476
1477
void GraphicsContextGLOpenGL::uniformMatrix3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1478
{
1479
    ASSERT(!(array.bufSize % 9));
1480
    if (!makeContextCurrent())
1481
        return;
1482
1483
    ::glUniformMatrix3fv(location, array.bufSize / 9, transpose, array.data);
1484
}
1485
1486
void GraphicsContextGLOpenGL::uniformMatrix4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1487
{
1488
    ASSERT(!(array.bufSize % 16));
1489
    if (!makeContextCurrent())
1490
        return;
1491
1492
    ::glUniformMatrix4fv(location, array.bufSize / 16, transpose, array.data);
1493
}
1494
1495
void GraphicsContextGLOpenGL::useProgram(PlatformGLObject program)
1496
{
1497
    if (!makeContextCurrent())
1498
        return;
1499
1500
    ::glUseProgram(program);
1501
}
1502
1503
void GraphicsContextGLOpenGL::validateProgram(PlatformGLObject program)
1504
{
1505
    ASSERT(program);
1506
1507
    if (!makeContextCurrent())
1508
        return;
1509
1510
    ::glValidateProgram(program);
1511
}
1512
1513
void GraphicsContextGLOpenGL::vertexAttrib1f(GCGLuint index, GCGLfloat v0)
1514
{
1515
    if (!makeContextCurrent())
1516
        return;
1517
1518
    ::glVertexAttrib1f(index, v0);
1519
}
1520
1521
void GraphicsContextGLOpenGL::vertexAttrib1fv(GCGLuint index, GCGLSpan<const GCGLfloat, 1> array)
1522
{
1523
    if (!makeContextCurrent())
1524
        return;
1525
1526
    ::glVertexAttrib1fv(index, array.data);
1527
}
1528
1529
void GraphicsContextGLOpenGL::vertexAttrib2f(GCGLuint index, GCGLfloat v0, GCGLfloat v1)
1530
{
1531
    if (!makeContextCurrent())
1532
        return;
1533
1534
    ::glVertexAttrib2f(index, v0, v1);
1535
}
1536
1537
void GraphicsContextGLOpenGL::vertexAttrib2fv(GCGLuint index, GCGLSpan<const GCGLfloat, 2> array)
1538
{
1539
    if (!makeContextCurrent())
1540
        return;
1541
1542
    ::glVertexAttrib2fv(index, array.data);
1543
}
1544
1545
void GraphicsContextGLOpenGL::vertexAttrib3f(GCGLuint index, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2)
1546
{
1547
    if (!makeContextCurrent())
1548
        return;
1549
1550
    ::glVertexAttrib3f(index, v0, v1, v2);
1551
}
1552
1553
void GraphicsContextGLOpenGL::vertexAttrib3fv(GCGLuint index, GCGLSpan<const GCGLfloat, 3> array)
1554
{
1555
    if (!makeContextCurrent())
1556
        return;
1557
1558
    ::glVertexAttrib3fv(index, array.data);
1559
}
1560
1561
void GraphicsContextGLOpenGL::vertexAttrib4f(GCGLuint index, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2, GCGLfloat v3)
1562
{
1563
    if (!makeContextCurrent())
1564
        return;
1565
1566
    ::glVertexAttrib4f(index, v0, v1, v2, v3);
1567
}
1568
1569
void GraphicsContextGLOpenGL::vertexAttrib4fv(GCGLuint index, GCGLSpan<const GCGLfloat, 4> array)
1570
{
1571
    if (!makeContextCurrent())
1572
        return;
1573
1574
    ::glVertexAttrib4fv(index, array.data);
1575
}
1576
1577
void GraphicsContextGLOpenGL::vertexAttribPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLboolean normalized, GCGLsizei stride, GCGLintptr offset)
1578
{
1579
    if (!makeContextCurrent())
1580
        return;
1581
1582
    ::glVertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
1583
}
1584
1585
void GraphicsContextGLOpenGL::viewport(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1586
{
1587
    if (!makeContextCurrent())
1588
        return;
1589
1590
    ::glViewport(x, y, width, height);
1591
}
1592
1593
PlatformGLObject GraphicsContextGLOpenGL::createVertexArray()
1594
{
1595
    return getExtensions().createVertexArrayOES();
1596
}
1597
1598
void GraphicsContextGLOpenGL::deleteVertexArray(PlatformGLObject array)
1599
{
1600
    getExtensions().deleteVertexArrayOES(array);
1601
}
1602
1603
GCGLboolean GraphicsContextGLOpenGL::isVertexArray(PlatformGLObject array)
1604
{
1605
    return getExtensions().isVertexArrayOES(array);
1606
}
1607
1608
void GraphicsContextGLOpenGL::bindVertexArray(PlatformGLObject array)
1609
{
1610
    getExtensions().bindVertexArrayOES(array);
1611
}
1612
1613
void GraphicsContextGLOpenGL::getBooleanv(GCGLenum pname, GCGLSpan<GCGLboolean> value)
1614
{
1615
    if (!makeContextCurrent())
1616
        return;
1617
1618
    ::glGetBooleanv(pname, value.data);
1619
}
1620
1621
GCGLint GraphicsContextGLOpenGL::getBufferParameteri(GCGLenum target, GCGLenum pname)
1622
{
1623
    GCGLint value = 0;
1624
    if (!makeContextCurrent())
1625
        return value;
1626
1627
    ::glGetBufferParameteriv(target, pname, &value);
1628
    return value;
1629
}
1630
1631
void GraphicsContextGLOpenGL::getFloatv(GCGLenum pname, GCGLSpan<GCGLfloat> value)
1632
{
1633
    if (!makeContextCurrent())
1634
        return;
1635
1636
    ::glGetFloatv(pname, value.data);
1637
}
1638
1639
GCGLint64 GraphicsContextGLOpenGL::getInteger64(GCGLenum pname)
1640
{
1641
    UNUSED_PARAM(pname);
1642
    if (!makeContextCurrent())
1643
        return 0;
1644
1645
    GCGLint64 value = 0;
1646
    // FIXME 141178: Before enabling this we must first switch over to using gl3.h and creating and initialing the WebGL2 context using OpenGL ES 3.0.
1647
    // ::glGetInteger64v(pname, value);
1648
    return value;
1649
}
1650
1651
GCGLint64 GraphicsContextGLOpenGL::getInteger64i(GCGLenum pname, GCGLuint index)
1652
{
1653
    UNUSED_PARAM(pname);
1654
    UNUSED_PARAM(index);
1655
    if (!makeContextCurrent())
1656
        return 0;
1657
1658
    GCGLint64 value = 0;
1659
    // FIXME 141178: Before enabling this we must first switch over to using gl3.h and creating and initialing the WebGL2 context using OpenGL ES 3.0.
1660
    // ::glGetInteger64i_v(pname, index, value);
1661
    return value;
1662
}
1663
1664
GCGLint GraphicsContextGLOpenGL::getFramebufferAttachmentParameteri(GCGLenum target, GCGLenum attachment, GCGLenum pname)
1665
{
1666
    GCGLint value = 0;
1667
    if (!makeContextCurrent())
1668
        return 0;
1669
    if (attachment == DEPTH_STENCIL_ATTACHMENT)
1670
        attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works.
1671
    ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, &value);
1672
    return value;
1673
}
1674
1675
GCGLint GraphicsContextGLOpenGL::getProgrami(PlatformGLObject program, GCGLenum pname)
1676
{
1677
    if (!makeContextCurrent())
1678
        return 0;
1679
    GCGLint value = 0;
1680
    ::glGetProgramiv(program, pname, &value);
1681
    return value;
1682
}
1683
1684
void GraphicsContextGLOpenGL::getNonBuiltInActiveSymbolCount(PlatformGLObject program, GCGLenum pname, GCGLint* value)
1685
{
1686
    ASSERT(ACTIVE_ATTRIBUTES == pname || ACTIVE_UNIFORMS == pname);
1687
    if (!value)
1688
        return;
1689
1690
    if (!makeContextCurrent())
1691
        return;
1692
1693
    const auto& result = m_shaderProgramSymbolCountMap.find(program);
1694
    if (result != m_shaderProgramSymbolCountMap.end()) {
1695
        *value = result->value.countForType(pname);
1696
        return;
1697
    }
1698
1699
    m_shaderProgramSymbolCountMap.set(program, ActiveShaderSymbolCounts());
1700
    ActiveShaderSymbolCounts& symbolCounts = m_shaderProgramSymbolCountMap.find(program)->value;
1701
1702
    // Retrieve the active attributes, build a filtered count, and a mapping of
1703
    // our internal attributes indexes to the real unfiltered indexes inside OpenGL.
1704
    GCGLint attributeCount = 0;
1705
    ::glGetProgramiv(program, ACTIVE_ATTRIBUTES, &attributeCount);
1706
    for (GCGLint i = 0; i < attributeCount; ++i) {
1707
        ActiveInfo info;
1708
        getActiveAttribImpl(program, i, info);
1709
        if (info.name.startsWith("gl_"))
1710
            continue;
1711
1712
        symbolCounts.filteredToActualAttributeIndexMap.append(i);
1713
    }
1714
    
1715
    // Do the same for uniforms.
1716
    GCGLint uniformCount = 0;
1717
    ::glGetProgramiv(program, ACTIVE_UNIFORMS, &uniformCount);
1718
    for (GCGLint i = 0; i < uniformCount; ++i) {
1719
        ActiveInfo info;
1720
        getActiveUniformImpl(program, i, info);
1721
        if (info.name.startsWith("gl_"))
1722
            continue;
1723
        
1724
        symbolCounts.filteredToActualUniformIndexMap.append(i);
1725
    }
1726
    
1727
    *value = symbolCounts.countForType(pname);
1728
}
1729
1730
String GraphicsContextGLOpenGL::getUnmangledInfoLog(PlatformGLObject shaders[2], GCGLsizei count, const String& log)
1731
{
1732
    LOG(WebGL, "Original ShaderInfoLog:\n%s", log.utf8().data());
1733
1734
    JSC::Yarr::RegularExpression regExp("webgl_[0123456789abcdefABCDEF]+");
1735
1736
    StringBuilder processedLog;
1737
    
1738
    // ANGLE inserts a "#extension" line into the shader source that
1739
    // causes a warning in some compilers. There is no point showing
1740
    // this warning to the user since they didn't write the code that
1741
    // is causing it.
1742
    static const NeverDestroyed<String> angleWarning { "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n"_s };
1743
    int startFrom = log.startsWith(angleWarning) ? angleWarning.get().length() : 0;
1744
    int matchedLength = 0;
1745
1746
    do {
1747
        int start = regExp.match(log, startFrom, &matchedLength);
1748
        if (start == -1)
1749
            break;
1750
1751
        processedLog.append(log.substring(startFrom, start - startFrom));
1752
        startFrom = start + matchedLength;
1753
1754
        const String& mangledSymbol = log.substring(start, matchedLength);
1755
        const String& mappedSymbol = mappedSymbolName(shaders, count, mangledSymbol);
1756
        LOG(WebGL, "Demangling: %s to %s", mangledSymbol.utf8().data(), mappedSymbol.utf8().data());
1757
        processedLog.append(mappedSymbol);
1758
    } while (startFrom < static_cast<int>(log.length()));
1759
1760
    processedLog.append(log.substring(startFrom, log.length() - startFrom));
1761
1762
    LOG(WebGL, "Unmangled ShaderInfoLog:\n%s", processedLog.toString().utf8().data());
1763
    return processedLog.toString();
1764
}
1765
1766
String GraphicsContextGLOpenGL::getProgramInfoLog(PlatformGLObject program)
1767
{
1768
    ASSERT(program);
1769
1770
    if (!makeContextCurrent())
1771
        return String();
1772
1773
    GLint length = 0;
1774
    ::glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
1775
    if (!length)
1776
        return String(); 
1777
1778
    GLsizei size = 0;
1779
    Vector<GLchar> info(length);
1780
    ::glGetProgramInfoLog(program, length, &size, info.data());
1781
1782
    GCGLsizei count;
1783
    PlatformGLObject shaders[2];
1784
    getAttachedShaders(program, 2, &count, shaders);
1785
1786
    return getUnmangledInfoLog(shaders, count, String(info.data(), size));
1787
}
1788
1789
GCGLint GraphicsContextGLOpenGL::getRenderbufferParameteri(GCGLenum target, GCGLenum pname)
1790
{
1791
    GCGLint value = 0;
1792
    if (!makeContextCurrent())
1793
        return value;
1794
    ::glGetRenderbufferParameterivEXT(target, pname, &value);
1795
    return value;
1796
}
1797
1798
GCGLint GraphicsContextGLOpenGL::getShaderi(PlatformGLObject shader, GCGLenum pname)
1799
{
1800
    ASSERT(shader);
1801
    GCGLint value = 0;
1802
    if (!makeContextCurrent())
1803
        return value;
1804
1805
1806
    const auto& result = m_shaderSourceMap.find(shader);
1807
    
1808
    switch (pname) {
1809
    case DELETE_STATUS:
1810
    case SHADER_TYPE:
1811
        ::glGetShaderiv(shader, pname, &value);
1812
        break;
1813
    case COMPILE_STATUS:
1814
        if (result != m_shaderSourceMap.end())
1815
            value = static_cast<int>(result->value.isValid);
1816
        break;
1817
    case INFO_LOG_LENGTH:
1818
        if (result != m_shaderSourceMap.end())
1819
            value = getShaderInfoLog(shader).length();
1820
        break;
1821
    case SHADER_SOURCE_LENGTH:
1822
        value = getShaderSource(shader).length();
1823
        break;
1824
    default:
1825
        synthesizeGLError(INVALID_ENUM);
1826
    }
1827
    return value;
1828
}
1829
1830
String GraphicsContextGLOpenGL::getShaderInfoLog(PlatformGLObject shader)
1831
{
1832
    ASSERT(shader);
1833
1834
    if (!makeContextCurrent())
1835
        return String();
1836
1837
    const auto& result = m_shaderSourceMap.find(shader);
1838
    if (result == m_shaderSourceMap.end())
1839
        return String(); 
1840
1841
    const ShaderSourceEntry& entry = result->value;
1842
    if (!entry.isValid)
1843
        return entry.log;
1844
1845
    GLint length = 0;
1846
    ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
1847
    if (!length)
1848
        return String(); 
1849
1850
    GLsizei size = 0;
1851
    Vector<GLchar> info(length);
1852
    ::glGetShaderInfoLog(shader, length, &size, info.data());
1853
1854
    PlatformGLObject shaders[2] = { shader, 0 };
1855
    return getUnmangledInfoLog(shaders, 1, String(info.data(), size));
1856
}
1857
1858
String GraphicsContextGLOpenGL::getShaderSource(PlatformGLObject shader)
1859
{
1860
    ASSERT(shader);
1861
1862
    if (!makeContextCurrent())
1863
        return String();
1864
1865
    const auto& result = m_shaderSourceMap.find(shader);
1866
    if (result == m_shaderSourceMap.end())
1867
        return String(); 
1868
1869
    return result->value.source;
1870
}
1871
1872
GCGLfloat GraphicsContextGLOpenGL::getTexParameterf(GCGLenum target, GCGLenum pname)
1873
{
1874
    GCGLfloat value = 0.f;
1875
    if (!makeContextCurrent())
1876
        return value;
1877
    ::glGetTexParameterfv(target, pname, &value);
1878
    return value;
1879
}
1880
1881
GCGLint GraphicsContextGLOpenGL::getTexParameteri(GCGLenum target, GCGLenum pname)
1882
{
1883
    GCGLint value = 0;
1884
    if (!makeContextCurrent())
1885
        return value;
1886
    ::glGetTexParameteriv(target, pname, &value);
1887
    return value;
1888
}
1889
1890
void GraphicsContextGLOpenGL::getUniformfv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLfloat> value)
1891
{
1892
    if (!makeContextCurrent())
1893
        return;
1894
1895
    ::glGetUniformfv(program, location, value.data);
1896
}
1897
1898
void GraphicsContextGLOpenGL::getUniformiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLint> value)
1899
{
1900
    if (!makeContextCurrent())
1901
        return;
1902
1903
    ::glGetUniformiv(program, location, value.data);
1904
}
1905
1906
void GraphicsContextGLOpenGL::getUniformuiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLuint> value)
1907
{
1908
    UNUSED_PARAM(program);
1909
    UNUSED_PARAM(location);
1910
    UNUSED_PARAM(value);
1911
}
1912
1913
GCGLint GraphicsContextGLOpenGL::getUniformLocation(PlatformGLObject program, const String& name)
1914
{
1915
    ASSERT(program);
1916
1917
    if (!makeContextCurrent())
1918
        return -1;
1919
1920
    String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, name);
1921
    LOG(WebGL, "::getUniformLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data());
1922
    return ::glGetUniformLocation(program, mappedName.utf8().data());
1923
}
1924
1925
GCGLsizeiptr GraphicsContextGLOpenGL::getVertexAttribOffset(GCGLuint index, GCGLenum pname)
1926
{
1927
    if (!makeContextCurrent())
1928
        return 0;
1929
1930
    GLvoid* pointer = 0;
1931
    ::glGetVertexAttribPointerv(index, pname, &pointer);
1932
    return static_cast<GCGLsizeiptr>(reinterpret_cast<intptr_t>(pointer));
1933
}
1934
1935
void GraphicsContextGLOpenGL::texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoff, GCGLint yoff, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
1936
{
1937
    if (!makeContextCurrent())
1938
        return;
1939
1940
#if !USE(OPENGL_ES)
1941
    if (type == HALF_FLOAT_OES)
1942
        type = GL_HALF_FLOAT_ARB;
1943
#endif
1944
1945
    if (m_usingCoreProfile)  {
1946
        // There are some format values used in WebGL that are deprecated when using a core profile, so we need
1947
        // to adapt them, as we do in GraphicsContextGLOpenGL::texImage2D().
1948
        switch (format) {
1949
        case ALPHA:
1950
            // We are using GL_RED to back GL_ALPHA, so do it here as well.
1951
            format = RED;
1952
            break;
1953
        case LUMINANCE_ALPHA:
1954
            // We are using GL_RG to back GL_LUMINANCE_ALPHA, so do it here as well.
1955
            format = RG;
1956
            break;
1957
        default:
1958
            break;
1959
        }
1960
    }
1961
1962
    // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size.
1963
    ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels.data);
1964
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1965
}
1966
1967
void GraphicsContextGLOpenGL::compressedTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
1968
{
1969
    if (!makeContextCurrent())
1970
        return;
1971
1972
    ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data.data);
1973
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1974
}
1975
1976
void GraphicsContextGLOpenGL::compressedTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
1977
{
1978
    if (!makeContextCurrent())
1979
        return;
1980
1981
    ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data.data);
1982
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1983
}
1984
1985
PlatformGLObject GraphicsContextGLOpenGL::createBuffer()
1986
{
1987
    if (!makeContextCurrent())
1988
        return 0;
1989
1990
    GLuint o = 0;
1991
    glGenBuffers(1, &o);
1992
    return o;
1993
}
1994
1995
PlatformGLObject GraphicsContextGLOpenGL::createFramebuffer()
1996
{
1997
    if (!makeContextCurrent())
1998
        return 0;
1999
2000
    GLuint o = 0;
2001
    glGenFramebuffersEXT(1, &o);
2002
    return o;
2003
}
2004
2005
PlatformGLObject GraphicsContextGLOpenGL::createProgram()
2006
{
2007
    if (!makeContextCurrent())
2008
        return 0;
2009
2010
    return glCreateProgram();
2011
}
2012
2013
PlatformGLObject GraphicsContextGLOpenGL::createRenderbuffer()
2014
{
2015
    if (!makeContextCurrent())
2016
        return 0;
2017
2018
    GLuint o = 0;
2019
    glGenRenderbuffersEXT(1, &o);
2020
    return o;
2021
}
2022
2023
PlatformGLObject GraphicsContextGLOpenGL::createShader(GCGLenum type)
2024
{
2025
    if (!makeContextCurrent())
2026
        return 0;
2027
2028
    return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
2029
}
2030
2031
PlatformGLObject GraphicsContextGLOpenGL::createTexture()
2032
{
2033
    if (!makeContextCurrent())
2034
        return 0;
2035
2036
    GLuint o = 0;
2037
    glGenTextures(1, &o);
2038
    m_state.textureSeedCount.add(o);
2039
    return o;
2040
}
2041
2042
void GraphicsContextGLOpenGL::deleteBuffer(PlatformGLObject buffer)
2043
{
2044
    if (!makeContextCurrent())
2045
        return;
2046
2047
    glDeleteBuffers(1, &buffer);
2048
}
2049
2050
void GraphicsContextGLOpenGL::deleteFramebuffer(PlatformGLObject framebuffer)
2051
{
2052
    if (!makeContextCurrent())
2053
        return;
2054
2055
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
2056
    if (framebuffer == m_state.boundDrawFBO) {
2057
        // Make sure the framebuffer is not going to be used for drawing
2058
        // operations after it gets deleted.
2059
        bindFramebuffer(FRAMEBUFFER, 0);
2060
    }
2061
    glDeleteFramebuffersEXT(1, &framebuffer);
2062
}
2063
2064
void GraphicsContextGLOpenGL::deleteProgram(PlatformGLObject program)
2065
{
2066
    if (!makeContextCurrent())
2067
        return;
2068
2069
    m_shaderProgramSymbolCountMap.remove(program);
2070
    glDeleteProgram(program);
2071
}
2072
2073
void GraphicsContextGLOpenGL::deleteRenderbuffer(PlatformGLObject renderbuffer)
2074
{
2075
    if (!makeContextCurrent())
2076
        return;
2077
2078
    glDeleteRenderbuffersEXT(1, &renderbuffer);
2079
}
2080
2081
void GraphicsContextGLOpenGL::deleteShader(PlatformGLObject shader)
2082
{
2083
    if (!makeContextCurrent())
2084
        return;
2085
2086
    glDeleteShader(shader);
2087
}
2088
2089
void GraphicsContextGLOpenGL::deleteTexture(PlatformGLObject texture)
2090
{
2091
    if (!makeContextCurrent())
2092
        return;
2093
2094
    m_state.boundTextureMap.removeIf([texture] (auto& keyValue) {
2095
        return keyValue.value.first == texture;
2096
    });
2097
    glDeleteTextures(1, &texture);
2098
    m_state.textureSeedCount.removeAll(texture);
2099
}
2100
2101
void GraphicsContextGLOpenGL::synthesizeGLError(GCGLenum error)
2102
{
2103
    // Need to move the current errors to the synthetic error list to
2104
    // preserve the order of errors, so a caller to getError will get
2105
    // any errors from glError before the error we are synthesizing.
2106
    moveErrorsToSyntheticErrorList();
2107
    m_syntheticErrors.add(error);
2108
}
2109
2110
void GraphicsContextGLOpenGL::forceContextLost()
2111
{
2112
    for (auto* client : copyToVector(m_clients))
2113
        client->forceContextLost();
2114
}
2115
2116
void GraphicsContextGLOpenGL::recycleContext()
2117
{
2118
    for (auto* client : copyToVector(m_clients))
2119
        client->recycleContext();
2120
}
2121
2122
void GraphicsContextGLOpenGL::dispatchContextChangedNotification()
2123
{
2124
    for (auto* client : copyToVector(m_clients))
2125
        client->dispatchContextChangedNotification();
2126
}
2127
2128
void GraphicsContextGLOpenGL::texImage2DDirect(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, const void* pixels)
2129
{
2130
    if (!makeContextCurrent())
2131
        return;
2132
2133
    ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
2134
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
2135
}
2136
2137
void GraphicsContextGLOpenGL::drawArraysInstanced(GCGLenum mode, GCGLint first, GCGLsizei count, GCGLsizei primcount)
2138
{
2139
    getExtensions().drawArraysInstancedANGLE(mode, first, count, primcount);
2140
    checkGPUStatus();
2141
}
2142
2143
void GraphicsContextGLOpenGL::drawElementsInstanced(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset, GCGLsizei primcount)
2144
{
2145
    getExtensions().drawElementsInstancedANGLE(mode, count, type, offset, primcount);
2146
    checkGPUStatus();
2147
}
2148
2149
void GraphicsContextGLOpenGL::vertexAttribDivisor(GCGLuint index, GCGLuint divisor)
2150
{
2151
    getExtensions().vertexAttribDivisorANGLE(index, divisor);
2152
}
2153
2154
#if HAVE(OPENGL_4) && ENABLE(WEBGL2)
2155
void GraphicsContextGLOpenGL::primitiveRestartIndex(GCGLuint index)
2156
{
2157
    if (!makeContextCurrent())
2158
        return;
2159
2160
    ::glPrimitiveRestartIndex(index);
2161
}
2162
#endif
2163
2164
void GraphicsContextGLOpenGL::bufferData(GCGLenum target, const void* data, GCGLenum usage, GCGLuint srcOffset, GCGLuint length)
2165
{
2166
    UNUSED_PARAM(target);
2167
    UNUSED_PARAM(data);
2168
    UNUSED_PARAM(usage);
2169
    UNUSED_PARAM(srcOffset);
2170
    UNUSED_PARAM(length);
2171
}
2172
2173
void GraphicsContextGLOpenGL::bufferSubData(GCGLenum target, GCGLintptr dstByteOffset, const void* srcData, GCGLuint srcOffset, GCGLuint length)
2174
{
2175
    UNUSED_PARAM(target);
2176
    UNUSED_PARAM(dstByteOffset);
2177
    UNUSED_PARAM(srcData);
2178
    UNUSED_PARAM(srcOffset);
2179
    UNUSED_PARAM(length);
2180
}
2181
2182
#if HAVE(OPENGL_4) || HAVE(OPENGL_ES_3)
2183
void GraphicsContextGLOpenGL::copyBufferSubData(GCGLenum readTarget, GCGLenum writeTarget, GCGLintptr readOffset, GCGLintptr writeOffset, GCGLsizeiptr size)
2184
{
2185
    if (!makeContextCurrent())
2186
        return;
2187
2188
    ::glCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
2189
}
2190
#else
2191
void GraphicsContextGLOpenGL::copyBufferSubData(GCGLenum, GCGLenum, GCGLintptr, GCGLintptr, GCGLsizeiptr)
2192
{
2193
}
2194
#endif
2195
2196
void GraphicsContextGLOpenGL::getBufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<GCGLvoid> data)
2197
{
2198
#if HAVE(OPENGL_4) || HAVE(OPENGL_ES_3)
2199
    if (!makeContextCurrent())
2200
        return;
2201
    GCGLvoid* ptr = ::glMapBufferRange(target, offset, data.bufSize, GraphicsContextGL::MAP_READ_BIT);
2202
    if (!ptr)
2203
        return;
2204
    memcpy(data.data, ptr, data.bufSize);
2205
    if (!::glUnmapBuffer(target))
2206
        synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2207
#else
2208
    UNUSED_PARAM(target);
2209
    UNUSED_PARAM(offset);
2210
    UNUSED_PARAM(data);
2211
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2212
#endif
2213
}
2214
2215
2216
void GraphicsContextGLOpenGL::blitFramebuffer(GCGLint srcX0, GCGLint srcY0, GCGLint srcX1, GCGLint srcY1, GCGLint dstX0, GCGLint dstY0, GCGLint dstX1, GCGLint dstY1, GCGLbitfield mask, GCGLenum filter)
2217
{
2218
    UNUSED_PARAM(srcX0);
2219
    UNUSED_PARAM(srcY0);
2220
    UNUSED_PARAM(srcX1);
2221
    UNUSED_PARAM(srcY1);
2222
    UNUSED_PARAM(dstX0);
2223
    UNUSED_PARAM(dstY0);
2224
    UNUSED_PARAM(dstX1);
2225
    UNUSED_PARAM(dstY1);
2226
    UNUSED_PARAM(mask);
2227
    UNUSED_PARAM(filter);
2228
}
2229
2230
void GraphicsContextGLOpenGL::framebufferTextureLayer(GCGLenum target, GCGLenum attachment, PlatformGLObject texture, GCGLint level, GCGLint layer)
2231
{
2232
    UNUSED_PARAM(target);
2233
    UNUSED_PARAM(attachment);
2234
    UNUSED_PARAM(texture);
2235
    UNUSED_PARAM(level);
2236
    UNUSED_PARAM(layer);
2237
}
2238
2239
void GraphicsContextGLOpenGL::invalidateFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments)
2240
{
2241
    UNUSED_PARAM(target);
2242
    UNUSED_PARAM(attachments);
2243
}
2244
2245
void GraphicsContextGLOpenGL::invalidateSubFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
2246
{
2247
    UNUSED_PARAM(target);
2248
    UNUSED_PARAM(attachments);
2249
    UNUSED_PARAM(x);
2250
    UNUSED_PARAM(y);
2251
    UNUSED_PARAM(width);
2252
    UNUSED_PARAM(height);
2253
}
2254
2255
void GraphicsContextGLOpenGL::readBuffer(GCGLenum src)
2256
{
2257
    UNUSED_PARAM(src);
2258
}
2259
2260
#if HAVE(OPENGL_4) || HAVE(OPENGL_ES_3)
2261
void GraphicsContextGLOpenGL::getInternalformativ(GCGLenum target, GCGLenum internalformat, GCGLenum pname, GCGLSpan<GCGLint> data)
2262
{
2263
#if USE(OPENGL_ES)
2264
    if (!makeContextCurrent())
2265
        return;
2266
2267
    ::glGetInternalformativ(target, internalformat, pname, data.bufSize, data.data);
2268
#else
2269
    UNUSED_PARAM(target);
2270
    UNUSED_PARAM(internalformat);
2271
    UNUSED_PARAM(pname);
2272
    UNUSED_PARAM(bufSize);
2273
    UNUSED_PARAM(params);
2274
#endif
2275
}
2276
2277
void GraphicsContextGLOpenGL::renderbufferStorageMultisample(GCGLenum target, GCGLsizei samples, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
2278
{
2279
    if (!makeContextCurrent())
2280
        return;
2281
2282
    ::glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
2283
}
2284
2285
void GraphicsContextGLOpenGL::texStorage2D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
2286
{
2287
    if (!makeContextCurrent())
2288
        return;
2289
2290
    ::glTexStorage2D(target, levels, internalformat, width, height);
2291
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
2292
}
2293
2294
void GraphicsContextGLOpenGL::texStorage3D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth)
2295
{
2296
    if (!makeContextCurrent())
2297
        return;
2298
2299
    ::glTexStorage3D(target, levels, internalformat, width, height, depth);
2300
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
2301
}
2302
#else
2303
void GraphicsContextGLOpenGL::getInternalformativ(GCGLenum, GCGLenum, GCGLenum, GCGLSpan<GCGLint>)
2304
{
2305
}
2306
2307
void GraphicsContextGLOpenGL::renderbufferStorageMultisample(GCGLenum, GCGLsizei, GCGLenum, GCGLsizei, GCGLsizei)
2308
{
2309
}
2310
2311
void GraphicsContextGLOpenGL::texStorage2D(GCGLenum, GCGLsizei, GCGLenum, GCGLsizei, GCGLsizei)
2312
{
2313
}
2314
2315
void GraphicsContextGLOpenGL::texStorage3D(GCGLenum, GCGLsizei, GCGLenum, GCGLsizei, GCGLsizei, GCGLsizei)
2316
{
2317
}
2318
#endif
2319
2320
void GraphicsContextGLOpenGL::copyTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
2321
{
2322
    UNUSED_PARAM(target);
2323
    UNUSED_PARAM(level);
2324
    UNUSED_PARAM(xoffset);
2325
    UNUSED_PARAM(yoffset);
2326
    UNUSED_PARAM(zoffset);
2327
    UNUSED_PARAM(x);
2328
    UNUSED_PARAM(y);
2329
    UNUSED_PARAM(width);
2330
    UNUSED_PARAM(height);
2331
}
2332
2333
GCGLint GraphicsContextGLOpenGL::getFragDataLocation(PlatformGLObject program, const String& name)
2334
{
2335
    UNUSED_PARAM(program);
2336
    UNUSED_PARAM(name);
2337
2338
    return 0;
2339
}
2340
2341
void GraphicsContextGLOpenGL::uniform1ui(GCGLint location, GCGLuint v0)
2342
{
2343
    UNUSED_PARAM(location);
2344
    UNUSED_PARAM(v0);
2345
}
2346
2347
void GraphicsContextGLOpenGL::uniform2ui(GCGLint location, GCGLuint v0, GCGLuint v1)
2348
{
2349
    UNUSED_PARAM(location);
2350
    UNUSED_PARAM(v0);
2351
    UNUSED_PARAM(v1);
2352
}
2353
2354
void GraphicsContextGLOpenGL::uniform3ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2)
2355
{
2356
    UNUSED_PARAM(location);
2357
    UNUSED_PARAM(v0);
2358
    UNUSED_PARAM(v1);
2359
    UNUSED_PARAM(v2);
2360
}
2361
2362
void GraphicsContextGLOpenGL::uniform4ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2, GCGLuint v3)
2363
{
2364
    UNUSED_PARAM(location);
2365
    UNUSED_PARAM(v0);
2366
    UNUSED_PARAM(v1);
2367
    UNUSED_PARAM(v2);
2368
    UNUSED_PARAM(v3);
2369
}
2370
2371
void GraphicsContextGLOpenGL::uniform1uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2372
{
2373
    UNUSED_PARAM(location);
2374
    UNUSED_PARAM(data);
2375
}
2376
2377
void GraphicsContextGLOpenGL::uniform2uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2378
{
2379
    UNUSED_PARAM(location);
2380
    UNUSED_PARAM(data);
2381
}
2382
2383
void GraphicsContextGLOpenGL::uniform3uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2384
{
2385
    UNUSED_PARAM(location);
2386
    UNUSED_PARAM(data);
2387
}
2388
2389
void GraphicsContextGLOpenGL::uniform4uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2390
{
2391
    UNUSED_PARAM(location);
2392
    UNUSED_PARAM(data);
2393
}
2394
2395
void GraphicsContextGLOpenGL::uniformMatrix2x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2396
{
2397
    UNUSED_PARAM(location);
2398
    UNUSED_PARAM(transpose);
2399
    UNUSED_PARAM(data);
2400
}
2401
2402
void GraphicsContextGLOpenGL::uniformMatrix3x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2403
{
2404
    UNUSED_PARAM(location);
2405
    UNUSED_PARAM(transpose);
2406
    UNUSED_PARAM(data);
2407
}
2408
2409
void GraphicsContextGLOpenGL::uniformMatrix2x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2410
{
2411
    UNUSED_PARAM(location);
2412
    UNUSED_PARAM(transpose);
2413
    UNUSED_PARAM(data);
2414
}
2415
2416
void GraphicsContextGLOpenGL::uniformMatrix4x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2417
{
2418
    UNUSED_PARAM(location);
2419
    UNUSED_PARAM(transpose);
2420
    UNUSED_PARAM(data);
2421
}
2422
2423
void GraphicsContextGLOpenGL::uniformMatrix3x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2424
{
2425
    UNUSED_PARAM(location);
2426
    UNUSED_PARAM(transpose);
2427
    UNUSED_PARAM(data);
2428
}
2429
2430
void GraphicsContextGLOpenGL::uniformMatrix4x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2431
{
2432
    UNUSED_PARAM(location);
2433
    UNUSED_PARAM(transpose);
2434
    UNUSED_PARAM(data);
2435
}
2436
2437
void GraphicsContextGLOpenGL::vertexAttribI4i(GCGLuint index, GCGLint x, GCGLint y, GCGLint z, GCGLint w)
2438
{
2439
    UNUSED_PARAM(index);
2440
    UNUSED_PARAM(x);
2441
    UNUSED_PARAM(y);
2442
    UNUSED_PARAM(z);
2443
    UNUSED_PARAM(w);
2444
}
2445
2446
void GraphicsContextGLOpenGL::vertexAttribI4iv(GCGLuint index, GCGLSpan<const GCGLint, 4> values)
2447
{
2448
    UNUSED_PARAM(index);
2449
    UNUSED_PARAM(values);
2450
}
2451
2452
void GraphicsContextGLOpenGL::vertexAttribI4ui(GCGLuint index, GCGLuint x, GCGLuint y, GCGLuint z, GCGLuint w)
2453
{
2454
    UNUSED_PARAM(index);
2455
    UNUSED_PARAM(x);
2456
    UNUSED_PARAM(y);
2457
    UNUSED_PARAM(z);
2458
    UNUSED_PARAM(w);
2459
}
2460
2461
void GraphicsContextGLOpenGL::vertexAttribI4uiv(GCGLuint index, GCGLSpan<const GCGLuint, 4> values)
2462
{
2463
    UNUSED_PARAM(index);
2464
    UNUSED_PARAM(values);
2465
}
2466
2467
void GraphicsContextGLOpenGL::vertexAttribIPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLsizei stride, GCGLintptr offset)
2468
{
2469
    UNUSED_PARAM(index);
2470
    UNUSED_PARAM(size);
2471
    UNUSED_PARAM(type);
2472
    UNUSED_PARAM(stride);
2473
    UNUSED_PARAM(offset);
2474
}
2475
2476
void GraphicsContextGLOpenGL::drawRangeElements(GCGLenum mode, GCGLuint start, GCGLuint end, GCGLsizei count, GCGLenum type, GCGLintptr offset)
2477
{
2478
    UNUSED_PARAM(mode);
2479
    UNUSED_PARAM(start);
2480
    UNUSED_PARAM(end);
2481
    UNUSED_PARAM(count);
2482
    UNUSED_PARAM(type);
2483
    UNUSED_PARAM(offset);
2484
}
2485
2486
void GraphicsContextGLOpenGL::drawBuffers(GCGLSpan<const GCGLenum> bufs)
2487
{
2488
    UNUSED_PARAM(bufs);
2489
}
2490
2491
void GraphicsContextGLOpenGL::clearBufferiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLint> values)
2492
{
2493
    UNUSED_PARAM(buffer);
2494
    UNUSED_PARAM(drawbuffer);
2495
    UNUSED_PARAM(values);
2496
}
2497
2498
void GraphicsContextGLOpenGL::clearBufferuiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLuint> values)
2499
{
2500
    UNUSED_PARAM(buffer);
2501
    UNUSED_PARAM(drawbuffer);
2502
    UNUSED_PARAM(values);
2503
}
2504
2505
void GraphicsContextGLOpenGL::clearBufferfv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLfloat> values)
2506
{
2507
    UNUSED_PARAM(buffer);
2508
    UNUSED_PARAM(drawbuffer);
2509
    UNUSED_PARAM(values);
2510
}
2511
2512
void GraphicsContextGLOpenGL::clearBufferfi(GCGLenum buffer, GCGLint drawbuffer, GCGLfloat depth, GCGLint stencil)
2513
{
2514
    UNUSED_PARAM(buffer);
2515
    UNUSED_PARAM(drawbuffer);
2516
    UNUSED_PARAM(depth);
2517
    UNUSED_PARAM(stencil);
2518
}
2519
2520
PlatformGLObject GraphicsContextGLOpenGL::createQuery()
2521
{
2522
    return 0;
2523
}
2524
2525
void GraphicsContextGLOpenGL::deleteQuery(PlatformGLObject query)
2526
{
2527
    UNUSED_PARAM(query);
2528
}
2529
2530
GCGLboolean GraphicsContextGLOpenGL::isQuery(PlatformGLObject query)
2531
{
2532
    UNUSED_PARAM(query);
2533
2534
    return false;
2535
}
2536
2537
void GraphicsContextGLOpenGL::beginQuery(GCGLenum target, PlatformGLObject query)
2538
{
2539
    UNUSED_PARAM(target);
2540
    UNUSED_PARAM(query);
2541
}
2542
2543
void GraphicsContextGLOpenGL::endQuery(GCGLenum target)
2544
{
2545
    UNUSED_PARAM(target);
2546
}
2547
2548
PlatformGLObject GraphicsContextGLOpenGL::getQuery(GCGLenum target, GCGLenum pname)
2549
{
2550
    UNUSED_PARAM(target);
2551
    UNUSED_PARAM(pname);
2552
2553
    return 0;
2554
}
2555
2556
GCGLuint GraphicsContextGLOpenGL::getQueryObjectui(PlatformGLObject query, GCGLenum pname)
2557
{
2558
    UNUSED_PARAM(query);
2559
    UNUSED_PARAM(pname);
2560
    return 0;
2561
}
2562
2563
PlatformGLObject GraphicsContextGLOpenGL::createSampler()
2564
{
2565
    return 0;
2566
}
2567
2568
void GraphicsContextGLOpenGL::deleteSampler(PlatformGLObject sampler)
2569
{
2570
    UNUSED_PARAM(sampler);
2571
}
2572
2573
GCGLboolean GraphicsContextGLOpenGL::isSampler(PlatformGLObject sampler)
2574
{
2575
    UNUSED_PARAM(sampler);
2576
2577
    return false;
2578
}
2579
2580
void GraphicsContextGLOpenGL::bindSampler(GCGLuint unit, PlatformGLObject sampler)
2581
{
2582
    UNUSED_PARAM(unit);
2583
    UNUSED_PARAM(sampler);
2584
}
2585
2586
void GraphicsContextGLOpenGL::samplerParameteri(PlatformGLObject sampler, GCGLenum pname, GCGLint param)
2587
{
2588
    UNUSED_PARAM(sampler);
2589
    UNUSED_PARAM(pname);
2590
    UNUSED_PARAM(param);
2591
}
2592
2593
void GraphicsContextGLOpenGL::samplerParameterf(PlatformGLObject sampler, GCGLenum pname, GCGLfloat param)
2594
{
2595
    UNUSED_PARAM(sampler);
2596
    UNUSED_PARAM(pname);
2597
    UNUSED_PARAM(param);
2598
}
2599
2600
GCGLfloat GraphicsContextGLOpenGL::getSamplerParameterf(PlatformGLObject sampler, GCGLenum pname)
2601
{
2602
    UNUSED_PARAM(sampler);
2603
    UNUSED_PARAM(pname);
2604
    return 0.f;
2605
}
2606
2607
GCGLint GraphicsContextGLOpenGL::getSamplerParameteri(PlatformGLObject sampler, GCGLenum pname)
2608
2609
{
2610
    UNUSED_PARAM(sampler);
2611
    UNUSED_PARAM(pname);
2612
    return 0;
2613
}
2614
2615
GCGLsync GraphicsContextGLOpenGL::fenceSync(GCGLenum condition, GCGLbitfield flags)
2616
{
2617
    UNUSED_PARAM(condition);
2618
    UNUSED_PARAM(flags);
2619
2620
    return 0;
2621
}
2622
2623
GCGLboolean GraphicsContextGLOpenGL::isSync(GCGLsync sync)
2624
{
2625
    UNUSED_PARAM(sync);
2626
2627
    return false;
2628
}
2629
2630
void GraphicsContextGLOpenGL::deleteSync(GCGLsync sync)
2631
{
2632
    UNUSED_PARAM(sync);
2633
}
2634
2635
GCGLenum GraphicsContextGLOpenGL::clientWaitSync(GCGLsync sync, GCGLbitfield flags, GCGLuint64 timeout)
2636
{
2637
    UNUSED_PARAM(sync);
2638
    UNUSED_PARAM(flags);
2639
    UNUSED_PARAM(timeout);
2640
2641
    return 0;
2642
}
2643
2644
void GraphicsContextGLOpenGL::waitSync(GCGLsync sync, GCGLbitfield flags, GCGLint64 timeout)
2645
{
2646
    UNUSED_PARAM(sync);
2647
    UNUSED_PARAM(flags);
2648
    UNUSED_PARAM(timeout);
2649
}
2650
2651
GCGLint GraphicsContextGLOpenGL::getSynci(GCGLsync sync, GCGLenum pname)
2652
{
2653
    UNUSED_PARAM(sync);
2654
    UNUSED_PARAM(pname);
2655
    return 0;
2656
}
2657
2658
PlatformGLObject GraphicsContextGLOpenGL::createTransformFeedback()
2659
{
2660
    return 0;
2661
}
2662
2663
void GraphicsContextGLOpenGL::deleteTransformFeedback(PlatformGLObject id)
2664
{
2665
    UNUSED_PARAM(id);
2666
}
2667
2668
GCGLboolean GraphicsContextGLOpenGL::isTransformFeedback(PlatformGLObject id)
2669
{
2670
    UNUSED_PARAM(id);
2671
2672
    return false;
2673
}
2674
2675
void GraphicsContextGLOpenGL::bindTransformFeedback(GCGLenum target, PlatformGLObject id)
2676
{
2677
    UNUSED_PARAM(target);
2678
    UNUSED_PARAM(id);
2679
}
2680
2681
void GraphicsContextGLOpenGL::beginTransformFeedback(GCGLenum primitiveMode)
2682
{
2683
    UNUSED_PARAM(primitiveMode);
2684
}
2685
2686
void GraphicsContextGLOpenGL::endTransformFeedback()
2687
{
2688
}
2689
2690
void GraphicsContextGLOpenGL::transformFeedbackVaryings(PlatformGLObject program, const Vector<String>& varyings, GCGLenum bufferMode)
2691
{
2692
    UNUSED_PARAM(program);
2693
    UNUSED_PARAM(varyings);
2694
    UNUSED_PARAM(bufferMode);
2695
}
2696
2697
void GraphicsContextGLOpenGL::getTransformFeedbackVarying(PlatformGLObject program, GCGLuint index, ActiveInfo&)
2698
{
2699
    UNUSED_PARAM(program);
2700
    UNUSED_PARAM(index);
2701
}
2702
2703
void GraphicsContextGLOpenGL::pauseTransformFeedback()
2704
{
2705
}
2706
2707
void GraphicsContextGLOpenGL::resumeTransformFeedback()
2708
{
2709
}
2710
2711
void GraphicsContextGLOpenGL::bindBufferBase(GCGLenum target, GCGLuint index, PlatformGLObject buffer)
2712
{
2713
    UNUSED_PARAM(target);
2714
    UNUSED_PARAM(index);
2715
    UNUSED_PARAM(buffer);
2716
}
2717
2718
void GraphicsContextGLOpenGL::bindBufferRange(GCGLenum target, GCGLuint index, PlatformGLObject buffer, GCGLintptr offset, GCGLsizeiptr size)
2719
{
2720
    UNUSED_PARAM(target);
2721
    UNUSED_PARAM(index);
2722
    UNUSED_PARAM(buffer);
2723
    UNUSED_PARAM(offset);
2724
    UNUSED_PARAM(size);
2725
}
2726
2727
Vector<GCGLuint> GraphicsContextGLOpenGL::getUniformIndices(PlatformGLObject program, const Vector<String>& uniformNames)
2728
{
2729
    UNUSED_PARAM(program);
2730
    UNUSED_PARAM(uniformNames);
2731
2732
    return { };
2733
}
2734
2735
Vector<GCGLint> GraphicsContextGLOpenGL::getActiveUniforms(PlatformGLObject program, const Vector<GCGLuint>& uniformIndices, GCGLenum pname)
2736
{
2737
    Vector<GCGLint> result(uniformIndices.size(), 0);
2738
#if HAVE(OPENGL_4) || HAVE(OPENGL_ES_3)
2739
    ASSERT(program);
2740
    if (!makeContextCurrent())
2741
        return result;
2742
2743
    ::glGetActiveUniformsiv(program, uniformIndices.size(), uniformIndices.data(), pname, result.data());
2744
#else
2745
    UNUSED_PARAM(program);
2746
    UNUSED_PARAM(pname);
2747
#endif
2748
    return result;
2749
}
2750
2751
GCGLuint GraphicsContextGLOpenGL::getUniformBlockIndex(PlatformGLObject program, const String& uniformBlockName)
2752
{
2753
    UNUSED_PARAM(program);
2754
    UNUSED_PARAM(uniformBlockName);
2755
    return 0;
2756
}
2757
2758
String GraphicsContextGLOpenGL::getActiveUniformBlockName(PlatformGLObject program, GCGLuint uniformBlockIndex)
2759
{
2760
    UNUSED_PARAM(program);
2761
    UNUSED_PARAM(uniformBlockIndex);
2762
    return emptyString();
2763
}
2764
2765
void GraphicsContextGLOpenGL::uniformBlockBinding(PlatformGLObject program, GCGLuint uniformBlockIndex, GCGLuint uniformBlockBinding)
2766
{
2767
    UNUSED_PARAM(program);
2768
    UNUSED_PARAM(uniformBlockIndex);
2769
    UNUSED_PARAM(uniformBlockBinding);
2770
}
2771
2772
void GraphicsContextGLOpenGL::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset)
2773
{
2774
    UNUSED_PARAM(x);
2775
    UNUSED_PARAM(y);
2776
    UNUSED_PARAM(width);
2777
    UNUSED_PARAM(height);
2778
    UNUSED_PARAM(format);
2779
    UNUSED_PARAM(type);
2780
    UNUSED_PARAM(offset);
2781
}
2782
2783
void GraphicsContextGLOpenGL::getActiveUniformBlockiv(GCGLuint program, GCGLuint uniformBlockIndex, GCGLenum pname, GCGLSpan<GCGLint> params)
2784
{
2785
    UNUSED_PARAM(program);
2786
    UNUSED_PARAM(uniformBlockIndex);
2787
    UNUSED_PARAM(pname);
2788
    UNUSED_PARAM(params);
2789
}
2790
2791
void GraphicsContextGLOpenGL::texImage2D(GCGLenum, GCGLint, GCGLenum, GCGLsizei, GCGLsizei, GCGLint, GCGLenum, GCGLenum , GCGLintptr)
2792
{
2793
}
2794
2795
void GraphicsContextGLOpenGL::texSubImage2D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLenum, GCGLenum, GCGLintptr)
2796
{
2797
}
2798
2799
void GraphicsContextGLOpenGL::compressedTexImage2D(GCGLenum, GCGLint, GCGLenum, GCGLsizei, GCGLsizei, GCGLint, GCGLsizei, GCGLintptr)
2800
{
2801
}
2802
2803
void GraphicsContextGLOpenGL::compressedTexSubImage2D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLenum, GCGLsizei, GCGLintptr)
2804
{
2805
}
2806
2807
void GraphicsContextGLOpenGL::texImage3D(GCGLenum, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLint, GCGLenum, GCGLenum, GCGLSpan<const GCGLvoid>)
2808
{
2809
}
2810
2811
void GraphicsContextGLOpenGL::texImage3D(GCGLenum, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLint, GCGLenum, GCGLenum, GCGLintptr)
2812
{
2813
}
2814
2815
void GraphicsContextGLOpenGL::texSubImage3D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLenum, GCGLenum, GCGLSpan<const GCGLvoid>)
2816
{
2817
}
2818
2819
void GraphicsContextGLOpenGL::texSubImage3D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLenum, GCGLenum, GCGLintptr)
2820
{
2821
}
2822
2823
void GraphicsContextGLOpenGL::compressedTexImage3D(GCGLenum, GCGLint, GCGLenum, GCGLsizei, GCGLsizei, GCGLsizei, GCGLint, GCGLsizei, GCGLSpan<const GCGLvoid>)
2824
{
2825
}
2826
2827
void GraphicsContextGLOpenGL::compressedTexImage3D(GCGLenum, GCGLint, GCGLenum, GCGLsizei, GCGLsizei, GCGLsizei, GCGLint, GCGLsizei, GCGLintptr)
2828
{
2829
}
2830
2831
void GraphicsContextGLOpenGL::compressedTexSubImage3D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLenum, GCGLsizei, GCGLSpan<const GCGLvoid>)
2832
{
2833
}
2834
2835
void GraphicsContextGLOpenGL::compressedTexSubImage3D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLenum, GCGLsizei, GCGLintptr)
2836
{
2837
}
2838
2839
void GraphicsContextGLOpenGL::multiDrawArraysANGLE(GCGLenum, GCGLSpan<const GCGLint>, GCGLSpan<const GCGLsizei>, GCGLsizei)
2840
{
2841
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2842
}
2843
2844
void GraphicsContextGLOpenGL::multiDrawArraysInstancedANGLE(GCGLenum, GCGLSpan<const GCGLint>, GCGLSpan<const GCGLsizei>, GCGLSpan<const GCGLsizei>, GCGLsizei)
2845
{
2846
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2847
}
2848
2849
void GraphicsContextGLOpenGL::multiDrawElementsANGLE(GCGLenum, GCGLSpan<const GCGLsizei>, GCGLenum, GCGLSpan<const GCGLint>, GCGLsizei)
2850
{
2851
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2852
}
2853
2854
void GraphicsContextGLOpenGL::multiDrawElementsInstancedANGLE(GCGLenum, GCGLSpan<const GCGLsizei>, GCGLenum, GCGLSpan<const GCGLint>, GCGLSpan<const GCGLsizei>, GCGLsizei)
2855
{
2856
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2857
}
2858
2859
bool GraphicsContextGLOpenGL::texImage2DResourceSafe(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLint unpackAlignment)
2860
{
2861
    ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8);
2862
    UniqueArray<unsigned char> zero;
2863
    unsigned size = 0;
2864
    if (width > 0 && height > 0) {
2865
        PixelStoreParams params;
2866
        params.alignment = unpackAlignment;
2867
        GCGLenum error = computeImageSizeInBytes(format, type, width, height, 1, params, &size, nullptr, nullptr);
2868
        if (error != GraphicsContextGL::NO_ERROR) {
2869
            synthesizeGLError(error);
2870
            return false;
2871
        }
2872
        zero = makeUniqueArray<unsigned char>(size);
2873
        if (!zero) {
2874
            synthesizeGLError(GraphicsContextGL::INVALID_VALUE);
2875
            return false;
2876
        }
2877
        memset(zero.get(), 0, size);
2878
    }
2879
    texImage2D(target, level, internalformat, width, height, border, format, type, makeGCGLSpan(zero.get(), size));
2880
    return true;
2881
}
2882
41
void GraphicsContextGLOpenGL::paintRenderingResultsToCanvas(ImageBuffer& imageBuffer)
2883
void GraphicsContextGLOpenGL::paintRenderingResultsToCanvas(ImageBuffer& imageBuffer)
42
{
2884
{
43
    if (!makeContextCurrent())
2885
    if (!makeContextCurrent())
Lines 103-108 std::optional<PixelBuffer> GraphicsContextGLOpenGL::readCompositedResultsForPain a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp_sec3
103
    return readCompositedResults();
2945
    return readCompositedResults();
104
}
2946
}
105
2947
106
} // namespace WebCore
2948
}
107
2949
108
#endif // ENABLE(WEBGL)
2950
#endif // ENABLE(WEBGL) && !USE(ANGLE)
- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h -210 / +10 lines
Lines 25-77 a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec1
25
25
26
#pragma once
26
#pragma once
27
27
28
#if ENABLE(WEBGL)
28
#if ENABLE(WEBGL) && !USE(ANGLE)
29
29
30
#include "ANGLEWebKitBridge.h"
31
#include "ExtensionsGLOpenGLCommon.h"
30
#include "GraphicsContextGL.h"
32
#include "GraphicsContextGL.h"
33
#include "GraphicsContextGLState.h"
31
#include <memory>
34
#include <memory>
32
#include <wtf/HashCountedSet.h>
33
#include <wtf/HashMap.h>
35
#include <wtf/HashMap.h>
34
#include <wtf/ListHashSet.h>
36
#include <wtf/ListHashSet.h>
35
#include <wtf/RetainPtr.h>
36
#include <wtf/UniqueArray.h>
37
#include <wtf/UniqueRef.h>
37
#include <wtf/UniqueRef.h>
38
38
39
#if PLATFORM(COCOA)
40
#include "GraphicsContextGLIOSurfaceSwapChain.h"
41
#include "IOSurface.h"
42
#endif
43
44
#if USE(CA)
45
#include "PlatformCALayer.h"
46
#endif
47
48
#if USE(ANGLE)
49
#include "ANGLEUtilities.h"
50
#else
51
#include "ANGLEWebKitBridge.h"
52
#include "ExtensionsGLOpenGLCommon.h"
53
#endif
54
55
#if PLATFORM(MAC)
56
#include "ScopedHighPerformanceGPURequest.h"
57
#endif
58
59
// FIXME: Find a better way to avoid the name confliction for NO_ERROR.
60
#if PLATFORM(WIN)
61
#undef NO_ERROR
62
#elif PLATFORM(GTK)
63
// This define is from the X11 headers, but it's used below, so we must undefine it.
64
#undef VERSION
65
#endif
66
67
#if PLATFORM(COCOA)
68
OBJC_CLASS CALayer;
69
OBJC_CLASS WebGLLayer;
70
namespace WebCore {
71
class GraphicsContextGLCVANGLE;
72
}
73
#endif // PLATFORM(COCOA)
74
75
#if USE(NICOSIA)
39
#if USE(NICOSIA)
76
namespace Nicosia {
40
namespace Nicosia {
77
class GCGLLayer;
41
class GCGLLayer;
Lines 80-88 class GCGLLayer; a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec2
80
44
81
namespace WebCore {
45
namespace WebCore {
82
class ExtensionsGL;
46
class ExtensionsGL;
83
#if USE(ANGLE)
47
#if USE(OPENGL_ES)
84
class ExtensionsGLANGLE;
85
#elif USE(OPENGL_ES)
86
class ExtensionsGLOpenGLES;
48
class ExtensionsGLOpenGLES;
87
#elif USE(OPENGL)
49
#elif USE(OPENGL)
88
class ExtensionsGLOpenGL;
50
class ExtensionsGLOpenGL;
Lines 97-146 class TextureMapperGCGLPlatformLayer; a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec3
97
59
98
typedef HashMap<CString, uint64_t> ShaderNameHash;
60
typedef HashMap<CString, uint64_t> ShaderNameHash;
99
61
62
// Base class for GraphicsContextGL contexts that use OpenGL or OpenGL ES.
100
class WEBCORE_EXPORT GraphicsContextGLOpenGL : public GraphicsContextGL
63
class WEBCORE_EXPORT GraphicsContextGLOpenGL : public GraphicsContextGL
101
{
64
{
102
public:
65
public:
103
    virtual ~GraphicsContextGLOpenGL();
66
    virtual ~GraphicsContextGLOpenGL();
104
    PlatformLayer* platformLayer() const override;
105
#if USE(ANGLE)
106
    PlatformGraphicsContextGLDisplay platformDisplay() const;
107
    PlatformGraphicsContextGLConfig platformConfig() const;
108
    GCGLenum drawingBufferTextureTarget();
109
    static GCGLenum drawingBufferTextureTargetQueryForDrawingTarget(GCGLenum drawingTarget);
110
    static GCGLint EGLDrawingBufferTextureTargetForDrawingTarget(GCGLenum drawingTarget);
111
    enum class ReleaseThreadResourceBehavior {
112
        // Releases current context after GraphicsContextGLOpenGL calls done in the thread.
113
        ReleaseCurrentContext,
114
        // Releases all thread resources after GraphicsContextGLOpenGL calls done in the thread.
115
        ReleaseThreadResources,
116
        // Releases all global state. Should be used only after all depending objects have
117
        // been released.
118
        TerminateAndReleaseThreadResources
119
    };
120
    static bool releaseThreadResources(ReleaseThreadResourceBehavior);
121
#endif
122
123
    // With multisampling on, blit from multisampleFBO to regular FBO.
124
    void prepareTexture();
125
126
    // Get an attribute location without checking the name -> mangledname mapping.
127
    int getAttribLocationDirect(PlatformGLObject program, const String& name);
128
129
    // Compile a shader without going through ANGLE.
130
    void compileShaderDirect(PlatformGLObject);
131
132
    // Equivalent to ::glTexImage2D(). Allows pixels==0 with no allocation.
133
    void texImage2DDirect(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, const void* pixels);
134
135
#if !USE(ANGLE)
136
    // Helper to texImage2D with pixel==0 case: pixels are initialized to 0.
137
    // Return true if no GL error is synthesized.
138
    // By default, alignment is 4, the OpenGL default setting.
139
    bool texImage2DResourceSafe(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLint alignment = 4);
67
    bool texImage2DResourceSafe(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLint alignment = 4);
140
#endif
141
68
142
    bool isGLES2Compliant() const final;
69
    bool isGLES2Compliant() const final;
143
144
    //----------------------------------------------------------------------
70
    //----------------------------------------------------------------------
145
    // Entry points for WebGL.
71
    // Entry points for WebGL.
146
    //
72
    //
Lines 206-214 public: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec4
206
    GCGLint64 getInteger64(GCGLenum pname) final;
132
    GCGLint64 getInteger64(GCGLenum pname) final;
207
    GCGLint64 getInteger64i(GCGLenum pname, GCGLuint index) final;
133
    GCGLint64 getInteger64i(GCGLenum pname, GCGLuint index) final;
208
    GCGLint getProgrami(PlatformGLObject program, GCGLenum pname) final;
134
    GCGLint getProgrami(PlatformGLObject program, GCGLenum pname) final;
209
#if !USE(ANGLE)
210
    void getNonBuiltInActiveSymbolCount(PlatformGLObject program, GCGLenum pname, GCGLint* value);
135
    void getNonBuiltInActiveSymbolCount(PlatformGLObject program, GCGLenum pname, GCGLint* value);
211
#endif // !USE(ANGLE)
212
    String getProgramInfoLog(PlatformGLObject) final;
136
    String getProgramInfoLog(PlatformGLObject) final;
213
    String getUnmangledInfoLog(PlatformGLObject[2], GCGLsizei, const String&);
137
    String getUnmangledInfoLog(PlatformGLObject[2], GCGLsizei, const String&);
214
    GCGLint getRenderbufferParameteri(GCGLenum target, GCGLenum pname) final;
138
    GCGLint getRenderbufferParameteri(GCGLenum target, GCGLenum pname) final;
Lines 286-295 public: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec5
286
210
287
    void useProgram(PlatformGLObject) final;
211
    void useProgram(PlatformGLObject) final;
288
    void validateProgram(PlatformGLObject) final;
212
    void validateProgram(PlatformGLObject) final;
289
#if !USE(ANGLE)
290
    bool checkVaryingsPacking(PlatformGLObject vertexShader, PlatformGLObject fragmentShader) const;
213
    bool checkVaryingsPacking(PlatformGLObject vertexShader, PlatformGLObject fragmentShader) const;
291
    bool precisionsMatch(PlatformGLObject vertexShader, PlatformGLObject fragmentShader) const;
214
    bool precisionsMatch(PlatformGLObject vertexShader, PlatformGLObject fragmentShader) const;
292
#endif
293
215
294
    void vertexAttrib1f(GCGLuint index, GCGLfloat x) final;
216
    void vertexAttrib1f(GCGLuint index, GCGLfloat x) final;
295
    void vertexAttrib1fv(GCGLuint index, GCGLSpan<const GCGLfloat, 1> values) final;
217
    void vertexAttrib1fv(GCGLuint index, GCGLSpan<const GCGLfloat, 1> values) final;
Lines 317-326 public: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec6
317
239
318
    // ========== WebGL2 entry points.
240
    // ========== WebGL2 entry points.
319
241
320
#if !USE(ANGLE)
321
    void bufferData(GCGLenum target, const void* data, GCGLenum usage, GCGLuint srcOffset, GCGLuint length);
242
    void bufferData(GCGLenum target, const void* data, GCGLenum usage, GCGLuint srcOffset, GCGLuint length);
322
    void bufferSubData(GCGLenum target, GCGLintptr dstByteOffset, const void* srcData, GCGLuint srcOffset, GCGLuint length);
243
    void bufferSubData(GCGLenum target, GCGLintptr dstByteOffset, const void* srcData, GCGLuint srcOffset, GCGLuint length);
323
#endif
324
    void copyBufferSubData(GCGLenum readTarget, GCGLenum writeTarget, GCGLintptr readOffset, GCGLintptr writeOffset, GCGLsizeiptr size) final;
244
    void copyBufferSubData(GCGLenum readTarget, GCGLenum writeTarget, GCGLintptr readOffset, GCGLintptr writeOffset, GCGLsizeiptr size) final;
325
245
326
    void getBufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<GCGLvoid> data) final;
246
    void getBufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<GCGLvoid> data) final;
Lines 456-464 public: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec7
456
    void primitiveRestartIndex(GCGLuint);
376
    void primitiveRestartIndex(GCGLuint);
457
#endif
377
#endif
458
378
459
#if PLATFORM(COCOA)
460
    void displayWasReconfigured();
461
#endif
462
379
463
    void setContextVisibility(bool) final;
380
    void setContextVisibility(bool) final;
464
381
Lines 484-495 public: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec8
484
    // all methods it contains may necessarily be supported on the
401
    // all methods it contains may necessarily be supported on the
485
    // current hardware. Must call ExtensionsGL::supports() to
402
    // current hardware. Must call ExtensionsGL::supports() to
486
    // determine this.
403
    // determine this.
487
#if !USE(ANGLE)
488
    // Use covariant return type for OPENGL/OPENGL_ES
404
    // Use covariant return type for OPENGL/OPENGL_ES
489
    ExtensionsGLOpenGLCommon& getExtensions() final;
405
    ExtensionsGLOpenGLCommon& getExtensions() final;
490
#else
491
    ExtensionsGL& getExtensions() final;
492
#endif
493
406
494
    void simulateEventForTesting(SimulatedEventForTesting) override;
407
    void simulateEventForTesting(SimulatedEventForTesting) override;
495
408
Lines 497-524 public: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec9
497
410
498
    void prepareForDisplay() override;
411
    void prepareForDisplay() override;
499
412
500
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
501
    GraphicsContextGLCV* asCV() final;
502
#endif
503
504
    static void paintToCanvas(const GraphicsContextGLAttributes&, PixelBuffer&&, const IntSize& canvasSize, GraphicsContext&);
505
506
#if USE(ANGLE)
507
    constexpr static EGLNativeDisplayType defaultDisplay = EGL_DEFAULT_DISPLAY;
508
#if PLATFORM(COCOA)
509
    constexpr static EGLNativeDisplayType lowPowerDisplay = EGL_CAST(EGLNativeDisplayType, -1);
510
    constexpr static EGLNativeDisplayType highPerformanceDisplay = EGL_CAST(EGLNativeDisplayType, -2);
511
#endif
512
#endif
513
514
protected:
413
protected:
515
    GraphicsContextGLOpenGL(GraphicsContextGLAttributes);
414
    GraphicsContextGLOpenGL(GraphicsContextGLAttributes);
516
#if PLATFORM(COCOA)
415
517
    GraphicsContextGLIOSurfaceSwapChain m_swapChain;
518
    EGLDisplay m_displayObj { nullptr };
519
    PlatformGraphicsContextGL m_contextObj { nullptr };
520
    PlatformGraphicsContextGLConfig m_configObj { nullptr };
521
#endif
522
    GCGLuint m_texture { 0 };
416
    GCGLuint m_texture { 0 };
523
417
524
private:
418
private:
Lines 547-570 private: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec10
547
    void resolveMultisamplingIfNecessary(const IntRect& = IntRect());
441
    void resolveMultisamplingIfNecessary(const IntRect& = IntRect());
548
    void attachDepthAndStencilBufferIfNeeded(GCGLuint internalDepthStencilFormat, int width, int height);
442
    void attachDepthAndStencilBufferIfNeeded(GCGLuint internalDepthStencilFormat, int width, int height);
549
443
550
#if USE(ANGLE)
551
    bool reshapeDisplayBufferBacking();
552
#endif
553
#if PLATFORM(COCOA)
554
    bool allocateAndBindDisplayBufferBacking();
555
    bool bindDisplayBufferBacking(std::unique_ptr<IOSurface> backing, void* pbuffer);
556
    static bool makeCurrent(PlatformGraphicsContextGLDisplay, PlatformGraphicsContextGL);
557
    friend class GraphicsContextGLCVANGLE;
558
#endif
559
#if USE(ANGLE)
560
    // Returns false if context should be lost due to timeout.
561
    bool waitAndUpdateOldestFrame() WARN_UNUSED_RETURN;
562
563
    // Platform specific behavior for releaseResources();
564
    static void platformReleaseThreadResources();
565
#endif
566
444
567
#if !USE(ANGLE)
568
    typedef HashMap<String, UniqueRef<sh::ShaderVariable>> ShaderSymbolMap;
445
    typedef HashMap<String, UniqueRef<sh::ShaderVariable>> ShaderSymbolMap;
569
446
570
    struct ShaderSourceEntry {
447
    struct ShaderSourceEntry {
Lines 631-642 private: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec11
631
    std::optional<String> originalSymbolInShaderSourceMap(PlatformGLObject shader, ANGLEShaderSymbolType, const String& name);
508
    std::optional<String> originalSymbolInShaderSourceMap(PlatformGLObject shader, ANGLEShaderSymbolType, const String& name);
632
509
633
    std::unique_ptr<ShaderNameHash> nameHashMapForShaders;
510
    std::unique_ptr<ShaderNameHash> nameHashMapForShaders;
634
#endif // !USE(ANGLE)
635
511
636
#if USE(ANGLE)
512
#if USE(OPENGL_ES)
637
    friend class ExtensionsGLANGLE;
638
    std::unique_ptr<ExtensionsGLANGLE> m_extensions;
639
#elif USE(OPENGL_ES)
640
    friend class ExtensionsGLOpenGLES;
513
    friend class ExtensionsGLOpenGLES;
641
    friend class ExtensionsGLOpenGLCommon;
514
    friend class ExtensionsGLOpenGLCommon;
642
    std::unique_ptr<ExtensionsGLOpenGLES> m_extensions;
515
    std::unique_ptr<ExtensionsGLOpenGLES> m_extensions;
Lines 648-656 private: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec12
648
521
649
    Vector<Vector<float>> m_vertexArray;
522
    Vector<Vector<float>> m_vertexArray;
650
523
651
#if !USE(ANGLE)
652
    ANGLEWebKitBridge m_compiler;
524
    ANGLEWebKitBridge m_compiler;
653
#endif
654
525
655
    GCGLuint m_fbo { 0 };
526
    GCGLuint m_fbo { 0 };
656
#if USE(COORDINATED_GRAPHICS)
527
#if USE(COORDINATED_GRAPHICS)
Lines 658-711 private: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec13
658
    GCGLuint m_intermediateTexture { 0 };
529
    GCGLuint m_intermediateTexture { 0 };
659
#endif
530
#endif
660
531
661
#if !USE(ANGLE) && USE(OPENGL_ES)
532
#if USE(OPENGL_ES)
662
    GCGLuint m_depthBuffer { 0 };
533
    GCGLuint m_depthBuffer { 0 };
663
    GCGLuint m_stencilBuffer { 0 };
534
    GCGLuint m_stencilBuffer { 0 };
664
#endif
535
#endif
665
    GCGLuint m_depthStencilBuffer { 0 };
536
    GCGLuint m_depthStencilBuffer { 0 };
666
537
667
    GCGLuint m_internalColorFormat { 0 };
538
    GCGLuint m_internalColorFormat { 0 };
668
#if USE(ANGLE)
669
    GCGLuint m_internalDepthStencilFormat { 0 };
670
#endif
671
    struct GraphicsContextGLState {
672
        GCGLuint boundReadFBO { 0 };
673
        GCGLuint boundDrawFBO { 0 };
674
        GCGLenum activeTextureUnit { GraphicsContextGL::TEXTURE0 };
675
676
        using BoundTextureMap = HashMap<GCGLenum,
677
            std::pair<GCGLuint, GCGLenum>,
678
            IntHash<GCGLenum>,
679
            WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>,
680
            PairHashTraits<WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>, WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>>
681
        >;
682
        BoundTextureMap boundTextureMap;
683
        GCGLuint currentBoundTexture() const { return boundTexture(activeTextureUnit); }
684
        GCGLuint boundTexture(GCGLenum textureUnit) const
685
        {
686
            auto iterator = boundTextureMap.find(textureUnit);
687
            if (iterator != boundTextureMap.end())
688
                return iterator->value.first;
689
            return 0;
690
        }
691
539
692
        GCGLuint currentBoundTarget() const { return boundTarget(activeTextureUnit); }
693
        GCGLenum boundTarget(GCGLenum textureUnit) const
694
        {
695
            auto iterator = boundTextureMap.find(textureUnit);
696
            if (iterator != boundTextureMap.end())
697
                return iterator->value.second;
698
            return 0;
699
        }
700
701
        void setBoundTexture(GCGLenum textureUnit, GCGLuint texture, GCGLenum target)
702
        {
703
            boundTextureMap.set(textureUnit, std::make_pair(texture, target));
704
        }
705
706
        using TextureSeedCount = HashCountedSet<GCGLuint, IntHash<GCGLuint>, WTF::UnsignedWithZeroKeyHashTraits<GCGLuint>>;
707
        TextureSeedCount textureSeedCount;
708
    };
709
540
710
    GraphicsContextGLState m_state;
541
    GraphicsContextGLState m_state;
711
542
Lines 714-729 private: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec14
714
    GCGLuint m_multisampleDepthStencilBuffer { 0 };
545
    GCGLuint m_multisampleDepthStencilBuffer { 0 };
715
    GCGLuint m_multisampleColorBuffer { 0 };
546
    GCGLuint m_multisampleColorBuffer { 0 };
716
547
717
#if USE(ANGLE)
718
    // For preserveDrawingBuffer:true without multisampling.
719
    GCGLuint m_preserveDrawingBufferTexture { 0 };
720
    // Attaches m_texture when m_preserveDrawingBufferTexture is non-zero.
721
    GCGLuint m_preserveDrawingBufferFBO { 0 };
722
    // Queried at display startup.
723
    EGLint m_drawingBufferTextureTarget { -1 };
724
725
#endif
726
727
    // Errors raised by synthesizeGLError().
548
    // Errors raised by synthesizeGLError().
728
    ListHashSet<GCGLenum> m_syntheticErrors;
549
    ListHashSet<GCGLenum> m_syntheticErrors;
729
550
Lines 744-772 private: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h_sec15
744
#if USE(CAIRO)
565
#if USE(CAIRO)
745
    PlatformGLObject m_vao { 0 };
566
    PlatformGLObject m_vao { 0 };
746
#endif
567
#endif
747
748
#if PLATFORM(COCOA)
749
    // Backing store for the the buffer which is eventually used for display.
750
    // When preserveDrawingBuffer == false, this is the drawing buffer backing store.
751
    // When preserveDrawingBuffer == true, this is blitted to during display prepare.
752
    std::unique_ptr<IOSurface> m_displayBufferBacking;
753
    void* m_displayBufferPbuffer { nullptr };
754
#endif
755
#if PLATFORM(MAC)
756
    bool m_switchesGPUOnDisplayReconfiguration { false };
757
    ScopedHighPerformanceGPURequest m_highPerformanceGPURequest;
758
#endif
759
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
760
    std::unique_ptr<GraphicsContextGLCVANGLE> m_cv;
761
#endif
762
#if USE(ANGLE)
763
    bool m_useFenceSyncForDisplayRateLimit = false;
764
    static constexpr size_t maxPendingFrames = 3;
765
    size_t m_oldestFrameCompletionFence { 0 };
766
    ScopedGLFence m_frameCompletionFences[maxPendingFrames];
767
#endif
768
};
568
};
769
569
770
} // namespace WebCore
570
} // namespace WebCore
771
571
772
#endif // ENABLE(WEBGL)
572
#endif // ENABLE(WEBGL) && !USE(ANGLE)
- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp -2884 lines
Lines 1-2884 a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp_sec1
1
/*
2
 * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Google Inc. All rights reserved.
4
 * Copyright (C) 2012 ChangSeok Oh <shivamidow@gmail.com>
5
 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
17
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
20
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
29
#include "config.h"
30
#include "GraphicsContextGLOpenGL.h"
31
32
#if ENABLE(WEBGL) && !USE(ANGLE)
33
34
#if USE(OPENGL_ES)
35
#include "ExtensionsGLOpenGLES.h"
36
#else
37
#include "ExtensionsGLOpenGL.h"
38
#endif
39
#include "ANGLEWebKitBridge.h"
40
#include "GraphicsContext.h"
41
#include "ImageBuffer.h"
42
#include "IntRect.h"
43
#include "IntSize.h"
44
#include "Logging.h"
45
#include "PixelBuffer.h"
46
#include "TemporaryOpenGLSetting.h"
47
#include "WebGLRenderingContextBase.h"
48
#include <JavaScriptCore/RegularExpression.h>
49
#include <cstring>
50
#include <wtf/HexNumber.h>
51
#include <wtf/MainThread.h>
52
#include <wtf/ThreadSpecific.h>
53
#include <wtf/UniqueArray.h>
54
#include <wtf/Vector.h>
55
#include <wtf/text/CString.h>
56
#include <wtf/text/StringBuilder.h>
57
58
#if USE(LIBEPOXY)
59
#include "EpoxyShims.h"
60
#elif USE(OPENGL_ES)
61
#include "OpenGLESShims.h"
62
#elif PLATFORM(GTK) || PLATFORM(WIN)
63
#include "OpenGLShims.h"
64
#endif
65
66
namespace WebCore {
67
68
static ThreadSpecific<ShaderNameHash*>& getCurrentNameHashMapForShader()
69
{
70
    static std::once_flag onceFlag;
71
    static ThreadSpecific<ShaderNameHash*>* sharedNameHash;
72
    std::call_once(onceFlag, [] {
73
        sharedNameHash = new ThreadSpecific<ShaderNameHash*>;
74
    });
75
76
    return *sharedNameHash;
77
}
78
79
static void setCurrentNameHashMapForShader(ShaderNameHash* shaderNameHash)
80
{
81
    *getCurrentNameHashMapForShader() = shaderNameHash;
82
}
83
84
// Hash function used by the ANGLE translator/compiler to do
85
// symbol name mangling. Since this is a static method, before
86
// calling compileShader we set currentNameHashMapForShader
87
// to point to the map kept by the current instance of GraphicsContextGLOpenGL.
88
89
static uint64_t nameHashForShader(const char* name, size_t length)
90
{
91
    if (!length)
92
        return 0;
93
94
    CString nameAsCString = CString(name);
95
96
    // Look up name in our local map.
97
    ShaderNameHash*& currentNameHashMapForShader = *getCurrentNameHashMapForShader();
98
    ShaderNameHash::iterator findResult = currentNameHashMapForShader->find(nameAsCString);
99
    if (findResult != currentNameHashMapForShader->end())
100
        return findResult->value;
101
102
    unsigned hashValue = nameAsCString.hash();
103
104
    // Convert the 32-bit hash from CString::hash into a 64-bit result
105
    // by shifting then adding the size of our table. Overflow would
106
    // only be a problem if we're already hashing to the same value (and
107
    // we're hoping that over the lifetime of the context we
108
    // don't have that many symbols).
109
110
    uint64_t result = hashValue;
111
    result = (result << 32) + (currentNameHashMapForShader->size() + 1);
112
113
    currentNameHashMapForShader->set(nameAsCString, result);
114
    return result;
115
}
116
117
void GraphicsContextGLOpenGL::validateDepthStencil(const char* packedDepthStencilExtension)
118
{
119
    auto attrs = contextAttributes();
120
121
    ExtensionsGLOpenGLCommon& extensions = getExtensions();
122
    if (attrs.stencil) {
123
        if (extensions.supports(packedDepthStencilExtension)) {
124
            extensions.ensureEnabled(packedDepthStencilExtension);
125
            // Force depth if stencil is true.
126
            attrs.depth = true;
127
        } else
128
            attrs.stencil = false;
129
        setContextAttributes(attrs);
130
    }
131
    if (attrs.antialias && !m_isForWebGL2) {
132
        if (!extensions.supports("GL_ANGLE_framebuffer_multisample")) {
133
            attrs.antialias = false;
134
            setContextAttributes(attrs);
135
        } else
136
            extensions.ensureEnabled("GL_ANGLE_framebuffer_multisample");
137
    }
138
}
139
140
void GraphicsContextGLOpenGL::prepareTexture()
141
{
142
    if (m_layerComposited)
143
        return;
144
145
    if (!makeContextCurrent())
146
        return;
147
148
149
#if !USE(COORDINATED_GRAPHICS)
150
    TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
151
    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
152
#endif
153
154
    if (contextAttributes().antialias)
155
        resolveMultisamplingIfNecessary();
156
157
#if USE(COORDINATED_GRAPHICS)
158
    std::swap(m_texture, m_compositorTexture);
159
    std::swap(m_texture, m_intermediateTexture);
160
    ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
161
    ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);
162
    glFlush();
163
164
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
165
    if (m_state.boundDrawFBO != m_fbo)
166
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
167
    else
168
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
169
    return;
170
#endif
171
172
    ::glActiveTexture(GL_TEXTURE0);
173
    ::glBindTexture(GL_TEXTURE_2D, m_state.boundTarget(GL_TEXTURE0) == GL_TEXTURE_2D ? m_state.boundTexture(GL_TEXTURE0) : 0);
174
    ::glActiveTexture(m_state.activeTextureUnit);
175
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
176
    if (m_state.boundDrawFBO != m_fbo)
177
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
178
    ::glFlush();
179
}
180
181
std::optional<PixelBuffer> GraphicsContextGLOpenGL::readRenderingResults()
182
{
183
    bool mustRestoreFBO = false;
184
    if (contextAttributes().antialias) {
185
        resolveMultisamplingIfNecessary();
186
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
187
        mustRestoreFBO = true;
188
    } else {
189
        ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
190
        if (m_state.boundDrawFBO != m_fbo) {
191
            mustRestoreFBO = true;
192
            ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
193
        }
194
    }
195
    auto result = readPixelsForPaintResults();
196
    if (mustRestoreFBO)
197
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
198
    return result;
199
}
200
201
void GraphicsContextGLOpenGL::reshape(int width, int height)
202
{
203
    if (width == m_currentWidth && height == m_currentHeight)
204
        return;
205
206
    ASSERT(width >= 0 && height >= 0);
207
    if (width < 0 || height < 0)
208
        return;
209
210
    if (!makeContextCurrent())
211
        return;
212
213
    markContextChanged();
214
215
    m_currentWidth = width;
216
    m_currentHeight = height;
217
218
    validateAttributes();
219
220
    TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
221
    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
222
    
223
    bool mustRestoreFBO = reshapeFBOs(IntSize(width, height));
224
225
    // Initialize renderbuffers to 0.
226
    GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0;
227
    GLint clearStencil = 0;
228
    GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE;
229
    GLuint stencilMask = 0xffffffff, stencilMaskBack = 0xffffffff;
230
    GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
231
    ::glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
232
    ::glClearColor(0, 0, 0, 0);
233
    ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
234
    ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
235
236
    auto attrs = contextAttributes();
237
238
    if (attrs.depth) {
239
        ::glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth);
240
        GraphicsContextGLOpenGL::clearDepth(1);
241
        ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
242
        ::glDepthMask(GL_TRUE);
243
        clearMask |= GL_DEPTH_BUFFER_BIT;
244
    }
245
    if (attrs.stencil) {
246
        ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil);
247
        ::glClearStencil(0);
248
        ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask));
249
        ::glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, reinterpret_cast<GLint*>(&stencilMaskBack));
250
        ::glStencilMaskSeparate(GL_FRONT, 0xffffffff);
251
        ::glStencilMaskSeparate(GL_BACK, 0xffffffff);
252
        clearMask |= GL_STENCIL_BUFFER_BIT;
253
    }
254
255
    ::glClear(clearMask);
256
257
    ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
258
    ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
259
    if (attrs.depth) {
260
        GraphicsContextGLOpenGL::clearDepth(clearDepth);
261
        ::glDepthMask(depthMask);
262
    }
263
    if (attrs.stencil) {
264
        ::glClearStencil(clearStencil);
265
        ::glStencilMaskSeparate(GL_FRONT, stencilMask);
266
        ::glStencilMaskSeparate(GL_BACK, stencilMaskBack);
267
    }
268
269
    if (mustRestoreFBO)
270
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_state.boundDrawFBO);
271
272
    auto error = ::glGetError();
273
    if (error != GL_NO_ERROR) {
274
        RELEASE_LOG(WebGL, "Fatal: OpenGL error during GraphicsContextGL buffer initialization (%d).", error);
275
        forceContextLost();
276
        return;
277
    }
278
279
    ::glFlush();
280
}
281
282
bool GraphicsContextGLOpenGL::checkVaryingsPacking(PlatformGLObject vertexShader, PlatformGLObject fragmentShader) const
283
{
284
    ASSERT(m_shaderSourceMap.contains(vertexShader));
285
    ASSERT(m_shaderSourceMap.contains(fragmentShader));
286
    const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value;
287
    const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value;
288
289
    HashMap<String, sh::ShaderVariable> combinedVaryings;
290
    for (const auto& vertexSymbol : vertexEntry.varyingMap) {
291
        const String& symbolName = vertexSymbol.key;
292
        // The varying map includes variables for each index of an array variable.
293
        // We only want a single variable to represent the array.
294
        if (symbolName.endsWith("]"))
295
            continue;
296
297
        // Don't count built in varyings.
298
        if (symbolName == "gl_FragCoord" || symbolName == "gl_FrontFacing" || symbolName == "gl_PointCoord")
299
            continue;
300
301
        const auto& fragmentSymbol = fragmentEntry.varyingMap.find(symbolName);
302
        if (fragmentSymbol != fragmentEntry.varyingMap.end())
303
            combinedVaryings.add(symbolName, fragmentSymbol->value);
304
    }
305
306
    size_t numVaryings = combinedVaryings.size();
307
    if (!numVaryings)
308
        return true;
309
310
    std::vector<sh::ShaderVariable> variables;
311
    variables.reserve(combinedVaryings.size());
312
    for (const auto& varyingSymbol : combinedVaryings.values())
313
        variables.push_back(varyingSymbol);
314
315
    GCGLint maxVaryingVectors = 0;
316
#if USE(OPENGL_ES)
317
    ::glGetIntegerv(MAX_VARYING_VECTORS, &maxVaryingVectors);
318
#else
319
    if (m_isForWebGL2)
320
        ::glGetIntegerv(GL_MAX_VARYING_VECTORS, &maxVaryingVectors);
321
    else {
322
        GCGLint maxVaryingFloats = 0;
323
        ::glGetIntegerv(GL_MAX_VARYING_FLOATS, &maxVaryingFloats);
324
        maxVaryingVectors = maxVaryingFloats / 4;
325
    }
326
#endif
327
    return sh::CheckVariablesWithinPackingLimits(maxVaryingVectors, variables);
328
}
329
330
bool GraphicsContextGLOpenGL::precisionsMatch(PlatformGLObject vertexShader, PlatformGLObject fragmentShader) const
331
{
332
    ASSERT(m_shaderSourceMap.contains(vertexShader));
333
    ASSERT(m_shaderSourceMap.contains(fragmentShader));
334
    const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value;
335
    const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value;
336
337
    HashMap<String, sh::GLenum> vertexSymbolPrecisionMap;
338
339
    for (const auto& entry : vertexEntry.uniformMap) {
340
        const std::string& mappedName = entry.value.get().mappedName;
341
        vertexSymbolPrecisionMap.add(String(mappedName.c_str(), mappedName.length()), entry.value.get().precision);
342
    }
343
344
    for (const auto& entry : fragmentEntry.uniformMap) {
345
        const std::string& mappedName = entry.value.get().mappedName;
346
        const auto& vertexSymbol = vertexSymbolPrecisionMap.find(String(mappedName.c_str(), mappedName.length()));
347
        if (vertexSymbol != vertexSymbolPrecisionMap.end() && vertexSymbol->value != entry.value.get().precision)
348
            return false;
349
    }
350
351
    return true;
352
}
353
354
void GraphicsContextGLOpenGL::activeTexture(GCGLenum texture)
355
{
356
    if (!makeContextCurrent())
357
        return;
358
359
    m_state.activeTextureUnit = texture;
360
    ::glActiveTexture(texture);
361
}
362
363
void GraphicsContextGLOpenGL::attachShader(PlatformGLObject program, PlatformGLObject shader)
364
{
365
    ASSERT(program);
366
    ASSERT(shader);
367
    if (!makeContextCurrent())
368
        return;
369
370
    m_shaderProgramSymbolCountMap.remove(program);
371
    ::glAttachShader(program, shader);
372
}
373
374
void GraphicsContextGLOpenGL::bindAttribLocation(PlatformGLObject program, GCGLuint index, const String& name)
375
{
376
    ASSERT(program);
377
    if (!makeContextCurrent())
378
        return;
379
380
    String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name);
381
    LOG(WebGL, "::bindAttribLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data());
382
    ::glBindAttribLocation(program, index, mappedName.utf8().data());
383
}
384
385
void GraphicsContextGLOpenGL::bindBuffer(GCGLenum target, PlatformGLObject buffer)
386
{
387
    if (!makeContextCurrent())
388
        return;
389
390
    ::glBindBuffer(target, buffer);
391
}
392
393
void GraphicsContextGLOpenGL::bindFramebuffer(GCGLenum target, PlatformGLObject buffer)
394
{
395
    if (!makeContextCurrent())
396
        return;
397
398
    GLuint fbo;
399
    if (buffer)
400
        fbo = buffer;
401
    else
402
        fbo = (contextAttributes().antialias ? m_multisampleFBO : m_fbo);
403
    ASSERT(target == GL_FRAMEBUFFER);
404
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
405
    if (fbo != m_state.boundDrawFBO) {
406
        ::glBindFramebufferEXT(target, fbo);
407
        m_state.boundDrawFBO = m_state.boundReadFBO = fbo;
408
    }
409
}
410
411
void GraphicsContextGLOpenGL::bindRenderbuffer(GCGLenum target, PlatformGLObject renderbuffer)
412
{
413
    if (!makeContextCurrent())
414
        return;
415
416
    ::glBindRenderbufferEXT(target, renderbuffer);
417
}
418
419
420
void GraphicsContextGLOpenGL::bindTexture(GCGLenum target, PlatformGLObject texture)
421
{
422
    if (!makeContextCurrent())
423
        return;
424
425
    m_state.setBoundTexture(m_state.activeTextureUnit, texture, target);
426
    ::glBindTexture(target, texture);
427
}
428
429
void GraphicsContextGLOpenGL::blendColor(GCGLclampf red, GCGLclampf green, GCGLclampf blue, GCGLclampf alpha)
430
{
431
    if (!makeContextCurrent())
432
        return;
433
434
    ::glBlendColor(red, green, blue, alpha);
435
}
436
437
void GraphicsContextGLOpenGL::blendEquation(GCGLenum mode)
438
{
439
    if (!makeContextCurrent())
440
        return;
441
442
    ::glBlendEquation(mode);
443
}
444
445
void GraphicsContextGLOpenGL::blendEquationSeparate(GCGLenum modeRGB, GCGLenum modeAlpha)
446
{
447
    if (!makeContextCurrent())
448
        return;
449
450
    ::glBlendEquationSeparate(modeRGB, modeAlpha);
451
}
452
453
454
void GraphicsContextGLOpenGL::blendFunc(GCGLenum sfactor, GCGLenum dfactor)
455
{
456
    if (!makeContextCurrent())
457
        return;
458
459
    ::glBlendFunc(sfactor, dfactor);
460
}       
461
462
void GraphicsContextGLOpenGL::blendFuncSeparate(GCGLenum srcRGB, GCGLenum dstRGB, GCGLenum srcAlpha, GCGLenum dstAlpha)
463
{
464
    if (!makeContextCurrent())
465
        return;
466
467
    ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
468
}
469
470
void GraphicsContextGLOpenGL::bufferData(GCGLenum target, GCGLsizeiptr size, GCGLenum usage)
471
{
472
    if (!makeContextCurrent())
473
        return;
474
475
    ::glBufferData(target, size, 0, usage);
476
}
477
478
void GraphicsContextGLOpenGL::bufferData(GCGLenum target, GCGLSpan<const void> data, GCGLenum usage)
479
{
480
    if (!makeContextCurrent())
481
        return;
482
483
    ::glBufferData(target, data.bufSize, data.data, usage);
484
}
485
486
void GraphicsContextGLOpenGL::bufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<const GCGLvoid> data)
487
{
488
    if (!makeContextCurrent())
489
        return;
490
491
    ::glBufferSubData(target, offset, data.bufSize, data.data);
492
}
493
494
GCGLenum GraphicsContextGLOpenGL::checkFramebufferStatus(GCGLenum target)
495
{
496
    if (!makeContextCurrent())
497
        return GL_INVALID_OPERATION;
498
499
    return ::glCheckFramebufferStatusEXT(target);
500
}
501
502
void GraphicsContextGLOpenGL::clearColor(GCGLclampf r, GCGLclampf g, GCGLclampf b, GCGLclampf a)
503
{
504
    if (!makeContextCurrent())
505
        return;
506
507
    ::glClearColor(r, g, b, a);
508
}
509
510
void GraphicsContextGLOpenGL::clear(GCGLbitfield mask)
511
{
512
    if (!makeContextCurrent())
513
        return;
514
515
    ::glClear(mask);
516
    checkGPUStatus();
517
}
518
519
void GraphicsContextGLOpenGL::clearStencil(GCGLint s)
520
{
521
    if (!makeContextCurrent())
522
        return;
523
524
    ::glClearStencil(s);
525
}
526
527
void GraphicsContextGLOpenGL::colorMask(GCGLboolean red, GCGLboolean green, GCGLboolean blue, GCGLboolean alpha)
528
{
529
    if (!makeContextCurrent())
530
        return;
531
532
    ::glColorMask(red, green, blue, alpha);
533
}
534
535
void GraphicsContextGLOpenGL::compileShader(PlatformGLObject shader)
536
{
537
    ASSERT(shader);
538
    if (!makeContextCurrent())
539
        return;
540
541
    // Turn on name mapping. Due to the way ANGLE name hashing works, we
542
    // point a global hashmap to the map owned by this context.
543
    ShBuiltInResources ANGLEResources = m_compiler.getResources();
544
    ShHashFunction64 previousHashFunction = ANGLEResources.HashFunction;
545
    ANGLEResources.HashFunction = nameHashForShader;
546
547
    if (!nameHashMapForShaders)
548
        nameHashMapForShaders = makeUnique<ShaderNameHash>();
549
    setCurrentNameHashMapForShader(nameHashMapForShaders.get());
550
    m_compiler.setResources(ANGLEResources);
551
552
    String translatedShaderSource = m_extensions->getTranslatedShaderSourceANGLE(shader);
553
554
    ANGLEResources.HashFunction = previousHashFunction;
555
    m_compiler.setResources(ANGLEResources);
556
    setCurrentNameHashMapForShader(nullptr);
557
558
    if (!translatedShaderSource.length())
559
        return;
560
561
    const CString& translatedShaderCString = translatedShaderSource.utf8();
562
    const char* translatedShaderPtr = translatedShaderCString.data();
563
    int translatedShaderLength = translatedShaderCString.length();
564
565
    LOG(WebGL, "--- begin original shader source ---\n%s\n--- end original shader source ---\n", getShaderSource(shader).utf8().data());
566
    LOG(WebGL, "--- begin translated shader source ---\n%s\n--- end translated shader source ---", translatedShaderPtr);
567
568
    ::glShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength);
569
    
570
    ::glCompileShader(shader);
571
    
572
    int compileStatus;
573
    
574
    ::glGetShaderiv(shader, COMPILE_STATUS, &compileStatus);
575
576
    ShaderSourceMap::iterator result = m_shaderSourceMap.find(shader);
577
    ShaderSourceEntry& entry = result->value;
578
579
    // Populate the shader log
580
    GLint length = 0;
581
    ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
582
583
    if (length) {
584
        GLsizei size = 0;
585
        Vector<GLchar> info(length);
586
        ::glGetShaderInfoLog(shader, length, &size, info.data());
587
588
        PlatformGLObject shaders[2] = { shader, 0 };
589
        entry.log = getUnmangledInfoLog(shaders, 1, String(info.data(), size));
590
    }
591
592
    if (compileStatus != GL_TRUE) {
593
        entry.isValid = false;
594
        LOG(WebGL, "Error: shader translator produced a shader that OpenGL would not compile.");
595
    }
596
}
597
598
void GraphicsContextGLOpenGL::compileShaderDirect(PlatformGLObject shader)
599
{
600
    ASSERT(shader);
601
    if (!makeContextCurrent())
602
        return;
603
604
    HashMap<PlatformGLObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
605
606
    if (result == m_shaderSourceMap.end())
607
        return;
608
609
    ShaderSourceEntry& entry = result->value;
610
611
    const CString& shaderSourceCString = entry.source.utf8();
612
    const char* shaderSourcePtr = shaderSourceCString.data();
613
    int shaderSourceLength = shaderSourceCString.length();
614
615
    LOG(WebGL, "--- begin direct shader source ---\n%s\n--- end direct shader source ---\n", shaderSourcePtr);
616
617
    ::glShaderSource(shader, 1, &shaderSourcePtr, &shaderSourceLength);
618
619
    ::glCompileShader(shader);
620
621
    int compileStatus;
622
623
    ::glGetShaderiv(shader, COMPILE_STATUS, &compileStatus);
624
625
    if (compileStatus == GL_TRUE) {
626
        entry.isValid = true;
627
        LOG(WebGL, "Direct compilation of shader succeeded.");
628
    } else {
629
        entry.isValid = false;
630
        LOG(WebGL, "Error: direct compilation of shader failed.");
631
    }
632
}
633
634
void GraphicsContextGLOpenGL::copyTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLint border)
635
{
636
    if (!makeContextCurrent())
637
        return;
638
639
    auto attrs = contextAttributes();
640
641
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
642
    if (attrs.antialias && m_state.boundDrawFBO == m_multisampleFBO) {
643
        resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
644
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
645
    }
646
    ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
647
    if (attrs.antialias && m_state.boundDrawFBO == m_multisampleFBO)
648
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_multisampleFBO);
649
}
650
651
void GraphicsContextGLOpenGL::copyTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
652
{
653
    if (!makeContextCurrent())
654
        return;
655
656
    auto attrs = contextAttributes();
657
658
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
659
    if (attrs.antialias && m_state.boundDrawFBO == m_multisampleFBO) {
660
        resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
661
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_fbo);
662
    }
663
    ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
664
    if (attrs.antialias && m_state.boundDrawFBO == m_multisampleFBO)
665
        ::glBindFramebufferEXT(GraphicsContextGL::FRAMEBUFFER, m_multisampleFBO);
666
}
667
668
void GraphicsContextGLOpenGL::cullFace(GCGLenum mode)
669
{
670
    if (!makeContextCurrent())
671
        return;
672
673
    ::glCullFace(mode);
674
}
675
676
void GraphicsContextGLOpenGL::depthFunc(GCGLenum func)
677
{
678
    if (!makeContextCurrent())
679
        return;
680
681
    ::glDepthFunc(func);
682
}
683
684
void GraphicsContextGLOpenGL::depthMask(GCGLboolean flag)
685
{
686
    if (!makeContextCurrent())
687
        return;
688
689
    ::glDepthMask(flag);
690
}
691
692
void GraphicsContextGLOpenGL::detachShader(PlatformGLObject program, PlatformGLObject shader)
693
{
694
    ASSERT(program);
695
    ASSERT(shader);
696
    if (!makeContextCurrent())
697
        return;
698
699
    m_shaderProgramSymbolCountMap.remove(program);
700
    ::glDetachShader(program, shader);
701
}
702
703
void GraphicsContextGLOpenGL::disable(GCGLenum cap)
704
{
705
    if (!makeContextCurrent())
706
        return;
707
708
    ::glDisable(cap);
709
}
710
711
void GraphicsContextGLOpenGL::disableVertexAttribArray(GCGLuint index)
712
{
713
    if (!makeContextCurrent())
714
        return;
715
716
    ::glDisableVertexAttribArray(index);
717
}
718
719
void GraphicsContextGLOpenGL::drawArrays(GCGLenum mode, GCGLint first, GCGLsizei count)
720
{
721
    if (!makeContextCurrent())
722
        return;
723
724
    ::glDrawArrays(mode, first, count);
725
    checkGPUStatus();
726
}
727
728
void GraphicsContextGLOpenGL::drawElements(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset)
729
{
730
    if (!makeContextCurrent())
731
        return;
732
733
    ::glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
734
    checkGPUStatus();
735
}
736
737
void GraphicsContextGLOpenGL::enable(GCGLenum cap)
738
{
739
    if (!makeContextCurrent())
740
        return;
741
742
    ::glEnable(cap);
743
}
744
745
void GraphicsContextGLOpenGL::enableVertexAttribArray(GCGLuint index)
746
{
747
    if (!makeContextCurrent())
748
        return;
749
750
    ::glEnableVertexAttribArray(index);
751
}
752
753
void GraphicsContextGLOpenGL::finish()
754
{
755
    if (!makeContextCurrent())
756
        return;
757
758
    ::glFinish();
759
}
760
761
void GraphicsContextGLOpenGL::flush()
762
{
763
    if (!makeContextCurrent())
764
        return;
765
766
    ::glFlush();
767
}
768
769
void GraphicsContextGLOpenGL::framebufferRenderbuffer(GCGLenum target, GCGLenum attachment, GCGLenum renderbuffertarget, PlatformGLObject buffer)
770
{
771
    if (!makeContextCurrent())
772
        return;
773
774
    ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer);
775
}
776
777
void GraphicsContextGLOpenGL::framebufferTexture2D(GCGLenum target, GCGLenum attachment, GCGLenum textarget, PlatformGLObject texture, GCGLint level)
778
{
779
    if (!makeContextCurrent())
780
        return;
781
782
    ::glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
783
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
784
}
785
786
void GraphicsContextGLOpenGL::frontFace(GCGLenum mode)
787
{
788
    if (!makeContextCurrent())
789
        return;
790
791
    ::glFrontFace(mode);
792
}
793
794
void GraphicsContextGLOpenGL::generateMipmap(GCGLenum target)
795
{
796
    if (!makeContextCurrent())
797
        return;
798
799
    ::glGenerateMipmap(target);
800
}
801
802
bool GraphicsContextGLOpenGL::getActiveAttribImpl(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
803
{
804
    if (!program) {
805
        synthesizeGLError(INVALID_VALUE);
806
        return false;
807
    }
808
    if (!makeContextCurrent())
809
        return false;
810
811
    GLint maxAttributeSize = 0;
812
    ::glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize);
813
    Vector<GLchar> name(maxAttributeSize); // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination.
814
    GLsizei nameLength = 0;
815
    GLint size = 0;
816
    GLenum type = 0;
817
    ::glGetActiveAttrib(program, index, maxAttributeSize, &nameLength, &size, &type, name.data());
818
    if (!nameLength)
819
        return false;
820
    
821
    String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, String(name.data(), nameLength));
822
    
823
#ifndef NDEBUG
824
    String uniformName(name.data(), nameLength);
825
    LOG(WebGL, "Program %d is mapping active attribute %d from '%s' to '%s'", program, index, uniformName.utf8().data(), originalName.utf8().data());
826
#endif
827
828
    info.name = originalName;
829
    info.type = type;
830
    info.size = size;
831
    return true;
832
}
833
834
bool GraphicsContextGLOpenGL::getActiveAttrib(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
835
{
836
    GCGLint symbolCount;
837
    auto result = m_shaderProgramSymbolCountMap.find(program);
838
    if (result == m_shaderProgramSymbolCountMap.end()) {
839
        getNonBuiltInActiveSymbolCount(program, GraphicsContextGL::ACTIVE_ATTRIBUTES, &symbolCount);
840
        result = m_shaderProgramSymbolCountMap.find(program);
841
    }
842
    
843
    ActiveShaderSymbolCounts& symbolCounts = result->value;
844
    GCGLuint rawIndex = (index < symbolCounts.filteredToActualAttributeIndexMap.size()) ? symbolCounts.filteredToActualAttributeIndexMap[index] : -1;
845
846
    return getActiveAttribImpl(program, rawIndex, info);
847
}
848
849
bool GraphicsContextGLOpenGL::getActiveUniformImpl(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
850
{
851
    if (!program) {
852
        synthesizeGLError(INVALID_VALUE);
853
        return false;
854
    }
855
856
    if (!makeContextCurrent())
857
        return false;
858
859
    GLint maxUniformSize = 0;
860
    ::glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize);
861
862
    Vector<GLchar> name(maxUniformSize); // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination.
863
    GLsizei nameLength = 0;
864
    GLint size = 0;
865
    GLenum type = 0;
866
    ::glGetActiveUniform(program, index, maxUniformSize, &nameLength, &size, &type, name.data());
867
    if (!nameLength)
868
        return false;
869
    
870
    String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, String(name.data(), nameLength));
871
    
872
#ifndef NDEBUG
873
    String uniformName(name.data(), nameLength);
874
    LOG(WebGL, "Program %d is mapping active uniform %d from '%s' to '%s'", program, index, uniformName.utf8().data(), originalName.utf8().data());
875
#endif
876
    
877
    info.name = originalName;
878
    info.type = type;
879
    info.size = size;
880
    return true;
881
}
882
883
bool GraphicsContextGLOpenGL::getActiveUniform(PlatformGLObject program, GCGLuint index, ActiveInfo& info)
884
{
885
    GCGLint symbolCount;
886
    auto result = m_shaderProgramSymbolCountMap.find(program);
887
    if (result == m_shaderProgramSymbolCountMap.end()) {
888
        getNonBuiltInActiveSymbolCount(program, GraphicsContextGL::ACTIVE_UNIFORMS, &symbolCount);
889
        result = m_shaderProgramSymbolCountMap.find(program);
890
    }
891
    
892
    ActiveShaderSymbolCounts& symbolCounts = result->value;
893
    GCGLuint rawIndex = (index < symbolCounts.filteredToActualUniformIndexMap.size()) ? symbolCounts.filteredToActualUniformIndexMap[index] : -1;
894
    
895
    return getActiveUniformImpl(program, rawIndex, info);
896
}
897
898
void GraphicsContextGLOpenGL::getAttachedShaders(PlatformGLObject program, GCGLsizei maxCount, GCGLsizei* count, PlatformGLObject* shaders)
899
{
900
    if (!program) {
901
        synthesizeGLError(INVALID_VALUE);
902
        return;
903
    }
904
    if (!makeContextCurrent())
905
        return;
906
907
    ::glGetAttachedShaders(program, maxCount, count, shaders);
908
}
909
910
static String generateHashedName(const String& name)
911
{
912
    if (name.isEmpty())
913
        return name;
914
    uint64_t number = nameHashForShader(name.utf8().data(), name.length());
915
    return makeString("webgl_", hex(number, Lowercase));
916
}
917
918
std::optional<String> GraphicsContextGLOpenGL::mappedSymbolInShaderSourceMap(PlatformGLObject shader, ANGLEShaderSymbolType symbolType, const String& name)
919
{
920
    auto result = m_shaderSourceMap.find(shader);
921
    if (result == m_shaderSourceMap.end())
922
        return std::nullopt;
923
924
    const auto& symbolMap = result->value.symbolMap(symbolType);
925
    auto symbolEntry = symbolMap.find(name);
926
    if (symbolEntry == symbolMap.end())
927
        return std::nullopt;
928
929
    auto& mappedName = symbolEntry->value.get().mappedName;
930
    return String(mappedName.c_str(), mappedName.length());
931
}
932
933
String GraphicsContextGLOpenGL::mappedSymbolName(PlatformGLObject program, ANGLEShaderSymbolType symbolType, const String& name)
934
{
935
    GCGLsizei count = 0;
936
    PlatformGLObject shaders[2] = { };
937
    getAttachedShaders(program, 2, &count, shaders);
938
939
    for (GCGLsizei i = 0; i < count; ++i) {
940
        auto mappedName = mappedSymbolInShaderSourceMap(shaders[i], symbolType, name);
941
        if (mappedName)
942
            return mappedName.value();
943
    }
944
945
    // We might have detached or deleted the shaders after linking.
946
    auto result = m_linkedShaderMap.find(program);
947
    if (result != m_linkedShaderMap.end()) {
948
        auto linkedShaders = result->value;
949
        auto mappedName = mappedSymbolInShaderSourceMap(linkedShaders.first, symbolType, name);
950
        if (mappedName)
951
            return mappedName.value();
952
        mappedName = mappedSymbolInShaderSourceMap(linkedShaders.second, symbolType, name);
953
        if (mappedName)
954
            return mappedName.value();
955
    }
956
957
    if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE && !name.isEmpty()) {
958
        // Attributes are a special case: they may be requested before any shaders have been compiled,
959
        // and aren't even required to be used in any shader program.
960
        if (!nameHashMapForShaders)
961
            nameHashMapForShaders = makeUnique<ShaderNameHash>();
962
        setCurrentNameHashMapForShader(nameHashMapForShaders.get());
963
964
        auto generatedName = generateHashedName(name);
965
966
        setCurrentNameHashMapForShader(nullptr);
967
968
        m_possiblyUnusedAttributeMap.set(generatedName, name);
969
970
        return generatedName;
971
    }
972
973
    return name;
974
}
975
976
std::optional<String> GraphicsContextGLOpenGL::originalSymbolInShaderSourceMap(PlatformGLObject shader, ANGLEShaderSymbolType symbolType, const String& name)
977
{
978
    auto result = m_shaderSourceMap.find(shader);
979
    if (result == m_shaderSourceMap.end())
980
        return std::nullopt;
981
982
    const auto& symbolMap = result->value.symbolMap(symbolType);
983
    for (const auto& symbolEntry : symbolMap) {
984
        if (name == symbolEntry.value.get().mappedName.c_str())
985
            return symbolEntry.key;
986
    }
987
    return std::nullopt;
988
}
989
990
String GraphicsContextGLOpenGL::originalSymbolName(PlatformGLObject program, ANGLEShaderSymbolType symbolType, const String& name)
991
{
992
    GCGLsizei count;
993
    PlatformGLObject shaders[2];
994
    getAttachedShaders(program, 2, &count, shaders);
995
    
996
    for (GCGLsizei i = 0; i < count; ++i) {
997
        auto originalName = originalSymbolInShaderSourceMap(shaders[i], symbolType, name);
998
        if (originalName)
999
            return originalName.value();
1000
    }
1001
1002
    // We might have detached or deleted the shaders after linking.
1003
    auto result = m_linkedShaderMap.find(program);
1004
    if (result != m_linkedShaderMap.end()) {
1005
        auto linkedShaders = result->value;
1006
        auto originalName = originalSymbolInShaderSourceMap(linkedShaders.first, symbolType, name);
1007
        if (originalName)
1008
            return originalName.value();
1009
        originalName = originalSymbolInShaderSourceMap(linkedShaders.second, symbolType, name);
1010
        if (originalName)
1011
            return originalName.value();
1012
    }
1013
1014
    if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE && !name.isEmpty()) {
1015
        // Attributes are a special case: they may be requested before any shaders have been compiled,
1016
        // and aren't even required to be used in any shader program.
1017
1018
        const auto& cached = m_possiblyUnusedAttributeMap.find(name);
1019
        if (cached != m_possiblyUnusedAttributeMap.end())
1020
            return cached->value;
1021
    }
1022
1023
    return name;
1024
}
1025
1026
String GraphicsContextGLOpenGL::mappedSymbolName(PlatformGLObject shaders[2], size_t count, const String& name)
1027
{
1028
    for (size_t symbolType = 0; symbolType <= static_cast<size_t>(SHADER_SYMBOL_TYPE_VARYING); ++symbolType) {
1029
        for (size_t i = 0; i < count; ++i) {
1030
            ShaderSourceMap::iterator result = m_shaderSourceMap.find(shaders[i]);
1031
            if (result == m_shaderSourceMap.end())
1032
                continue;
1033
            
1034
            const ShaderSymbolMap& symbolMap = result->value.symbolMap(static_cast<enum ANGLEShaderSymbolType>(symbolType));
1035
            for (const auto& symbolEntry : symbolMap) {
1036
                if (name == symbolEntry.value.get().mappedName.c_str())
1037
                    return symbolEntry.key;
1038
            }
1039
        }
1040
    }
1041
    return name;
1042
}
1043
1044
int GraphicsContextGLOpenGL::getAttribLocation(PlatformGLObject program, const String& name)
1045
{
1046
    if (!program)
1047
        return -1;
1048
1049
    if (!makeContextCurrent())
1050
        return -1;
1051
1052
1053
    String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name);
1054
    LOG(WebGL, "::glGetAttribLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data());
1055
    return ::glGetAttribLocation(program, mappedName.utf8().data());
1056
}
1057
1058
int GraphicsContextGLOpenGL::getAttribLocationDirect(PlatformGLObject program, const String& name)
1059
{
1060
    if (!program)
1061
        return -1;
1062
1063
    if (!makeContextCurrent())
1064
        return -1;
1065
1066
1067
    return ::glGetAttribLocation(program, name.utf8().data());
1068
}
1069
1070
bool GraphicsContextGLOpenGL::moveErrorsToSyntheticErrorList()
1071
{
1072
    if (!makeContextCurrent())
1073
        return false;
1074
1075
    bool movedAnError = false;
1076
1077
    // Set an arbitrary limit of 100 here to avoid creating a hang if
1078
    // a problem driver has a bug that causes it to never clear the error.
1079
    // Otherwise, we would just loop until we got NO_ERROR.
1080
    for (unsigned i = 0; i < 100; ++i) {
1081
        GCGLenum error = glGetError();
1082
        if (error == NO_ERROR)
1083
            break;
1084
        m_syntheticErrors.add(error);
1085
        movedAnError = true;
1086
    }
1087
1088
    return movedAnError;
1089
}
1090
1091
GCGLenum GraphicsContextGLOpenGL::getError()
1092
{
1093
    if (!m_syntheticErrors.isEmpty()) {
1094
        // Need to move the current errors to the synthetic error list in case
1095
        // that error is already there, since the expected behavior of both
1096
        // glGetError and getError is to only report each error code once.
1097
        moveErrorsToSyntheticErrorList();
1098
        return m_syntheticErrors.takeFirst();
1099
    }
1100
1101
    if (!makeContextCurrent())
1102
        return GL_INVALID_OPERATION;
1103
1104
    return ::glGetError();
1105
}
1106
1107
String GraphicsContextGLOpenGL::getString(GCGLenum name)
1108
{
1109
    if (!makeContextCurrent())
1110
        return String();
1111
1112
    return String(reinterpret_cast<const char*>(::glGetString(name)));
1113
}
1114
1115
void GraphicsContextGLOpenGL::hint(GCGLenum target, GCGLenum mode)
1116
{
1117
    if (!makeContextCurrent())
1118
        return;
1119
1120
    ::glHint(target, mode);
1121
}
1122
1123
GCGLboolean GraphicsContextGLOpenGL::isBuffer(PlatformGLObject buffer)
1124
{
1125
    if (!buffer)
1126
        return GL_FALSE;
1127
1128
    if (!makeContextCurrent())
1129
        return GL_FALSE;
1130
1131
    return ::glIsBuffer(buffer);
1132
}
1133
1134
GCGLboolean GraphicsContextGLOpenGL::isEnabled(GCGLenum cap)
1135
{
1136
    if (!makeContextCurrent())
1137
        return GL_FALSE;
1138
1139
    return ::glIsEnabled(cap);
1140
}
1141
1142
GCGLboolean GraphicsContextGLOpenGL::isFramebuffer(PlatformGLObject framebuffer)
1143
{
1144
    if (!framebuffer)
1145
        return GL_FALSE;
1146
1147
    if (!makeContextCurrent())
1148
        return GL_FALSE;
1149
1150
    return ::glIsFramebufferEXT(framebuffer);
1151
}
1152
1153
GCGLboolean GraphicsContextGLOpenGL::isProgram(PlatformGLObject program)
1154
{
1155
    if (!program)
1156
        return GL_FALSE;
1157
1158
    if (!makeContextCurrent())
1159
        return GL_FALSE;
1160
1161
    return ::glIsProgram(program);
1162
}
1163
1164
GCGLboolean GraphicsContextGLOpenGL::isRenderbuffer(PlatformGLObject renderbuffer)
1165
{
1166
    if (!renderbuffer)
1167
        return GL_FALSE;
1168
1169
    if (!makeContextCurrent())
1170
        return GL_FALSE;
1171
1172
    return ::glIsRenderbufferEXT(renderbuffer);
1173
}
1174
1175
GCGLboolean GraphicsContextGLOpenGL::isShader(PlatformGLObject shader)
1176
{
1177
    if (!shader)
1178
        return GL_FALSE;
1179
1180
    if (!makeContextCurrent())
1181
        return GL_FALSE;
1182
1183
    return ::glIsShader(shader);
1184
}
1185
1186
GCGLboolean GraphicsContextGLOpenGL::isTexture(PlatformGLObject texture)
1187
{
1188
    if (!texture)
1189
        return GL_FALSE;
1190
1191
    if (!makeContextCurrent())
1192
        return GL_FALSE;
1193
1194
    return ::glIsTexture(texture);
1195
}
1196
1197
void GraphicsContextGLOpenGL::lineWidth(GCGLfloat width)
1198
{
1199
    if (!makeContextCurrent())
1200
        return;
1201
1202
    ::glLineWidth(width);
1203
}
1204
1205
void GraphicsContextGLOpenGL::linkProgram(PlatformGLObject program)
1206
{
1207
    ASSERT(program);
1208
    if (!makeContextCurrent())
1209
        return;
1210
1211
1212
    GCGLsizei count = 0;
1213
    PlatformGLObject shaders[2] = { };
1214
    getAttachedShaders(program, 2, &count, shaders);
1215
1216
    if (count == 2)
1217
        m_linkedShaderMap.set(program, std::make_pair(shaders[0], shaders[1]));
1218
1219
    ::glLinkProgram(program);
1220
}
1221
1222
void GraphicsContextGLOpenGL::pixelStorei(GCGLenum pname, GCGLint param)
1223
{
1224
    if (!makeContextCurrent())
1225
        return;
1226
1227
    ::glPixelStorei(pname, param);
1228
}
1229
1230
void GraphicsContextGLOpenGL::polygonOffset(GCGLfloat factor, GCGLfloat units)
1231
{
1232
    if (!makeContextCurrent())
1233
        return;
1234
1235
    ::glPolygonOffset(factor, units);
1236
}
1237
1238
void GraphicsContextGLOpenGL::sampleCoverage(GCGLclampf value, GCGLboolean invert)
1239
{
1240
    if (!makeContextCurrent())
1241
        return;
1242
1243
    ::glSampleCoverage(value, invert);
1244
}
1245
1246
void GraphicsContextGLOpenGL::scissor(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1247
{
1248
    if (!makeContextCurrent())
1249
        return;
1250
1251
    ::glScissor(x, y, width, height);
1252
}
1253
1254
void GraphicsContextGLOpenGL::shaderSource(PlatformGLObject shader, const String& string)
1255
{
1256
    ASSERT(shader);
1257
1258
    if (!makeContextCurrent())
1259
        return;
1260
1261
1262
    ShaderSourceEntry entry;
1263
1264
    entry.source = string;
1265
1266
    m_shaderSourceMap.set(shader, WTFMove(entry));
1267
}
1268
1269
void GraphicsContextGLOpenGL::stencilFunc(GCGLenum func, GCGLint ref, GCGLuint mask)
1270
{
1271
    if (!makeContextCurrent())
1272
        return;
1273
1274
    ::glStencilFunc(func, ref, mask);
1275
}
1276
1277
void GraphicsContextGLOpenGL::stencilFuncSeparate(GCGLenum face, GCGLenum func, GCGLint ref, GCGLuint mask)
1278
{
1279
    if (!makeContextCurrent())
1280
        return;
1281
1282
    ::glStencilFuncSeparate(face, func, ref, mask);
1283
}
1284
1285
void GraphicsContextGLOpenGL::stencilMask(GCGLuint mask)
1286
{
1287
    if (!makeContextCurrent())
1288
        return;
1289
1290
    ::glStencilMask(mask);
1291
}
1292
1293
void GraphicsContextGLOpenGL::stencilMaskSeparate(GCGLenum face, GCGLuint mask)
1294
{
1295
    if (!makeContextCurrent())
1296
        return;
1297
1298
    ::glStencilMaskSeparate(face, mask);
1299
}
1300
1301
void GraphicsContextGLOpenGL::stencilOp(GCGLenum fail, GCGLenum zfail, GCGLenum zpass)
1302
{
1303
    if (!makeContextCurrent())
1304
        return;
1305
1306
    ::glStencilOp(fail, zfail, zpass);
1307
}
1308
1309
void GraphicsContextGLOpenGL::stencilOpSeparate(GCGLenum face, GCGLenum fail, GCGLenum zfail, GCGLenum zpass)
1310
{
1311
    if (!makeContextCurrent())
1312
        return;
1313
1314
    ::glStencilOpSeparate(face, fail, zfail, zpass);
1315
}
1316
1317
void GraphicsContextGLOpenGL::texParameterf(GCGLenum target, GCGLenum pname, GCGLfloat value)
1318
{
1319
    if (!makeContextCurrent())
1320
        return;
1321
1322
    ::glTexParameterf(target, pname, value);
1323
}
1324
1325
void GraphicsContextGLOpenGL::texParameteri(GCGLenum target, GCGLenum pname, GCGLint value)
1326
{
1327
    if (!makeContextCurrent())
1328
        return;
1329
1330
    ::glTexParameteri(target, pname, value);
1331
}
1332
1333
void GraphicsContextGLOpenGL::uniform1f(GCGLint location, GCGLfloat v0)
1334
{
1335
    if (!makeContextCurrent())
1336
        return;
1337
1338
    ::glUniform1f(location, v0);
1339
}
1340
1341
void GraphicsContextGLOpenGL::uniform1fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1342
{
1343
    if (!makeContextCurrent())
1344
        return;
1345
1346
    ::glUniform1fv(location, array.bufSize, array.data);
1347
}
1348
1349
void GraphicsContextGLOpenGL::uniform2f(GCGLint location, GCGLfloat v0, GCGLfloat v1)
1350
{
1351
    if (!makeContextCurrent())
1352
        return;
1353
1354
    ::glUniform2f(location, v0, v1);
1355
}
1356
1357
void GraphicsContextGLOpenGL::uniform2fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1358
{
1359
    ASSERT(!(array.bufSize % 2));
1360
    if (!makeContextCurrent())
1361
        return;
1362
1363
    ::glUniform2fv(location, array.bufSize / 2, array.data);
1364
}
1365
1366
void GraphicsContextGLOpenGL::uniform3f(GCGLint location, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2)
1367
{
1368
    if (!makeContextCurrent())
1369
        return;
1370
1371
    ::glUniform3f(location, v0, v1, v2);
1372
}
1373
1374
void GraphicsContextGLOpenGL::uniform3fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1375
{
1376
    ASSERT(!(array.bufSize % 3));
1377
    if (!makeContextCurrent())
1378
        return;
1379
1380
    ::glUniform3fv(location, array.bufSize / 3, array.data);
1381
}
1382
1383
void GraphicsContextGLOpenGL::uniform4f(GCGLint location, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2, GCGLfloat v3)
1384
{
1385
    if (!makeContextCurrent())
1386
        return;
1387
1388
    ::glUniform4f(location, v0, v1, v2, v3);
1389
}
1390
1391
void GraphicsContextGLOpenGL::uniform4fv(GCGLint location, GCGLSpan<const GCGLfloat> array)
1392
{
1393
    ASSERT(!(array.bufSize % 4));
1394
    if (!makeContextCurrent())
1395
        return;
1396
1397
    ::glUniform4fv(location, array.bufSize / 4, array.data);
1398
}
1399
1400
void GraphicsContextGLOpenGL::uniform1i(GCGLint location, GCGLint v0)
1401
{
1402
    if (!makeContextCurrent())
1403
        return;
1404
1405
    ::glUniform1i(location, v0);
1406
}
1407
1408
void GraphicsContextGLOpenGL::uniform1iv(GCGLint location, GCGLSpan<const GCGLint> array)
1409
{
1410
    if (!makeContextCurrent())
1411
        return;
1412
1413
    ::glUniform1iv(location, array.bufSize, array.data);
1414
}
1415
1416
void GraphicsContextGLOpenGL::uniform2i(GCGLint location, GCGLint v0, GCGLint v1)
1417
{
1418
    if (!makeContextCurrent())
1419
        return;
1420
1421
    ::glUniform2i(location, v0, v1);
1422
}
1423
1424
void GraphicsContextGLOpenGL::uniform2iv(GCGLint location, GCGLSpan<const GCGLint> array)
1425
{
1426
    ASSERT(!(array.bufSize % 2));
1427
    if (!makeContextCurrent())
1428
        return;
1429
1430
    ::glUniform2iv(location, array.bufSize / 2, array.data);
1431
}
1432
1433
void GraphicsContextGLOpenGL::uniform3i(GCGLint location, GCGLint v0, GCGLint v1, GCGLint v2)
1434
{
1435
    if (!makeContextCurrent())
1436
        return;
1437
1438
    ::glUniform3i(location, v0, v1, v2);
1439
}
1440
1441
void GraphicsContextGLOpenGL::uniform3iv(GCGLint location, GCGLSpan<const GCGLint> array)
1442
{
1443
    ASSERT(!(array.bufSize % 3));
1444
    if (!makeContextCurrent())
1445
        return;
1446
1447
    ::glUniform3iv(location, array.bufSize / 3, array.data);
1448
}
1449
1450
void GraphicsContextGLOpenGL::uniform4i(GCGLint location, GCGLint v0, GCGLint v1, GCGLint v2, GCGLint v3)
1451
{
1452
    if (!makeContextCurrent())
1453
        return;
1454
1455
    ::glUniform4i(location, v0, v1, v2, v3);
1456
}
1457
1458
void GraphicsContextGLOpenGL::uniform4iv(GCGLint location, GCGLSpan<const GCGLint> array)
1459
{
1460
    ASSERT(!(array.bufSize % 4));
1461
    if (!makeContextCurrent())
1462
        return;
1463
1464
    ::glUniform4iv(location, array.bufSize / 4, array.data);
1465
}
1466
1467
void GraphicsContextGLOpenGL::uniformMatrix2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1468
{
1469
    ASSERT(!(array.bufSize % 4));
1470
    if (!makeContextCurrent())
1471
        return;
1472
1473
    ::glUniformMatrix2fv(location, array.bufSize / 4, transpose, array.data);
1474
}
1475
1476
void GraphicsContextGLOpenGL::uniformMatrix3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1477
{
1478
    ASSERT(!(array.bufSize % 9));
1479
    if (!makeContextCurrent())
1480
        return;
1481
1482
    ::glUniformMatrix3fv(location, array.bufSize / 9, transpose, array.data);
1483
}
1484
1485
void GraphicsContextGLOpenGL::uniformMatrix4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> array)
1486
{
1487
    ASSERT(!(array.bufSize % 16));
1488
    if (!makeContextCurrent())
1489
        return;
1490
1491
    ::glUniformMatrix4fv(location, array.bufSize / 16, transpose, array.data);
1492
}
1493
1494
void GraphicsContextGLOpenGL::useProgram(PlatformGLObject program)
1495
{
1496
    if (!makeContextCurrent())
1497
        return;
1498
1499
    ::glUseProgram(program);
1500
}
1501
1502
void GraphicsContextGLOpenGL::validateProgram(PlatformGLObject program)
1503
{
1504
    ASSERT(program);
1505
1506
    if (!makeContextCurrent())
1507
        return;
1508
1509
    ::glValidateProgram(program);
1510
}
1511
1512
void GraphicsContextGLOpenGL::vertexAttrib1f(GCGLuint index, GCGLfloat v0)
1513
{
1514
    if (!makeContextCurrent())
1515
        return;
1516
1517
    ::glVertexAttrib1f(index, v0);
1518
}
1519
1520
void GraphicsContextGLOpenGL::vertexAttrib1fv(GCGLuint index, GCGLSpan<const GCGLfloat, 1> array)
1521
{
1522
    if (!makeContextCurrent())
1523
        return;
1524
1525
    ::glVertexAttrib1fv(index, array.data);
1526
}
1527
1528
void GraphicsContextGLOpenGL::vertexAttrib2f(GCGLuint index, GCGLfloat v0, GCGLfloat v1)
1529
{
1530
    if (!makeContextCurrent())
1531
        return;
1532
1533
    ::glVertexAttrib2f(index, v0, v1);
1534
}
1535
1536
void GraphicsContextGLOpenGL::vertexAttrib2fv(GCGLuint index, GCGLSpan<const GCGLfloat, 2> array)
1537
{
1538
    if (!makeContextCurrent())
1539
        return;
1540
1541
    ::glVertexAttrib2fv(index, array.data);
1542
}
1543
1544
void GraphicsContextGLOpenGL::vertexAttrib3f(GCGLuint index, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2)
1545
{
1546
    if (!makeContextCurrent())
1547
        return;
1548
1549
    ::glVertexAttrib3f(index, v0, v1, v2);
1550
}
1551
1552
void GraphicsContextGLOpenGL::vertexAttrib3fv(GCGLuint index, GCGLSpan<const GCGLfloat, 3> array)
1553
{
1554
    if (!makeContextCurrent())
1555
        return;
1556
1557
    ::glVertexAttrib3fv(index, array.data);
1558
}
1559
1560
void GraphicsContextGLOpenGL::vertexAttrib4f(GCGLuint index, GCGLfloat v0, GCGLfloat v1, GCGLfloat v2, GCGLfloat v3)
1561
{
1562
    if (!makeContextCurrent())
1563
        return;
1564
1565
    ::glVertexAttrib4f(index, v0, v1, v2, v3);
1566
}
1567
1568
void GraphicsContextGLOpenGL::vertexAttrib4fv(GCGLuint index, GCGLSpan<const GCGLfloat, 4> array)
1569
{
1570
    if (!makeContextCurrent())
1571
        return;
1572
1573
    ::glVertexAttrib4fv(index, array.data);
1574
}
1575
1576
void GraphicsContextGLOpenGL::vertexAttribPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLboolean normalized, GCGLsizei stride, GCGLintptr offset)
1577
{
1578
    if (!makeContextCurrent())
1579
        return;
1580
1581
    ::glVertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
1582
}
1583
1584
void GraphicsContextGLOpenGL::viewport(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
1585
{
1586
    if (!makeContextCurrent())
1587
        return;
1588
1589
    ::glViewport(x, y, width, height);
1590
}
1591
1592
PlatformGLObject GraphicsContextGLOpenGL::createVertexArray()
1593
{
1594
    return getExtensions().createVertexArrayOES();
1595
}
1596
1597
void GraphicsContextGLOpenGL::deleteVertexArray(PlatformGLObject array)
1598
{
1599
    getExtensions().deleteVertexArrayOES(array);
1600
}
1601
1602
GCGLboolean GraphicsContextGLOpenGL::isVertexArray(PlatformGLObject array)
1603
{
1604
    return getExtensions().isVertexArrayOES(array);
1605
}
1606
1607
void GraphicsContextGLOpenGL::bindVertexArray(PlatformGLObject array)
1608
{
1609
    getExtensions().bindVertexArrayOES(array);
1610
}
1611
1612
void GraphicsContextGLOpenGL::getBooleanv(GCGLenum pname, GCGLSpan<GCGLboolean> value)
1613
{
1614
    if (!makeContextCurrent())
1615
        return;
1616
1617
    ::glGetBooleanv(pname, value.data);
1618
}
1619
1620
GCGLint GraphicsContextGLOpenGL::getBufferParameteri(GCGLenum target, GCGLenum pname)
1621
{
1622
    GCGLint value = 0;
1623
    if (!makeContextCurrent())
1624
        return value;
1625
1626
    ::glGetBufferParameteriv(target, pname, &value);
1627
    return value;
1628
}
1629
1630
void GraphicsContextGLOpenGL::getFloatv(GCGLenum pname, GCGLSpan<GCGLfloat> value)
1631
{
1632
    if (!makeContextCurrent())
1633
        return;
1634
1635
    ::glGetFloatv(pname, value.data);
1636
}
1637
1638
GCGLint64 GraphicsContextGLOpenGL::getInteger64(GCGLenum pname)
1639
{
1640
    UNUSED_PARAM(pname);
1641
    if (!makeContextCurrent())
1642
        return 0;
1643
1644
    GCGLint64 value = 0;
1645
    // FIXME 141178: Before enabling this we must first switch over to using gl3.h and creating and initialing the WebGL2 context using OpenGL ES 3.0.
1646
    // ::glGetInteger64v(pname, value);
1647
    return value;
1648
}
1649
1650
GCGLint64 GraphicsContextGLOpenGL::getInteger64i(GCGLenum pname, GCGLuint index)
1651
{
1652
    UNUSED_PARAM(pname);
1653
    UNUSED_PARAM(index);
1654
    if (!makeContextCurrent())
1655
        return 0;
1656
1657
    GCGLint64 value = 0;
1658
    // FIXME 141178: Before enabling this we must first switch over to using gl3.h and creating and initialing the WebGL2 context using OpenGL ES 3.0.
1659
    // ::glGetInteger64i_v(pname, index, value);
1660
    return value;
1661
}
1662
1663
GCGLint GraphicsContextGLOpenGL::getFramebufferAttachmentParameteri(GCGLenum target, GCGLenum attachment, GCGLenum pname)
1664
{
1665
    GCGLint value = 0;
1666
    if (!makeContextCurrent())
1667
        return 0;
1668
    if (attachment == DEPTH_STENCIL_ATTACHMENT)
1669
        attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works.
1670
    ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, &value);
1671
    return value;
1672
}
1673
1674
GCGLint GraphicsContextGLOpenGL::getProgrami(PlatformGLObject program, GCGLenum pname)
1675
{
1676
    if (!makeContextCurrent())
1677
        return 0;
1678
    GCGLint value = 0;
1679
    ::glGetProgramiv(program, pname, &value);
1680
    return value;
1681
}
1682
1683
void GraphicsContextGLOpenGL::getNonBuiltInActiveSymbolCount(PlatformGLObject program, GCGLenum pname, GCGLint* value)
1684
{
1685
    ASSERT(ACTIVE_ATTRIBUTES == pname || ACTIVE_UNIFORMS == pname);
1686
    if (!value)
1687
        return;
1688
1689
    if (!makeContextCurrent())
1690
        return;
1691
1692
    const auto& result = m_shaderProgramSymbolCountMap.find(program);
1693
    if (result != m_shaderProgramSymbolCountMap.end()) {
1694
        *value = result->value.countForType(pname);
1695
        return;
1696
    }
1697
1698
    m_shaderProgramSymbolCountMap.set(program, ActiveShaderSymbolCounts());
1699
    ActiveShaderSymbolCounts& symbolCounts = m_shaderProgramSymbolCountMap.find(program)->value;
1700
1701
    // Retrieve the active attributes, build a filtered count, and a mapping of
1702
    // our internal attributes indexes to the real unfiltered indexes inside OpenGL.
1703
    GCGLint attributeCount = 0;
1704
    ::glGetProgramiv(program, ACTIVE_ATTRIBUTES, &attributeCount);
1705
    for (GCGLint i = 0; i < attributeCount; ++i) {
1706
        ActiveInfo info;
1707
        getActiveAttribImpl(program, i, info);
1708
        if (info.name.startsWith("gl_"))
1709
            continue;
1710
1711
        symbolCounts.filteredToActualAttributeIndexMap.append(i);
1712
    }
1713
    
1714
    // Do the same for uniforms.
1715
    GCGLint uniformCount = 0;
1716
    ::glGetProgramiv(program, ACTIVE_UNIFORMS, &uniformCount);
1717
    for (GCGLint i = 0; i < uniformCount; ++i) {
1718
        ActiveInfo info;
1719
        getActiveUniformImpl(program, i, info);
1720
        if (info.name.startsWith("gl_"))
1721
            continue;
1722
        
1723
        symbolCounts.filteredToActualUniformIndexMap.append(i);
1724
    }
1725
    
1726
    *value = symbolCounts.countForType(pname);
1727
}
1728
1729
String GraphicsContextGLOpenGL::getUnmangledInfoLog(PlatformGLObject shaders[2], GCGLsizei count, const String& log)
1730
{
1731
    LOG(WebGL, "Original ShaderInfoLog:\n%s", log.utf8().data());
1732
1733
    JSC::Yarr::RegularExpression regExp("webgl_[0123456789abcdefABCDEF]+");
1734
1735
    StringBuilder processedLog;
1736
    
1737
    // ANGLE inserts a "#extension" line into the shader source that
1738
    // causes a warning in some compilers. There is no point showing
1739
    // this warning to the user since they didn't write the code that
1740
    // is causing it.
1741
    static const NeverDestroyed<String> angleWarning { "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n"_s };
1742
    int startFrom = log.startsWith(angleWarning) ? angleWarning.get().length() : 0;
1743
    int matchedLength = 0;
1744
1745
    do {
1746
        int start = regExp.match(log, startFrom, &matchedLength);
1747
        if (start == -1)
1748
            break;
1749
1750
        processedLog.append(log.substring(startFrom, start - startFrom));
1751
        startFrom = start + matchedLength;
1752
1753
        const String& mangledSymbol = log.substring(start, matchedLength);
1754
        const String& mappedSymbol = mappedSymbolName(shaders, count, mangledSymbol);
1755
        LOG(WebGL, "Demangling: %s to %s", mangledSymbol.utf8().data(), mappedSymbol.utf8().data());
1756
        processedLog.append(mappedSymbol);
1757
    } while (startFrom < static_cast<int>(log.length()));
1758
1759
    processedLog.append(log.substring(startFrom, log.length() - startFrom));
1760
1761
    LOG(WebGL, "Unmangled ShaderInfoLog:\n%s", processedLog.toString().utf8().data());
1762
    return processedLog.toString();
1763
}
1764
1765
String GraphicsContextGLOpenGL::getProgramInfoLog(PlatformGLObject program)
1766
{
1767
    ASSERT(program);
1768
1769
    if (!makeContextCurrent())
1770
        return String();
1771
1772
    GLint length = 0;
1773
    ::glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
1774
    if (!length)
1775
        return String(); 
1776
1777
    GLsizei size = 0;
1778
    Vector<GLchar> info(length);
1779
    ::glGetProgramInfoLog(program, length, &size, info.data());
1780
1781
    GCGLsizei count;
1782
    PlatformGLObject shaders[2];
1783
    getAttachedShaders(program, 2, &count, shaders);
1784
1785
    return getUnmangledInfoLog(shaders, count, String(info.data(), size));
1786
}
1787
1788
GCGLint GraphicsContextGLOpenGL::getRenderbufferParameteri(GCGLenum target, GCGLenum pname)
1789
{
1790
    GCGLint value = 0;
1791
    if (!makeContextCurrent())
1792
        return value;
1793
    ::glGetRenderbufferParameterivEXT(target, pname, &value);
1794
    return value;
1795
}
1796
1797
GCGLint GraphicsContextGLOpenGL::getShaderi(PlatformGLObject shader, GCGLenum pname)
1798
{
1799
    ASSERT(shader);
1800
    GCGLint value = 0;
1801
    if (!makeContextCurrent())
1802
        return value;
1803
1804
1805
    const auto& result = m_shaderSourceMap.find(shader);
1806
    
1807
    switch (pname) {
1808
    case DELETE_STATUS:
1809
    case SHADER_TYPE:
1810
        ::glGetShaderiv(shader, pname, &value);
1811
        break;
1812
    case COMPILE_STATUS:
1813
        if (result != m_shaderSourceMap.end())
1814
            value = static_cast<int>(result->value.isValid);
1815
        break;
1816
    case INFO_LOG_LENGTH:
1817
        if (result != m_shaderSourceMap.end())
1818
            value = getShaderInfoLog(shader).length();
1819
        break;
1820
    case SHADER_SOURCE_LENGTH:
1821
        value = getShaderSource(shader).length();
1822
        break;
1823
    default:
1824
        synthesizeGLError(INVALID_ENUM);
1825
    }
1826
    return value;
1827
}
1828
1829
String GraphicsContextGLOpenGL::getShaderInfoLog(PlatformGLObject shader)
1830
{
1831
    ASSERT(shader);
1832
1833
    if (!makeContextCurrent())
1834
        return String();
1835
1836
    const auto& result = m_shaderSourceMap.find(shader);
1837
    if (result == m_shaderSourceMap.end())
1838
        return String(); 
1839
1840
    const ShaderSourceEntry& entry = result->value;
1841
    if (!entry.isValid)
1842
        return entry.log;
1843
1844
    GLint length = 0;
1845
    ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
1846
    if (!length)
1847
        return String(); 
1848
1849
    GLsizei size = 0;
1850
    Vector<GLchar> info(length);
1851
    ::glGetShaderInfoLog(shader, length, &size, info.data());
1852
1853
    PlatformGLObject shaders[2] = { shader, 0 };
1854
    return getUnmangledInfoLog(shaders, 1, String(info.data(), size));
1855
}
1856
1857
String GraphicsContextGLOpenGL::getShaderSource(PlatformGLObject shader)
1858
{
1859
    ASSERT(shader);
1860
1861
    if (!makeContextCurrent())
1862
        return String();
1863
1864
    const auto& result = m_shaderSourceMap.find(shader);
1865
    if (result == m_shaderSourceMap.end())
1866
        return String(); 
1867
1868
    return result->value.source;
1869
}
1870
1871
GCGLfloat GraphicsContextGLOpenGL::getTexParameterf(GCGLenum target, GCGLenum pname)
1872
{
1873
    GCGLfloat value = 0.f;
1874
    if (!makeContextCurrent())
1875
        return value;
1876
    ::glGetTexParameterfv(target, pname, &value);
1877
    return value;
1878
}
1879
1880
GCGLint GraphicsContextGLOpenGL::getTexParameteri(GCGLenum target, GCGLenum pname)
1881
{
1882
    GCGLint value = 0;
1883
    if (!makeContextCurrent())
1884
        return value;
1885
    ::glGetTexParameteriv(target, pname, &value);
1886
    return value;
1887
}
1888
1889
void GraphicsContextGLOpenGL::getUniformfv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLfloat> value)
1890
{
1891
    if (!makeContextCurrent())
1892
        return;
1893
1894
    ::glGetUniformfv(program, location, value.data);
1895
}
1896
1897
void GraphicsContextGLOpenGL::getUniformiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLint> value)
1898
{
1899
    if (!makeContextCurrent())
1900
        return;
1901
1902
    ::glGetUniformiv(program, location, value.data);
1903
}
1904
1905
void GraphicsContextGLOpenGL::getUniformuiv(PlatformGLObject program, GCGLint location, GCGLSpan<GCGLuint> value)
1906
{
1907
    UNUSED_PARAM(program);
1908
    UNUSED_PARAM(location);
1909
    UNUSED_PARAM(value);
1910
}
1911
1912
GCGLint GraphicsContextGLOpenGL::getUniformLocation(PlatformGLObject program, const String& name)
1913
{
1914
    ASSERT(program);
1915
1916
    if (!makeContextCurrent())
1917
        return -1;
1918
1919
    String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, name);
1920
    LOG(WebGL, "::getUniformLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data());
1921
    return ::glGetUniformLocation(program, mappedName.utf8().data());
1922
}
1923
1924
GCGLsizeiptr GraphicsContextGLOpenGL::getVertexAttribOffset(GCGLuint index, GCGLenum pname)
1925
{
1926
    if (!makeContextCurrent())
1927
        return 0;
1928
1929
    GLvoid* pointer = 0;
1930
    ::glGetVertexAttribPointerv(index, pname, &pointer);
1931
    return static_cast<GCGLsizeiptr>(reinterpret_cast<intptr_t>(pointer));
1932
}
1933
1934
void GraphicsContextGLOpenGL::texSubImage2D(GCGLenum target, GCGLint level, GCGLint xoff, GCGLint yoff, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLSpan<const GCGLvoid> pixels)
1935
{
1936
    if (!makeContextCurrent())
1937
        return;
1938
1939
#if !USE(OPENGL_ES)
1940
    if (type == HALF_FLOAT_OES)
1941
        type = GL_HALF_FLOAT_ARB;
1942
#endif
1943
1944
    if (m_usingCoreProfile)  {
1945
        // There are some format values used in WebGL that are deprecated when using a core profile, so we need
1946
        // to adapt them, as we do in GraphicsContextGLOpenGL::texImage2D().
1947
        switch (format) {
1948
        case ALPHA:
1949
            // We are using GL_RED to back GL_ALPHA, so do it here as well.
1950
            format = RED;
1951
            break;
1952
        case LUMINANCE_ALPHA:
1953
            // We are using GL_RG to back GL_LUMINANCE_ALPHA, so do it here as well.
1954
            format = RG;
1955
            break;
1956
        default:
1957
            break;
1958
        }
1959
    }
1960
1961
    // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size.
1962
    ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels.data);
1963
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1964
}
1965
1966
void GraphicsContextGLOpenGL::compressedTexImage2D(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
1967
{
1968
    if (!makeContextCurrent())
1969
        return;
1970
1971
    ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data.data);
1972
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1973
}
1974
1975
void GraphicsContextGLOpenGL::compressedTexSubImage2D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLsizei imageSize, GCGLSpan<const GCGLvoid> data)
1976
{
1977
    if (!makeContextCurrent())
1978
        return;
1979
1980
    ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data.data);
1981
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
1982
}
1983
1984
PlatformGLObject GraphicsContextGLOpenGL::createBuffer()
1985
{
1986
    if (!makeContextCurrent())
1987
        return 0;
1988
1989
    GLuint o = 0;
1990
    glGenBuffers(1, &o);
1991
    return o;
1992
}
1993
1994
PlatformGLObject GraphicsContextGLOpenGL::createFramebuffer()
1995
{
1996
    if (!makeContextCurrent())
1997
        return 0;
1998
1999
    GLuint o = 0;
2000
    glGenFramebuffersEXT(1, &o);
2001
    return o;
2002
}
2003
2004
PlatformGLObject GraphicsContextGLOpenGL::createProgram()
2005
{
2006
    if (!makeContextCurrent())
2007
        return 0;
2008
2009
    return glCreateProgram();
2010
}
2011
2012
PlatformGLObject GraphicsContextGLOpenGL::createRenderbuffer()
2013
{
2014
    if (!makeContextCurrent())
2015
        return 0;
2016
2017
    GLuint o = 0;
2018
    glGenRenderbuffersEXT(1, &o);
2019
    return o;
2020
}
2021
2022
PlatformGLObject GraphicsContextGLOpenGL::createShader(GCGLenum type)
2023
{
2024
    if (!makeContextCurrent())
2025
        return 0;
2026
2027
    return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
2028
}
2029
2030
PlatformGLObject GraphicsContextGLOpenGL::createTexture()
2031
{
2032
    if (!makeContextCurrent())
2033
        return 0;
2034
2035
    GLuint o = 0;
2036
    glGenTextures(1, &o);
2037
    m_state.textureSeedCount.add(o);
2038
    return o;
2039
}
2040
2041
void GraphicsContextGLOpenGL::deleteBuffer(PlatformGLObject buffer)
2042
{
2043
    if (!makeContextCurrent())
2044
        return;
2045
2046
    glDeleteBuffers(1, &buffer);
2047
}
2048
2049
void GraphicsContextGLOpenGL::deleteFramebuffer(PlatformGLObject framebuffer)
2050
{
2051
    if (!makeContextCurrent())
2052
        return;
2053
2054
    ASSERT(m_state.boundReadFBO == m_state.boundDrawFBO);
2055
    if (framebuffer == m_state.boundDrawFBO) {
2056
        // Make sure the framebuffer is not going to be used for drawing
2057
        // operations after it gets deleted.
2058
        bindFramebuffer(FRAMEBUFFER, 0);
2059
    }
2060
    glDeleteFramebuffersEXT(1, &framebuffer);
2061
}
2062
2063
void GraphicsContextGLOpenGL::deleteProgram(PlatformGLObject program)
2064
{
2065
    if (!makeContextCurrent())
2066
        return;
2067
2068
    m_shaderProgramSymbolCountMap.remove(program);
2069
    glDeleteProgram(program);
2070
}
2071
2072
void GraphicsContextGLOpenGL::deleteRenderbuffer(PlatformGLObject renderbuffer)
2073
{
2074
    if (!makeContextCurrent())
2075
        return;
2076
2077
    glDeleteRenderbuffersEXT(1, &renderbuffer);
2078
}
2079
2080
void GraphicsContextGLOpenGL::deleteShader(PlatformGLObject shader)
2081
{
2082
    if (!makeContextCurrent())
2083
        return;
2084
2085
    glDeleteShader(shader);
2086
}
2087
2088
void GraphicsContextGLOpenGL::deleteTexture(PlatformGLObject texture)
2089
{
2090
    if (!makeContextCurrent())
2091
        return;
2092
2093
    m_state.boundTextureMap.removeIf([texture] (auto& keyValue) {
2094
        return keyValue.value.first == texture;
2095
    });
2096
    glDeleteTextures(1, &texture);
2097
    m_state.textureSeedCount.removeAll(texture);
2098
}
2099
2100
void GraphicsContextGLOpenGL::synthesizeGLError(GCGLenum error)
2101
{
2102
    // Need to move the current errors to the synthetic error list to
2103
    // preserve the order of errors, so a caller to getError will get
2104
    // any errors from glError before the error we are synthesizing.
2105
    moveErrorsToSyntheticErrorList();
2106
    m_syntheticErrors.add(error);
2107
}
2108
2109
void GraphicsContextGLOpenGL::forceContextLost()
2110
{
2111
    for (auto* client : copyToVector(m_clients))
2112
        client->forceContextLost();
2113
}
2114
2115
void GraphicsContextGLOpenGL::recycleContext()
2116
{
2117
    for (auto* client : copyToVector(m_clients))
2118
        client->recycleContext();
2119
}
2120
2121
void GraphicsContextGLOpenGL::dispatchContextChangedNotification()
2122
{
2123
    for (auto* client : copyToVector(m_clients))
2124
        client->dispatchContextChangedNotification();
2125
}
2126
2127
void GraphicsContextGLOpenGL::texImage2DDirect(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, const void* pixels)
2128
{
2129
    if (!makeContextCurrent())
2130
        return;
2131
2132
    ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
2133
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
2134
}
2135
2136
void GraphicsContextGLOpenGL::drawArraysInstanced(GCGLenum mode, GCGLint first, GCGLsizei count, GCGLsizei primcount)
2137
{
2138
    getExtensions().drawArraysInstancedANGLE(mode, first, count, primcount);
2139
    checkGPUStatus();
2140
}
2141
2142
void GraphicsContextGLOpenGL::drawElementsInstanced(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLintptr offset, GCGLsizei primcount)
2143
{
2144
    getExtensions().drawElementsInstancedANGLE(mode, count, type, offset, primcount);
2145
    checkGPUStatus();
2146
}
2147
2148
void GraphicsContextGLOpenGL::vertexAttribDivisor(GCGLuint index, GCGLuint divisor)
2149
{
2150
    getExtensions().vertexAttribDivisorANGLE(index, divisor);
2151
}
2152
2153
#if HAVE(OPENGL_4) && ENABLE(WEBGL2)
2154
void GraphicsContextGLOpenGL::primitiveRestartIndex(GCGLuint index)
2155
{
2156
    if (!makeContextCurrent())
2157
        return;
2158
2159
    ::glPrimitiveRestartIndex(index);
2160
}
2161
#endif
2162
2163
void GraphicsContextGLOpenGL::bufferData(GCGLenum target, const void* data, GCGLenum usage, GCGLuint srcOffset, GCGLuint length)
2164
{
2165
    UNUSED_PARAM(target);
2166
    UNUSED_PARAM(data);
2167
    UNUSED_PARAM(usage);
2168
    UNUSED_PARAM(srcOffset);
2169
    UNUSED_PARAM(length);
2170
}
2171
2172
void GraphicsContextGLOpenGL::bufferSubData(GCGLenum target, GCGLintptr dstByteOffset, const void* srcData, GCGLuint srcOffset, GCGLuint length)
2173
{
2174
    UNUSED_PARAM(target);
2175
    UNUSED_PARAM(dstByteOffset);
2176
    UNUSED_PARAM(srcData);
2177
    UNUSED_PARAM(srcOffset);
2178
    UNUSED_PARAM(length);
2179
}
2180
2181
#if HAVE(OPENGL_4) || HAVE(OPENGL_ES_3)
2182
void GraphicsContextGLOpenGL::copyBufferSubData(GCGLenum readTarget, GCGLenum writeTarget, GCGLintptr readOffset, GCGLintptr writeOffset, GCGLsizeiptr size)
2183
{
2184
    if (!makeContextCurrent())
2185
        return;
2186
2187
    ::glCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
2188
}
2189
#else
2190
void GraphicsContextGLOpenGL::copyBufferSubData(GCGLenum, GCGLenum, GCGLintptr, GCGLintptr, GCGLsizeiptr)
2191
{
2192
}
2193
#endif
2194
2195
void GraphicsContextGLOpenGL::getBufferSubData(GCGLenum target, GCGLintptr offset, GCGLSpan<GCGLvoid> data)
2196
{
2197
#if HAVE(OPENGL_4) || HAVE(OPENGL_ES_3)
2198
    if (!makeContextCurrent())
2199
        return;
2200
    GCGLvoid* ptr = ::glMapBufferRange(target, offset, data.bufSize, GraphicsContextGL::MAP_READ_BIT);
2201
    if (!ptr)
2202
        return;
2203
    memcpy(data.data, ptr, data.bufSize);
2204
    if (!::glUnmapBuffer(target))
2205
        synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2206
#else
2207
    UNUSED_PARAM(target);
2208
    UNUSED_PARAM(offset);
2209
    UNUSED_PARAM(data);
2210
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2211
#endif
2212
}
2213
2214
2215
void GraphicsContextGLOpenGL::blitFramebuffer(GCGLint srcX0, GCGLint srcY0, GCGLint srcX1, GCGLint srcY1, GCGLint dstX0, GCGLint dstY0, GCGLint dstX1, GCGLint dstY1, GCGLbitfield mask, GCGLenum filter)
2216
{
2217
    UNUSED_PARAM(srcX0);
2218
    UNUSED_PARAM(srcY0);
2219
    UNUSED_PARAM(srcX1);
2220
    UNUSED_PARAM(srcY1);
2221
    UNUSED_PARAM(dstX0);
2222
    UNUSED_PARAM(dstY0);
2223
    UNUSED_PARAM(dstX1);
2224
    UNUSED_PARAM(dstY1);
2225
    UNUSED_PARAM(mask);
2226
    UNUSED_PARAM(filter);
2227
}
2228
2229
void GraphicsContextGLOpenGL::framebufferTextureLayer(GCGLenum target, GCGLenum attachment, PlatformGLObject texture, GCGLint level, GCGLint layer)
2230
{
2231
    UNUSED_PARAM(target);
2232
    UNUSED_PARAM(attachment);
2233
    UNUSED_PARAM(texture);
2234
    UNUSED_PARAM(level);
2235
    UNUSED_PARAM(layer);
2236
}
2237
2238
void GraphicsContextGLOpenGL::invalidateFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments)
2239
{
2240
    UNUSED_PARAM(target);
2241
    UNUSED_PARAM(attachments);
2242
}
2243
2244
void GraphicsContextGLOpenGL::invalidateSubFramebuffer(GCGLenum target, GCGLSpan<const GCGLenum> attachments, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
2245
{
2246
    UNUSED_PARAM(target);
2247
    UNUSED_PARAM(attachments);
2248
    UNUSED_PARAM(x);
2249
    UNUSED_PARAM(y);
2250
    UNUSED_PARAM(width);
2251
    UNUSED_PARAM(height);
2252
}
2253
2254
void GraphicsContextGLOpenGL::readBuffer(GCGLenum src)
2255
{
2256
    UNUSED_PARAM(src);
2257
}
2258
2259
#if HAVE(OPENGL_4) || HAVE(OPENGL_ES_3)
2260
void GraphicsContextGLOpenGL::getInternalformativ(GCGLenum target, GCGLenum internalformat, GCGLenum pname, GCGLSpan<GCGLint> data)
2261
{
2262
#if USE(OPENGL_ES)
2263
    if (!makeContextCurrent())
2264
        return;
2265
2266
    ::glGetInternalformativ(target, internalformat, pname, data.bufSize, data.data);
2267
#else
2268
    UNUSED_PARAM(target);
2269
    UNUSED_PARAM(internalformat);
2270
    UNUSED_PARAM(pname);
2271
    UNUSED_PARAM(bufSize);
2272
    UNUSED_PARAM(params);
2273
#endif
2274
}
2275
2276
void GraphicsContextGLOpenGL::renderbufferStorageMultisample(GCGLenum target, GCGLsizei samples, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
2277
{
2278
    if (!makeContextCurrent())
2279
        return;
2280
2281
    ::glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
2282
}
2283
2284
void GraphicsContextGLOpenGL::texStorage2D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height)
2285
{
2286
    if (!makeContextCurrent())
2287
        return;
2288
2289
    ::glTexStorage2D(target, levels, internalformat, width, height);
2290
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
2291
}
2292
2293
void GraphicsContextGLOpenGL::texStorage3D(GCGLenum target, GCGLsizei levels, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLsizei depth)
2294
{
2295
    if (!makeContextCurrent())
2296
        return;
2297
2298
    ::glTexStorage3D(target, levels, internalformat, width, height, depth);
2299
    m_state.textureSeedCount.add(m_state.currentBoundTexture());
2300
}
2301
#else
2302
void GraphicsContextGLOpenGL::getInternalformativ(GCGLenum, GCGLenum, GCGLenum, GCGLSpan<GCGLint>)
2303
{
2304
}
2305
2306
void GraphicsContextGLOpenGL::renderbufferStorageMultisample(GCGLenum, GCGLsizei, GCGLenum, GCGLsizei, GCGLsizei)
2307
{
2308
}
2309
2310
void GraphicsContextGLOpenGL::texStorage2D(GCGLenum, GCGLsizei, GCGLenum, GCGLsizei, GCGLsizei)
2311
{
2312
}
2313
2314
void GraphicsContextGLOpenGL::texStorage3D(GCGLenum, GCGLsizei, GCGLenum, GCGLsizei, GCGLsizei, GCGLsizei)
2315
{
2316
}
2317
#endif
2318
2319
void GraphicsContextGLOpenGL::copyTexSubImage3D(GCGLenum target, GCGLint level, GCGLint xoffset, GCGLint yoffset, GCGLint zoffset, GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height)
2320
{
2321
    UNUSED_PARAM(target);
2322
    UNUSED_PARAM(level);
2323
    UNUSED_PARAM(xoffset);
2324
    UNUSED_PARAM(yoffset);
2325
    UNUSED_PARAM(zoffset);
2326
    UNUSED_PARAM(x);
2327
    UNUSED_PARAM(y);
2328
    UNUSED_PARAM(width);
2329
    UNUSED_PARAM(height);
2330
}
2331
2332
GCGLint GraphicsContextGLOpenGL::getFragDataLocation(PlatformGLObject program, const String& name)
2333
{
2334
    UNUSED_PARAM(program);
2335
    UNUSED_PARAM(name);
2336
2337
    return 0;
2338
}
2339
2340
void GraphicsContextGLOpenGL::uniform1ui(GCGLint location, GCGLuint v0)
2341
{
2342
    UNUSED_PARAM(location);
2343
    UNUSED_PARAM(v0);
2344
}
2345
2346
void GraphicsContextGLOpenGL::uniform2ui(GCGLint location, GCGLuint v0, GCGLuint v1)
2347
{
2348
    UNUSED_PARAM(location);
2349
    UNUSED_PARAM(v0);
2350
    UNUSED_PARAM(v1);
2351
}
2352
2353
void GraphicsContextGLOpenGL::uniform3ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2)
2354
{
2355
    UNUSED_PARAM(location);
2356
    UNUSED_PARAM(v0);
2357
    UNUSED_PARAM(v1);
2358
    UNUSED_PARAM(v2);
2359
}
2360
2361
void GraphicsContextGLOpenGL::uniform4ui(GCGLint location, GCGLuint v0, GCGLuint v1, GCGLuint v2, GCGLuint v3)
2362
{
2363
    UNUSED_PARAM(location);
2364
    UNUSED_PARAM(v0);
2365
    UNUSED_PARAM(v1);
2366
    UNUSED_PARAM(v2);
2367
    UNUSED_PARAM(v3);
2368
}
2369
2370
void GraphicsContextGLOpenGL::uniform1uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2371
{
2372
    UNUSED_PARAM(location);
2373
    UNUSED_PARAM(data);
2374
}
2375
2376
void GraphicsContextGLOpenGL::uniform2uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2377
{
2378
    UNUSED_PARAM(location);
2379
    UNUSED_PARAM(data);
2380
}
2381
2382
void GraphicsContextGLOpenGL::uniform3uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2383
{
2384
    UNUSED_PARAM(location);
2385
    UNUSED_PARAM(data);
2386
}
2387
2388
void GraphicsContextGLOpenGL::uniform4uiv(GCGLint location, GCGLSpan<const GCGLuint> data)
2389
{
2390
    UNUSED_PARAM(location);
2391
    UNUSED_PARAM(data);
2392
}
2393
2394
void GraphicsContextGLOpenGL::uniformMatrix2x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2395
{
2396
    UNUSED_PARAM(location);
2397
    UNUSED_PARAM(transpose);
2398
    UNUSED_PARAM(data);
2399
}
2400
2401
void GraphicsContextGLOpenGL::uniformMatrix3x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2402
{
2403
    UNUSED_PARAM(location);
2404
    UNUSED_PARAM(transpose);
2405
    UNUSED_PARAM(data);
2406
}
2407
2408
void GraphicsContextGLOpenGL::uniformMatrix2x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2409
{
2410
    UNUSED_PARAM(location);
2411
    UNUSED_PARAM(transpose);
2412
    UNUSED_PARAM(data);
2413
}
2414
2415
void GraphicsContextGLOpenGL::uniformMatrix4x2fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2416
{
2417
    UNUSED_PARAM(location);
2418
    UNUSED_PARAM(transpose);
2419
    UNUSED_PARAM(data);
2420
}
2421
2422
void GraphicsContextGLOpenGL::uniformMatrix3x4fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2423
{
2424
    UNUSED_PARAM(location);
2425
    UNUSED_PARAM(transpose);
2426
    UNUSED_PARAM(data);
2427
}
2428
2429
void GraphicsContextGLOpenGL::uniformMatrix4x3fv(GCGLint location, GCGLboolean transpose, GCGLSpan<const GCGLfloat> data)
2430
{
2431
    UNUSED_PARAM(location);
2432
    UNUSED_PARAM(transpose);
2433
    UNUSED_PARAM(data);
2434
}
2435
2436
void GraphicsContextGLOpenGL::vertexAttribI4i(GCGLuint index, GCGLint x, GCGLint y, GCGLint z, GCGLint w)
2437
{
2438
    UNUSED_PARAM(index);
2439
    UNUSED_PARAM(x);
2440
    UNUSED_PARAM(y);
2441
    UNUSED_PARAM(z);
2442
    UNUSED_PARAM(w);
2443
}
2444
2445
void GraphicsContextGLOpenGL::vertexAttribI4iv(GCGLuint index, GCGLSpan<const GCGLint, 4> values)
2446
{
2447
    UNUSED_PARAM(index);
2448
    UNUSED_PARAM(values);
2449
}
2450
2451
void GraphicsContextGLOpenGL::vertexAttribI4ui(GCGLuint index, GCGLuint x, GCGLuint y, GCGLuint z, GCGLuint w)
2452
{
2453
    UNUSED_PARAM(index);
2454
    UNUSED_PARAM(x);
2455
    UNUSED_PARAM(y);
2456
    UNUSED_PARAM(z);
2457
    UNUSED_PARAM(w);
2458
}
2459
2460
void GraphicsContextGLOpenGL::vertexAttribI4uiv(GCGLuint index, GCGLSpan<const GCGLuint, 4> values)
2461
{
2462
    UNUSED_PARAM(index);
2463
    UNUSED_PARAM(values);
2464
}
2465
2466
void GraphicsContextGLOpenGL::vertexAttribIPointer(GCGLuint index, GCGLint size, GCGLenum type, GCGLsizei stride, GCGLintptr offset)
2467
{
2468
    UNUSED_PARAM(index);
2469
    UNUSED_PARAM(size);
2470
    UNUSED_PARAM(type);
2471
    UNUSED_PARAM(stride);
2472
    UNUSED_PARAM(offset);
2473
}
2474
2475
void GraphicsContextGLOpenGL::drawRangeElements(GCGLenum mode, GCGLuint start, GCGLuint end, GCGLsizei count, GCGLenum type, GCGLintptr offset)
2476
{
2477
    UNUSED_PARAM(mode);
2478
    UNUSED_PARAM(start);
2479
    UNUSED_PARAM(end);
2480
    UNUSED_PARAM(count);
2481
    UNUSED_PARAM(type);
2482
    UNUSED_PARAM(offset);
2483
}
2484
2485
void GraphicsContextGLOpenGL::drawBuffers(GCGLSpan<const GCGLenum> bufs)
2486
{
2487
    UNUSED_PARAM(bufs);
2488
}
2489
2490
void GraphicsContextGLOpenGL::clearBufferiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLint> values)
2491
{
2492
    UNUSED_PARAM(buffer);
2493
    UNUSED_PARAM(drawbuffer);
2494
    UNUSED_PARAM(values);
2495
}
2496
2497
void GraphicsContextGLOpenGL::clearBufferuiv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLuint> values)
2498
{
2499
    UNUSED_PARAM(buffer);
2500
    UNUSED_PARAM(drawbuffer);
2501
    UNUSED_PARAM(values);
2502
}
2503
2504
void GraphicsContextGLOpenGL::clearBufferfv(GCGLenum buffer, GCGLint drawbuffer, GCGLSpan<const GCGLfloat> values)
2505
{
2506
    UNUSED_PARAM(buffer);
2507
    UNUSED_PARAM(drawbuffer);
2508
    UNUSED_PARAM(values);
2509
}
2510
2511
void GraphicsContextGLOpenGL::clearBufferfi(GCGLenum buffer, GCGLint drawbuffer, GCGLfloat depth, GCGLint stencil)
2512
{
2513
    UNUSED_PARAM(buffer);
2514
    UNUSED_PARAM(drawbuffer);
2515
    UNUSED_PARAM(depth);
2516
    UNUSED_PARAM(stencil);
2517
}
2518
2519
PlatformGLObject GraphicsContextGLOpenGL::createQuery()
2520
{
2521
    return 0;
2522
}
2523
2524
void GraphicsContextGLOpenGL::deleteQuery(PlatformGLObject query)
2525
{
2526
    UNUSED_PARAM(query);
2527
}
2528
2529
GCGLboolean GraphicsContextGLOpenGL::isQuery(PlatformGLObject query)
2530
{
2531
    UNUSED_PARAM(query);
2532
2533
    return false;
2534
}
2535
2536
void GraphicsContextGLOpenGL::beginQuery(GCGLenum target, PlatformGLObject query)
2537
{
2538
    UNUSED_PARAM(target);
2539
    UNUSED_PARAM(query);
2540
}
2541
2542
void GraphicsContextGLOpenGL::endQuery(GCGLenum target)
2543
{
2544
    UNUSED_PARAM(target);
2545
}
2546
2547
PlatformGLObject GraphicsContextGLOpenGL::getQuery(GCGLenum target, GCGLenum pname)
2548
{
2549
    UNUSED_PARAM(target);
2550
    UNUSED_PARAM(pname);
2551
2552
    return 0;
2553
}
2554
2555
GCGLuint GraphicsContextGLOpenGL::getQueryObjectui(PlatformGLObject query, GCGLenum pname)
2556
{
2557
    UNUSED_PARAM(query);
2558
    UNUSED_PARAM(pname);
2559
    return 0;
2560
}
2561
2562
PlatformGLObject GraphicsContextGLOpenGL::createSampler()
2563
{
2564
    return 0;
2565
}
2566
2567
void GraphicsContextGLOpenGL::deleteSampler(PlatformGLObject sampler)
2568
{
2569
    UNUSED_PARAM(sampler);
2570
}
2571
2572
GCGLboolean GraphicsContextGLOpenGL::isSampler(PlatformGLObject sampler)
2573
{
2574
    UNUSED_PARAM(sampler);
2575
2576
    return false;
2577
}
2578
2579
void GraphicsContextGLOpenGL::bindSampler(GCGLuint unit, PlatformGLObject sampler)
2580
{
2581
    UNUSED_PARAM(unit);
2582
    UNUSED_PARAM(sampler);
2583
}
2584
2585
void GraphicsContextGLOpenGL::samplerParameteri(PlatformGLObject sampler, GCGLenum pname, GCGLint param)
2586
{
2587
    UNUSED_PARAM(sampler);
2588
    UNUSED_PARAM(pname);
2589
    UNUSED_PARAM(param);
2590
}
2591
2592
void GraphicsContextGLOpenGL::samplerParameterf(PlatformGLObject sampler, GCGLenum pname, GCGLfloat param)
2593
{
2594
    UNUSED_PARAM(sampler);
2595
    UNUSED_PARAM(pname);
2596
    UNUSED_PARAM(param);
2597
}
2598
2599
GCGLfloat GraphicsContextGLOpenGL::getSamplerParameterf(PlatformGLObject sampler, GCGLenum pname)
2600
{
2601
    UNUSED_PARAM(sampler);
2602
    UNUSED_PARAM(pname);
2603
    return 0.f;
2604
}
2605
2606
GCGLint GraphicsContextGLOpenGL::getSamplerParameteri(PlatformGLObject sampler, GCGLenum pname)
2607
2608
{
2609
    UNUSED_PARAM(sampler);
2610
    UNUSED_PARAM(pname);
2611
    return 0;
2612
}
2613
2614
GCGLsync GraphicsContextGLOpenGL::fenceSync(GCGLenum condition, GCGLbitfield flags)
2615
{
2616
    UNUSED_PARAM(condition);
2617
    UNUSED_PARAM(flags);
2618
2619
    return 0;
2620
}
2621
2622
GCGLboolean GraphicsContextGLOpenGL::isSync(GCGLsync sync)
2623
{
2624
    UNUSED_PARAM(sync);
2625
2626
    return false;
2627
}
2628
2629
void GraphicsContextGLOpenGL::deleteSync(GCGLsync sync)
2630
{
2631
    UNUSED_PARAM(sync);
2632
}
2633
2634
GCGLenum GraphicsContextGLOpenGL::clientWaitSync(GCGLsync sync, GCGLbitfield flags, GCGLuint64 timeout)
2635
{
2636
    UNUSED_PARAM(sync);
2637
    UNUSED_PARAM(flags);
2638
    UNUSED_PARAM(timeout);
2639
2640
    return 0;
2641
}
2642
2643
void GraphicsContextGLOpenGL::waitSync(GCGLsync sync, GCGLbitfield flags, GCGLint64 timeout)
2644
{
2645
    UNUSED_PARAM(sync);
2646
    UNUSED_PARAM(flags);
2647
    UNUSED_PARAM(timeout);
2648
}
2649
2650
GCGLint GraphicsContextGLOpenGL::getSynci(GCGLsync sync, GCGLenum pname)
2651
{
2652
    UNUSED_PARAM(sync);
2653
    UNUSED_PARAM(pname);
2654
    return 0;
2655
}
2656
2657
PlatformGLObject GraphicsContextGLOpenGL::createTransformFeedback()
2658
{
2659
    return 0;
2660
}
2661
2662
void GraphicsContextGLOpenGL::deleteTransformFeedback(PlatformGLObject id)
2663
{
2664
    UNUSED_PARAM(id);
2665
}
2666
2667
GCGLboolean GraphicsContextGLOpenGL::isTransformFeedback(PlatformGLObject id)
2668
{
2669
    UNUSED_PARAM(id);
2670
2671
    return false;
2672
}
2673
2674
void GraphicsContextGLOpenGL::bindTransformFeedback(GCGLenum target, PlatformGLObject id)
2675
{
2676
    UNUSED_PARAM(target);
2677
    UNUSED_PARAM(id);
2678
}
2679
2680
void GraphicsContextGLOpenGL::beginTransformFeedback(GCGLenum primitiveMode)
2681
{
2682
    UNUSED_PARAM(primitiveMode);
2683
}
2684
2685
void GraphicsContextGLOpenGL::endTransformFeedback()
2686
{
2687
}
2688
2689
void GraphicsContextGLOpenGL::transformFeedbackVaryings(PlatformGLObject program, const Vector<String>& varyings, GCGLenum bufferMode)
2690
{
2691
    UNUSED_PARAM(program);
2692
    UNUSED_PARAM(varyings);
2693
    UNUSED_PARAM(bufferMode);
2694
}
2695
2696
void GraphicsContextGLOpenGL::getTransformFeedbackVarying(PlatformGLObject program, GCGLuint index, ActiveInfo&)
2697
{
2698
    UNUSED_PARAM(program);
2699
    UNUSED_PARAM(index);
2700
}
2701
2702
void GraphicsContextGLOpenGL::pauseTransformFeedback()
2703
{
2704
}
2705
2706
void GraphicsContextGLOpenGL::resumeTransformFeedback()
2707
{
2708
}
2709
2710
void GraphicsContextGLOpenGL::bindBufferBase(GCGLenum target, GCGLuint index, PlatformGLObject buffer)
2711
{
2712
    UNUSED_PARAM(target);
2713
    UNUSED_PARAM(index);
2714
    UNUSED_PARAM(buffer);
2715
}
2716
2717
void GraphicsContextGLOpenGL::bindBufferRange(GCGLenum target, GCGLuint index, PlatformGLObject buffer, GCGLintptr offset, GCGLsizeiptr size)
2718
{
2719
    UNUSED_PARAM(target);
2720
    UNUSED_PARAM(index);
2721
    UNUSED_PARAM(buffer);
2722
    UNUSED_PARAM(offset);
2723
    UNUSED_PARAM(size);
2724
}
2725
2726
Vector<GCGLuint> GraphicsContextGLOpenGL::getUniformIndices(PlatformGLObject program, const Vector<String>& uniformNames)
2727
{
2728
    UNUSED_PARAM(program);
2729
    UNUSED_PARAM(uniformNames);
2730
2731
    return { };
2732
}
2733
2734
Vector<GCGLint> GraphicsContextGLOpenGL::getActiveUniforms(PlatformGLObject program, const Vector<GCGLuint>& uniformIndices, GCGLenum pname)
2735
{
2736
    Vector<GCGLint> result(uniformIndices.size(), 0);
2737
#if HAVE(OPENGL_4) || HAVE(OPENGL_ES_3)
2738
    ASSERT(program);
2739
    if (!makeContextCurrent())
2740
        return result;
2741
2742
    ::glGetActiveUniformsiv(program, uniformIndices.size(), uniformIndices.data(), pname, result.data());
2743
#else
2744
    UNUSED_PARAM(program);
2745
    UNUSED_PARAM(pname);
2746
#endif
2747
    return result;
2748
}
2749
2750
GCGLuint GraphicsContextGLOpenGL::getUniformBlockIndex(PlatformGLObject program, const String& uniformBlockName)
2751
{
2752
    UNUSED_PARAM(program);
2753
    UNUSED_PARAM(uniformBlockName);
2754
    return 0;
2755
}
2756
2757
String GraphicsContextGLOpenGL::getActiveUniformBlockName(PlatformGLObject program, GCGLuint uniformBlockIndex)
2758
{
2759
    UNUSED_PARAM(program);
2760
    UNUSED_PARAM(uniformBlockIndex);
2761
    return emptyString();
2762
}
2763
2764
void GraphicsContextGLOpenGL::uniformBlockBinding(PlatformGLObject program, GCGLuint uniformBlockIndex, GCGLuint uniformBlockBinding)
2765
{
2766
    UNUSED_PARAM(program);
2767
    UNUSED_PARAM(uniformBlockIndex);
2768
    UNUSED_PARAM(uniformBlockBinding);
2769
}
2770
2771
void GraphicsContextGLOpenGL::readnPixels(GCGLint x, GCGLint y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLintptr offset)
2772
{
2773
    UNUSED_PARAM(x);
2774
    UNUSED_PARAM(y);
2775
    UNUSED_PARAM(width);
2776
    UNUSED_PARAM(height);
2777
    UNUSED_PARAM(format);
2778
    UNUSED_PARAM(type);
2779
    UNUSED_PARAM(offset);
2780
}
2781
2782
void GraphicsContextGLOpenGL::getActiveUniformBlockiv(GCGLuint program, GCGLuint uniformBlockIndex, GCGLenum pname, GCGLSpan<GCGLint> params)
2783
{
2784
    UNUSED_PARAM(program);
2785
    UNUSED_PARAM(uniformBlockIndex);
2786
    UNUSED_PARAM(pname);
2787
    UNUSED_PARAM(params);
2788
}
2789
2790
void GraphicsContextGLOpenGL::texImage2D(GCGLenum, GCGLint, GCGLenum, GCGLsizei, GCGLsizei, GCGLint, GCGLenum, GCGLenum , GCGLintptr)
2791
{
2792
}
2793
2794
void GraphicsContextGLOpenGL::texSubImage2D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLenum, GCGLenum, GCGLintptr)
2795
{
2796
}
2797
2798
void GraphicsContextGLOpenGL::compressedTexImage2D(GCGLenum, GCGLint, GCGLenum, GCGLsizei, GCGLsizei, GCGLint, GCGLsizei, GCGLintptr)
2799
{
2800
}
2801
2802
void GraphicsContextGLOpenGL::compressedTexSubImage2D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLenum, GCGLsizei, GCGLintptr)
2803
{
2804
}
2805
2806
void GraphicsContextGLOpenGL::texImage3D(GCGLenum, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLint, GCGLenum, GCGLenum, GCGLSpan<const GCGLvoid>)
2807
{
2808
}
2809
2810
void GraphicsContextGLOpenGL::texImage3D(GCGLenum, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLint, GCGLenum, GCGLenum, GCGLintptr)
2811
{
2812
}
2813
2814
void GraphicsContextGLOpenGL::texSubImage3D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLenum, GCGLenum, GCGLSpan<const GCGLvoid>)
2815
{
2816
}
2817
2818
void GraphicsContextGLOpenGL::texSubImage3D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLenum, GCGLenum, GCGLintptr)
2819
{
2820
}
2821
2822
void GraphicsContextGLOpenGL::compressedTexImage3D(GCGLenum, GCGLint, GCGLenum, GCGLsizei, GCGLsizei, GCGLsizei, GCGLint, GCGLsizei, GCGLSpan<const GCGLvoid>)
2823
{
2824
}
2825
2826
void GraphicsContextGLOpenGL::compressedTexImage3D(GCGLenum, GCGLint, GCGLenum, GCGLsizei, GCGLsizei, GCGLsizei, GCGLint, GCGLsizei, GCGLintptr)
2827
{
2828
}
2829
2830
void GraphicsContextGLOpenGL::compressedTexSubImage3D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLenum, GCGLsizei, GCGLSpan<const GCGLvoid>)
2831
{
2832
}
2833
2834
void GraphicsContextGLOpenGL::compressedTexSubImage3D(GCGLenum, GCGLint, GCGLint, GCGLint, GCGLint, GCGLsizei, GCGLsizei, GCGLsizei, GCGLenum, GCGLsizei, GCGLintptr)
2835
{
2836
}
2837
2838
void GraphicsContextGLOpenGL::multiDrawArraysANGLE(GCGLenum, GCGLSpan<const GCGLint>, GCGLSpan<const GCGLsizei>, GCGLsizei)
2839
{
2840
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2841
}
2842
2843
void GraphicsContextGLOpenGL::multiDrawArraysInstancedANGLE(GCGLenum, GCGLSpan<const GCGLint>, GCGLSpan<const GCGLsizei>, GCGLSpan<const GCGLsizei>, GCGLsizei)
2844
{
2845
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2846
}
2847
2848
void GraphicsContextGLOpenGL::multiDrawElementsANGLE(GCGLenum, GCGLSpan<const GCGLsizei>, GCGLenum, GCGLSpan<const GCGLint>, GCGLsizei)
2849
{
2850
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2851
}
2852
2853
void GraphicsContextGLOpenGL::multiDrawElementsInstancedANGLE(GCGLenum, GCGLSpan<const GCGLsizei>, GCGLenum, GCGLSpan<const GCGLint>, GCGLSpan<const GCGLsizei>, GCGLsizei)
2854
{
2855
    synthesizeGLError(GraphicsContextGL::INVALID_OPERATION);
2856
}
2857
2858
bool GraphicsContextGLOpenGL::texImage2DResourceSafe(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLint unpackAlignment)
2859
{
2860
    ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8);
2861
    UniqueArray<unsigned char> zero;
2862
    unsigned size = 0;
2863
    if (width > 0 && height > 0) {
2864
        PixelStoreParams params;
2865
        params.alignment = unpackAlignment;
2866
        GCGLenum error = computeImageSizeInBytes(format, type, width, height, 1, params, &size, nullptr, nullptr);
2867
        if (error != GraphicsContextGL::NO_ERROR) {
2868
            synthesizeGLError(error);
2869
            return false;
2870
        }
2871
        zero = makeUniqueArray<unsigned char>(size);
2872
        if (!zero) {
2873
            synthesizeGLError(GraphicsContextGL::INVALID_VALUE);
2874
            return false;
2875
        }
2876
        memset(zero.get(), 0, size);
2877
    }
2878
    texImage2D(target, level, internalformat, width, height, border, format, type, makeGCGLSpan(zero.get(), size));
2879
    return true;
2880
}
2881
2882
}
2883
2884
#endif // ENABLE(WEBGL) && !USE(ANGLE)
- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp -3 / +7 lines
Lines 28-36 a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp_sec1
28
#if ENABLE(WEBGL)
28
#if ENABLE(WEBGL)
29
#include "GraphicsContextGLOpenGLManager.h"
29
#include "GraphicsContextGLOpenGLManager.h"
30
30
31
#include "GraphicsContextGLOpenGL.h"
32
#include "Logging.h"
31
#include "Logging.h"
33
32
33
#if USE(ANGLE)
34
#include "GraphicsContextGLANGLE.h"
35
#else
36
#include "GraphicsContextGLOpenGL.h"
37
#endif
34
namespace WebCore {
38
namespace WebCore {
35
39
36
GraphicsContextGLOpenGLManager& GraphicsContextGLOpenGLManager::sharedManager()
40
GraphicsContextGLOpenGLManager& GraphicsContextGLOpenGLManager::sharedManager()
Lines 56-62 void GraphicsContextGLOpenGLManager::displayWasReconfigured() a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp_sec2
56
}
60
}
57
#endif
61
#endif
58
62
59
void GraphicsContextGLOpenGLManager::addContext(GraphicsContextGLOpenGL* context)
63
void GraphicsContextGLOpenGLManager::addContext(PlatformGraphicsContextGL* context)
60
{
64
{
61
    ASSERT(context);
65
    ASSERT(context);
62
    if (!context)
66
    if (!context)
Lines 66-72 void GraphicsContextGLOpenGLManager::addContext(GraphicsContextGLOpenGL* context a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp_sec3
66
    m_contexts.append(context);
70
    m_contexts.append(context);
67
}
71
}
68
72
69
void GraphicsContextGLOpenGLManager::removeContext(GraphicsContextGLOpenGL* context)
73
void GraphicsContextGLOpenGLManager::removeContext(PlatformGraphicsContextGL* context)
70
{
74
{
71
    if (!m_contexts.contains(context))
75
    if (!m_contexts.contains(context))
72
        return;
76
        return;
- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h -3 / +13 lines
Lines 36-50 namespace WebCore { a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h_sec1
36
36
37
const unsigned MaxContexts = 16;
37
const unsigned MaxContexts = 16;
38
38
39
#if USE(ANGLE)
40
class GraphicsContextGLANGLE;
41
#else
39
class GraphicsContextGLOpenGL;
42
class GraphicsContextGLOpenGL;
43
#endif
40
44
41
class GraphicsContextGLOpenGLManager {
45
class GraphicsContextGLOpenGLManager {
42
    friend NeverDestroyed<GraphicsContextGLOpenGLManager>;
46
    friend NeverDestroyed<GraphicsContextGLOpenGLManager>;
43
public:
47
public:
48
#if USE(ANGLE)
49
    using PlatformGraphicsContextGL = GraphicsContextGLANGLE;
50
#else
51
    using PlatformGraphicsContextGL = GraphicsContextGLOpenGL;
52
#endif
53
44
    static GraphicsContextGLOpenGLManager& sharedManager();
54
    static GraphicsContextGLOpenGLManager& sharedManager();
45
    
55
    
46
    void addContext(GraphicsContextGLOpenGL*);
56
    void addContext(PlatformGraphicsContextGL*);
47
    void removeContext(GraphicsContextGLOpenGL*);
57
    void removeContext(PlatformGraphicsContextGL*);
48
    
58
    
49
    void recycleContextIfNecessary();
59
    void recycleContextIfNecessary();
50
    bool hasTooManyContexts() const { return m_contexts.size() >= MaxContexts; }
60
    bool hasTooManyContexts() const { return m_contexts.size() >= MaxContexts; }
Lines 59-65 public: a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h_sec2
59
private:
69
private:
60
    GraphicsContextGLOpenGLManager() = default;
70
    GraphicsContextGLOpenGLManager() = default;
61
71
62
    Vector<GraphicsContextGLOpenGL*> m_contexts;
72
    Vector<PlatformGraphicsContextGL*> m_contexts;
63
};
73
};
64
74
65
}
75
}
- a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp -4 / +7 lines
Lines 92-98 GraphicsContextGLTextureMapper::GraphicsContextGLTextureMapper(GraphicsContextGL a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp_sec1
92
{
92
{
93
}
93
}
94
94
95
// FIXME: Below functionality should be moved to GraphicsContextGLTextureMapper to simplify the base class.
96
95
97
RefPtr<GraphicsContextGL> createWebProcessGraphicsContextGL(const GraphicsContextGLAttributes& attributes)
96
RefPtr<GraphicsContextGL> createWebProcessGraphicsContextGL(const GraphicsContextGLAttributes& attributes)
98
{
97
{
Lines 126-131 RefPtr<GraphicsContextGL> createWebProcessGraphicsContextGL(const GraphicsContex a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp_sec2
126
    return context;
125
    return context;
127
}
126
}
128
127
128
// FIXME: Below functionality should be moved to GraphicsContextGLTextureMapper to simplify the base class.
129
129
#if USE(ANGLE)
130
#if USE(ANGLE)
130
GraphicsContextGLOpenGL::GraphicsContextGLOpenGL(GraphicsContextGLAttributes attributes)
131
GraphicsContextGLOpenGL::GraphicsContextGLOpenGL(GraphicsContextGLAttributes attributes)
131
    : GraphicsContextGL(attributes)
132
    : GraphicsContextGL(attributes)
Lines 422-437 void GraphicsContextGLOpenGL::checkGPUStatus() a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp_sec3
422
{
423
{
423
}
424
}
424
425
426
#if !USE(ANGLE)
425
bool GraphicsContextGLOpenGL::isGLES2Compliant() const
427
bool GraphicsContextGLOpenGL::isGLES2Compliant() const
426
{
428
{
427
#if USE(ANGLE)
429
#if USE(OPENGL_ES)
428
    return m_isForWebGL2;
429
#elif USE(OPENGL_ES)
430
    return true;
430
    return true;
431
#else
431
#else
432
    return false;
432
    return false;
433
#endif
433
#endif
434
}
434
}
435
#endif
435
436
436
PlatformLayer* GraphicsContextGLOpenGL::platformLayer() const
437
PlatformLayer* GraphicsContextGLOpenGL::platformLayer() const
437
{
438
{
Lines 462-472 void GraphicsContextGLOpenGL::setContextVisibility(bool) a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp_sec4
462
{
463
{
463
}
464
}
464
465
466
#if !USE(ANGLE)
465
void GraphicsContextGLOpenGL::simulateEventForTesting(SimulatedEventForTesting event)
467
void GraphicsContextGLOpenGL::simulateEventForTesting(SimulatedEventForTesting event)
466
{
468
{
467
    if (event == SimulatedEventForTesting::GPUStatusFailure)
469
    if (event == SimulatedEventForTesting::GPUStatusFailure)
468
        m_failNextStatusCheck = true;
470
        m_failNextStatusCheck = true;
469
}
471
}
472
#endif
470
473
471
void GraphicsContextGLOpenGL::prepareForDisplay()
474
void GraphicsContextGLOpenGL::prepareForDisplay()
472
{
475
{
- a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h -1 / +11 lines
Lines 27-41 a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h_sec1
27
27
28
#if ENABLE(WEBGL)
28
#if ENABLE(WEBGL)
29
29
30
#if USE(ANGLE)
31
#include "GraphicsContextGLANGLE.h"
32
#else
30
#include "GraphicsContextGLOpenGL.h"
33
#include "GraphicsContextGLOpenGL.h"
34
#endif
31
35
32
namespace WebCore {
36
namespace WebCore {
33
37
34
class WEBCORE_EXPORT GraphicsContextGLTextureMapper : public GraphicsContextGLOpenGL {
38
#if USE(ANGLE)
39
using GraphicsContextGLTextureMapperBase = GraphicsContextGLANGLE;
40
#else
41
using GraphicsContextGLTextureMapperBase = GraphicsContextGLOpenGL;
42
43
class WEBCORE_EXPORT GraphicsContextGLTextureMapper : public GraphicsContextGLTextureMapperBase {
35
public:
44
public:
36
    static RefPtr<GraphicsContextGLTextureMapper> create(WebCore::GraphicsContextGLAttributes&&);
45
    static RefPtr<GraphicsContextGLTextureMapper> create(WebCore::GraphicsContextGLAttributes&&);
37
    ~GraphicsContextGLTextureMapper();
46
    ~GraphicsContextGLTextureMapper();
38
47
48
    // GraphicsContextGLTextureMapperBase overrides.
39
#if ENABLE(VIDEO)
49
#if ENABLE(VIDEO)
40
    bool copyTextureFromMedia(MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
50
    bool copyTextureFromMedia(MediaPlayer&, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;
41
#endif
51
#endif
- a/Source/WebCore/platform/graphics/win/GraphicsContextGLDirect2D.cpp -1 / +1 lines
Lines 48-54 bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i a/Source/WebCore/platform/graphics/win/GraphicsContextGLDirect2D.cpp_sec1
48
    return true;
48
    return true;
49
}
49
}
50
50
51
void GraphicsContextGLOpenGL::paintToCanvas(const unsigned char* imagePixels, const IntSize& imageSize, const IntSize& canvasSize, GraphicsContext& context)
51
void GraphicsContextGLGL::paintToCanvas(const unsigned char* imagePixels, const IntSize& imageSize, const IntSize& canvasSize, GraphicsContext& context)
52
{
52
{
53
    if (!imagePixels || imageSize.isEmpty() || canvasSize.isEmpty())
53
    if (!imagePixels || imageSize.isEmpty() || canvasSize.isEmpty())
54
        return;
54
        return;
- a/Source/WebCore/platform/ios/wak/WebCoreThread.mm -3 / +3 lines
Lines 30-36 a/Source/WebCore/platform/ios/wak/WebCoreThread.mm_sec1
30
30
31
#import "CommonVM.h"
31
#import "CommonVM.h"
32
#import "FloatingPointEnvironment.h"
32
#import "FloatingPointEnvironment.h"
33
#import "GraphicsContextGLOpenGL.h"
33
#import "GraphicsContextGLANGLE.h"
34
#import "Logging.h"
34
#import "Logging.h"
35
#import "RuntimeApplicationChecks.h"
35
#import "RuntimeApplicationChecks.h"
36
#import "ThreadGlobalData.h"
36
#import "ThreadGlobalData.h"
Lines 77-89 void ReleaseWebThreadGlobalState() a/Source/WebCore/platform/ios/wak/WebCoreThread.mm_sec2
77
    // In single-threaded environments we do not need to unset the context, as there should not be access from
77
    // In single-threaded environments we do not need to unset the context, as there should not be access from
78
    // multiple threads.
78
    // multiple threads.
79
    ASSERT(WebThreadIsEnabled());
79
    ASSERT(WebThreadIsEnabled());
80
    using ReleaseThreadResourceBehavior = WebCore::GraphicsContextGLOpenGL::ReleaseThreadResourceBehavior;
80
    using ReleaseThreadResourceBehavior = WebCore::GraphicsContextGLANGLE::ReleaseThreadResourceBehavior;
81
    // For web thread, just release the context as we know we will see calls to it again.
81
    // For web thread, just release the context as we know we will see calls to it again.
82
    // For non-web threads, e.g. third-party client threads, we don't know if we ever see another call from the
82
    // For non-web threads, e.g. third-party client threads, we don't know if we ever see another call from the
83
    // thread, so we also release the thread resources.
83
    // thread, so we also release the thread resources.
84
    ReleaseThreadResourceBehavior releaseBehavior =
84
    ReleaseThreadResourceBehavior releaseBehavior =
85
        WebThreadIsCurrent() ? ReleaseThreadResourceBehavior::ReleaseCurrentContext : ReleaseThreadResourceBehavior::ReleaseThreadResources;
85
        WebThreadIsCurrent() ? ReleaseThreadResourceBehavior::ReleaseCurrentContext : ReleaseThreadResourceBehavior::ReleaseThreadResources;
86
    WebCore::GraphicsContextGLOpenGL::releaseThreadResources(releaseBehavior);
86
    WebCore::GraphicsContextGLANGLE::releaseThreadResources(releaseBehavior);
87
}
87
}
88
88
89
}
89
}
- a/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp -1 / +1 lines
Lines 236-242 void RemoteGraphicsContextGL::paintPixelBufferToImageBuffer(std::optional<WebCor a/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp_sec1
236
            // Here we do not try to play back pending commands for imageBuffer. Currently this call is only made for empty
236
            // Here we do not try to play back pending commands for imageBuffer. Currently this call is only made for empty
237
            // image buffers and there's no good way to add display lists.
237
            // image buffers and there's no good way to add display lists.
238
            if (pixelBuffer)
238
            if (pixelBuffer)
239
                GraphicsContextGLOpenGL::paintToCanvas(contextAttributes, WTFMove(*pixelBuffer), imageBuffer->backendSize(), imageBuffer->context());
239
                GraphicsContextGL::paintToCanvas(contextAttributes, WTFMove(*pixelBuffer), imageBuffer->backendSize(), imageBuffer->context());
240
            else
240
            else
241
                imageBuffer->context().clearRect({ IntPoint(), imageBuffer->backendSize() });
241
                imageBuffer->context().clearRect({ IntPoint(), imageBuffer->backendSize() });
242
            // Unfortunately "flush" implementation in RemoteRenderingBackend overloads ordering and effects.
242
            // Unfortunately "flush" implementation in RemoteRenderingBackend overloads ordering and effects.
- a/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp -2 / +2 lines
Lines 30-36 a/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp_sec1
30
30
31
#include "RemoteGraphicsContextGL.h"
31
#include "RemoteGraphicsContextGL.h"
32
#include "StreamConnectionWorkQueue.h"
32
#include "StreamConnectionWorkQueue.h"
33
#include <WebCore/GraphicsContextGL.h>
33
#include <WebCore/GraphicsContextGLANGLE.h>
34
#include <wtf/RunLoop.h>
34
#include <wtf/RunLoop.h>
35
#include <wtf/Seconds.h>
35
#include <wtf/Seconds.h>
36
36
Lines 56-62 void ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources() a/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp_sec2
56
    if (s_requests)
56
    if (s_requests)
57
        return;
57
        return;
58
    remoteGraphicsContextGLStreamWorkQueue().dispatch([] {
58
    remoteGraphicsContextGLStreamWorkQueue().dispatch([] {
59
        WebCore::GraphicsContextGLOpenGL::releaseThreadResources(WebCore::GraphicsContextGLOpenGL::ReleaseThreadResourceBehavior::TerminateAndReleaseThreadResources);
59
        WebCore::GraphicsContextGLANGLE::releaseThreadResources(WebCore::GraphicsContextGLANGLE::ReleaseThreadResourceBehavior::TerminateAndReleaseThreadResources);
60
    });
60
    });
61
}
61
}
62
62
- a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h -1 lines
Lines 253-259 private: a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h_sec1
253
    RefPtr<WebCore::GraphicsContextGL> createGraphicsContextGL(const WebCore::GraphicsContextGLAttributes&, WebCore::PlatformDisplayID hostWindowDisplayID) const final;
253
    RefPtr<WebCore::GraphicsContextGL> createGraphicsContextGL(const WebCore::GraphicsContextGLAttributes&, WebCore::PlatformDisplayID hostWindowDisplayID) const final;
254
#endif
254
#endif
255
255
256
257
    CompositingTriggerFlags allowedCompositingTriggers() const final
256
    CompositingTriggerFlags allowedCompositingTriggers() const final
258
    {
257
    {
259
        return static_cast<CompositingTriggerFlags>(
258
        return static_cast<CompositingTriggerFlags>(

Return to Bug 233522