[WebGL] Add a pure virtual base class for GraphicsContext3D
[WebKit-https.git] / Source / WebCore / platform / graphics / GraphicsContext3DBase.h
1 /*
2  * Copyright (C) 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 "GraphicsContext3DAttributes.h"
31 #include "GraphicsTypes3D.h"
32 #include "Image.h"
33 #include "IntRect.h"
34 #include "IntSize.h"
35 #include "PlatformLayer.h"
36 #include <wtf/RefCounted.h>
37 #include <wtf/text/WTFString.h>
38
39 typedef void* PlatformGraphicsContext3D;
40 typedef void* PlatformGraphicsContext3DDisplay;
41 typedef void* PlatformGraphicsContext3DSurface;
42 typedef void* PlatformGraphicsContext3DConfig;
43
44 namespace WebCore {
45 class Extensions3D;
46 class HostWindow;
47 class ImageBuffer;
48 class ImageData;
49
50 class GraphicsContext3DBase : public RefCounted<GraphicsContext3DBase> {
51 public:
52     enum {
53         // WebGL 1 constants.
54         DEPTH_BUFFER_BIT = 0x00000100,
55         STENCIL_BUFFER_BIT = 0x00000400,
56         COLOR_BUFFER_BIT = 0x00004000,
57         POINTS = 0x0000,
58         LINES = 0x0001,
59         LINE_LOOP = 0x0002,
60         LINE_STRIP = 0x0003,
61         TRIANGLES = 0x0004,
62         TRIANGLE_STRIP = 0x0005,
63         TRIANGLE_FAN = 0x0006,
64         ZERO = 0,
65         ONE = 1,
66         SRC_COLOR = 0x0300,
67         ONE_MINUS_SRC_COLOR = 0x0301,
68         SRC_ALPHA = 0x0302,
69         ONE_MINUS_SRC_ALPHA = 0x0303,
70         DST_ALPHA = 0x0304,
71         ONE_MINUS_DST_ALPHA = 0x0305,
72         DST_COLOR = 0x0306,
73         ONE_MINUS_DST_COLOR = 0x0307,
74         SRC_ALPHA_SATURATE = 0x0308,
75         FUNC_ADD = 0x8006,
76         BLEND_EQUATION = 0x8009,
77         BLEND_EQUATION_RGB = 0x8009,
78         BLEND_EQUATION_ALPHA = 0x883D,
79         FUNC_SUBTRACT = 0x800A,
80         FUNC_REVERSE_SUBTRACT = 0x800B,
81         BLEND_DST_RGB = 0x80C8,
82         BLEND_SRC_RGB = 0x80C9,
83         BLEND_DST_ALPHA = 0x80CA,
84         BLEND_SRC_ALPHA = 0x80CB,
85         CONSTANT_COLOR = 0x8001,
86         ONE_MINUS_CONSTANT_COLOR = 0x8002,
87         CONSTANT_ALPHA = 0x8003,
88         ONE_MINUS_CONSTANT_ALPHA = 0x8004,
89         BLEND_COLOR = 0x8005,
90         ARRAY_BUFFER = 0x8892,
91         ELEMENT_ARRAY_BUFFER = 0x8893,
92         ARRAY_BUFFER_BINDING = 0x8894,
93         ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
94         STREAM_DRAW = 0x88E0,
95         STATIC_DRAW = 0x88E4,
96         DYNAMIC_DRAW = 0x88E8,
97         BUFFER_SIZE = 0x8764,
98         BUFFER_USAGE = 0x8765,
99         CURRENT_VERTEX_ATTRIB = 0x8626,
100         FRONT = 0x0404,
101         BACK = 0x0405,
102         FRONT_AND_BACK = 0x0408,
103         TEXTURE_2D = 0x0DE1,
104         CULL_FACE = 0x0B44,
105         BLEND = 0x0BE2,
106         DITHER = 0x0BD0,
107         STENCIL_TEST = 0x0B90,
108         DEPTH_TEST = 0x0B71,
109         SCISSOR_TEST = 0x0C11,
110         POLYGON_OFFSET_FILL = 0x8037,
111         SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
112         SAMPLE_COVERAGE = 0x80A0,
113         NO_ERROR = 0,
114         INVALID_ENUM = 0x0500,
115         INVALID_VALUE = 0x0501,
116         INVALID_OPERATION = 0x0502,
117         OUT_OF_MEMORY = 0x0505,
118         CW = 0x0900,
119         CCW = 0x0901,
120         LINE_WIDTH = 0x0B21,
121         ALIASED_POINT_SIZE_RANGE = 0x846D,
122         ALIASED_LINE_WIDTH_RANGE = 0x846E,
123         CULL_FACE_MODE = 0x0B45,
124         FRONT_FACE = 0x0B46,
125         DEPTH_RANGE = 0x0B70,
126         DEPTH_WRITEMASK = 0x0B72,
127         DEPTH_CLEAR_VALUE = 0x0B73,
128         DEPTH_FUNC = 0x0B74,
129         STENCIL_CLEAR_VALUE = 0x0B91,
130         STENCIL_FUNC = 0x0B92,
131         STENCIL_FAIL = 0x0B94,
132         STENCIL_PASS_DEPTH_FAIL = 0x0B95,
133         STENCIL_PASS_DEPTH_PASS = 0x0B96,
134         STENCIL_REF = 0x0B97,
135         STENCIL_VALUE_MASK = 0x0B93,
136         STENCIL_WRITEMASK = 0x0B98,
137         STENCIL_BACK_FUNC = 0x8800,
138         STENCIL_BACK_FAIL = 0x8801,
139         STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
140         STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
141         STENCIL_BACK_REF = 0x8CA3,
142         STENCIL_BACK_VALUE_MASK = 0x8CA4,
143         STENCIL_BACK_WRITEMASK = 0x8CA5,
144         VIEWPORT = 0x0BA2,
145         SCISSOR_BOX = 0x0C10,
146         COLOR_CLEAR_VALUE = 0x0C22,
147         COLOR_WRITEMASK = 0x0C23,
148         UNPACK_ALIGNMENT = 0x0CF5,
149         PACK_ALIGNMENT = 0x0D05,
150         MAX_TEXTURE_SIZE = 0x0D33,
151         MAX_VIEWPORT_DIMS = 0x0D3A,
152         SUBPIXEL_BITS = 0x0D50,
153         RED_BITS = 0x0D52,
154         GREEN_BITS = 0x0D53,
155         BLUE_BITS = 0x0D54,
156         ALPHA_BITS = 0x0D55,
157         DEPTH_BITS = 0x0D56,
158         STENCIL_BITS = 0x0D57,
159         POLYGON_OFFSET_UNITS = 0x2A00,
160         POLYGON_OFFSET_FACTOR = 0x8038,
161         TEXTURE_BINDING_2D = 0x8069,
162         SAMPLE_BUFFERS = 0x80A8,
163         SAMPLES = 0x80A9,
164         SAMPLE_COVERAGE_VALUE = 0x80AA,
165         SAMPLE_COVERAGE_INVERT = 0x80AB,
166         NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2,
167         COMPRESSED_TEXTURE_FORMATS = 0x86A3,
168         DONT_CARE = 0x1100,
169         FASTEST = 0x1101,
170         NICEST = 0x1102,
171         GENERATE_MIPMAP_HINT = 0x8192,
172         BYTE = 0x1400,
173         UNSIGNED_BYTE = 0x1401,
174         SHORT = 0x1402,
175         UNSIGNED_SHORT = 0x1403,
176         INT = 0x1404,
177         UNSIGNED_INT = 0x1405,
178         FLOAT = 0x1406,
179         HALF_FLOAT_OES = 0x8D61,
180         FIXED = 0x140C,
181         DEPTH_COMPONENT = 0x1902,
182         ALPHA = 0x1906,
183         RGB = 0x1907,
184         RGBA = 0x1908,
185         BGRA = 0x80E1,
186         LUMINANCE = 0x1909,
187         LUMINANCE_ALPHA = 0x190A,
188         UNSIGNED_SHORT_4_4_4_4 = 0x8033,
189         UNSIGNED_SHORT_5_5_5_1 = 0x8034,
190         UNSIGNED_SHORT_5_6_5 = 0x8363,
191         FRAGMENT_SHADER = 0x8B30,
192         VERTEX_SHADER = 0x8B31,
193         MAX_VERTEX_ATTRIBS = 0x8869,
194         MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
195         MAX_VARYING_VECTORS = 0x8DFC,
196         MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D,
197         MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C,
198         MAX_TEXTURE_IMAGE_UNITS = 0x8872,
199         MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
200         SHADER_TYPE = 0x8B4F,
201         DELETE_STATUS = 0x8B80,
202         LINK_STATUS = 0x8B82,
203         VALIDATE_STATUS = 0x8B83,
204         ATTACHED_SHADERS = 0x8B85,
205         ACTIVE_UNIFORMS = 0x8B86,
206         ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
207         ACTIVE_ATTRIBUTES = 0x8B89,
208         ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
209         SHADING_LANGUAGE_VERSION = 0x8B8C,
210         CURRENT_PROGRAM = 0x8B8D,
211         NEVER = 0x0200,
212         LESS = 0x0201,
213         EQUAL = 0x0202,
214         LEQUAL = 0x0203,
215         GREATER = 0x0204,
216         NOTEQUAL = 0x0205,
217         GEQUAL = 0x0206,
218         ALWAYS = 0x0207,
219         KEEP = 0x1E00,
220         REPLACE = 0x1E01,
221         INCR = 0x1E02,
222         DECR = 0x1E03,
223         INVERT = 0x150A,
224         INCR_WRAP = 0x8507,
225         DECR_WRAP = 0x8508,
226         VENDOR = 0x1F00,
227         RENDERER = 0x1F01,
228         VERSION = 0x1F02,
229         EXTENSIONS = 0x1F03,
230         NEAREST = 0x2600,
231         LINEAR = 0x2601,
232         NEAREST_MIPMAP_NEAREST = 0x2700,
233         LINEAR_MIPMAP_NEAREST = 0x2701,
234         NEAREST_MIPMAP_LINEAR = 0x2702,
235         LINEAR_MIPMAP_LINEAR = 0x2703,
236         TEXTURE_MAG_FILTER = 0x2800,
237         TEXTURE_MIN_FILTER = 0x2801,
238         TEXTURE_WRAP_S = 0x2802,
239         TEXTURE_WRAP_T = 0x2803,
240         TEXTURE = 0x1702,
241         TEXTURE_CUBE_MAP = 0x8513,
242         TEXTURE_BINDING_CUBE_MAP = 0x8514,
243         TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
244         TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
245         TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
246         TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
247         TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
248         TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A,
249         MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C,
250         TEXTURE0 = 0x84C0,
251         TEXTURE1 = 0x84C1,
252         TEXTURE2 = 0x84C2,
253         TEXTURE3 = 0x84C3,
254         TEXTURE4 = 0x84C4,
255         TEXTURE5 = 0x84C5,
256         TEXTURE6 = 0x84C6,
257         TEXTURE7 = 0x84C7,
258         TEXTURE8 = 0x84C8,
259         TEXTURE9 = 0x84C9,
260         TEXTURE10 = 0x84CA,
261         TEXTURE11 = 0x84CB,
262         TEXTURE12 = 0x84CC,
263         TEXTURE13 = 0x84CD,
264         TEXTURE14 = 0x84CE,
265         TEXTURE15 = 0x84CF,
266         TEXTURE16 = 0x84D0,
267         TEXTURE17 = 0x84D1,
268         TEXTURE18 = 0x84D2,
269         TEXTURE19 = 0x84D3,
270         TEXTURE20 = 0x84D4,
271         TEXTURE21 = 0x84D5,
272         TEXTURE22 = 0x84D6,
273         TEXTURE23 = 0x84D7,
274         TEXTURE24 = 0x84D8,
275         TEXTURE25 = 0x84D9,
276         TEXTURE26 = 0x84DA,
277         TEXTURE27 = 0x84DB,
278         TEXTURE28 = 0x84DC,
279         TEXTURE29 = 0x84DD,
280         TEXTURE30 = 0x84DE,
281         TEXTURE31 = 0x84DF,
282         ACTIVE_TEXTURE = 0x84E0,
283         REPEAT = 0x2901,
284         CLAMP_TO_EDGE = 0x812F,
285         MIRRORED_REPEAT = 0x8370,
286         FLOAT_VEC2 = 0x8B50,
287         FLOAT_VEC3 = 0x8B51,
288         FLOAT_VEC4 = 0x8B52,
289         INT_VEC2 = 0x8B53,
290         INT_VEC3 = 0x8B54,
291         INT_VEC4 = 0x8B55,
292         BOOL = 0x8B56,
293         BOOL_VEC2 = 0x8B57,
294         BOOL_VEC3 = 0x8B58,
295         BOOL_VEC4 = 0x8B59,
296         FLOAT_MAT2 = 0x8B5A,
297         FLOAT_MAT3 = 0x8B5B,
298         FLOAT_MAT4 = 0x8B5C,
299         SAMPLER_2D = 0x8B5E,
300         SAMPLER_CUBE = 0x8B60,
301         VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622,
302         VERTEX_ATTRIB_ARRAY_SIZE = 0x8623,
303         VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624,
304         VERTEX_ATTRIB_ARRAY_TYPE = 0x8625,
305         VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A,
306         VERTEX_ATTRIB_ARRAY_POINTER = 0x8645,
307         VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F,
308         IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
309         IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B,
310         COMPILE_STATUS = 0x8B81,
311         INFO_LOG_LENGTH = 0x8B84,
312         SHADER_SOURCE_LENGTH = 0x8B88,
313         SHADER_COMPILER = 0x8DFA,
314         SHADER_BINARY_FORMATS = 0x8DF8,
315         NUM_SHADER_BINARY_FORMATS = 0x8DF9,
316         LOW_FLOAT = 0x8DF0,
317         MEDIUM_FLOAT = 0x8DF1,
318         HIGH_FLOAT = 0x8DF2,
319         LOW_INT = 0x8DF3,
320         MEDIUM_INT = 0x8DF4,
321         HIGH_INT = 0x8DF5,
322         FRAMEBUFFER = 0x8D40,
323         RENDERBUFFER = 0x8D41,
324         RGBA4 = 0x8056,
325         RGB5_A1 = 0x8057,
326         RGB565 = 0x8D62,
327         DEPTH_COMPONENT16 = 0x81A5,
328         STENCIL_INDEX = 0x1901,
329         STENCIL_INDEX8 = 0x8D48,
330         RENDERBUFFER_WIDTH = 0x8D42,
331         RENDERBUFFER_HEIGHT = 0x8D43,
332         RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
333         RENDERBUFFER_RED_SIZE = 0x8D50,
334         RENDERBUFFER_GREEN_SIZE = 0x8D51,
335         RENDERBUFFER_BLUE_SIZE = 0x8D52,
336         RENDERBUFFER_ALPHA_SIZE = 0x8D53,
337         RENDERBUFFER_DEPTH_SIZE = 0x8D54,
338         RENDERBUFFER_STENCIL_SIZE = 0x8D55,
339         FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0,
340         FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1,
341         FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2,
342         FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3,
343         COLOR_ATTACHMENT0 = 0x8CE0,
344         DEPTH_ATTACHMENT = 0x8D00,
345         STENCIL_ATTACHMENT = 0x8D20,
346         NONE = 0,
347         FRAMEBUFFER_COMPLETE = 0x8CD5,
348         FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
349         FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7,
350         FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9,
351         FRAMEBUFFER_UNSUPPORTED = 0x8CDD,
352         FRAMEBUFFER_BINDING = 0x8CA6,
353         RENDERBUFFER_BINDING = 0x8CA7,
354         MAX_RENDERBUFFER_SIZE = 0x84E8,
355         INVALID_FRAMEBUFFER_OPERATION = 0x0506,
356
357         // WebGL-specific enums
358         UNPACK_FLIP_Y_WEBGL = 0x9240,
359         UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241,
360         CONTEXT_LOST_WEBGL = 0x9242,
361         UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243,
362         BROWSER_DEFAULT_WEBGL = 0x9244,
363         VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE,
364         
365         // WebGL2 constants
366         READ_BUFFER = 0x0C02,
367         UNPACK_ROW_LENGTH = 0x0CF2,
368         UNPACK_SKIP_ROWS = 0x0CF3,
369         UNPACK_SKIP_PIXELS = 0x0CF4,
370         PACK_ROW_LENGTH = 0x0D02,
371         PACK_SKIP_ROWS = 0x0D03,
372         PACK_SKIP_PIXELS = 0x0D04,
373         COLOR = 0x1800,
374         DEPTH = 0x1801,
375         STENCIL = 0x1802,
376         RED = 0x1903,
377         RGB8 = 0x8051,
378         RGBA8 = 0x8058,
379         RGB10_A2 = 0x8059,
380         TEXTURE_BINDING_3D = 0x806A,
381         UNPACK_SKIP_IMAGES = 0x806D,
382         UNPACK_IMAGE_HEIGHT = 0x806E,
383         TEXTURE_3D = 0x806F,
384         TEXTURE_WRAP_R = 0x8072,
385         MAX_3D_TEXTURE_SIZE = 0x8073,
386         UNSIGNED_INT_2_10_10_10_REV = 0x8368,
387         MAX_ELEMENTS_VERTICES = 0x80E8,
388         MAX_ELEMENTS_INDICES = 0x80E9,
389         TEXTURE_MIN_LOD = 0x813A,
390         TEXTURE_MAX_LOD = 0x813B,
391         TEXTURE_BASE_LEVEL = 0x813C,
392         TEXTURE_MAX_LEVEL = 0x813D,
393         MIN = 0x8007,
394         MAX = 0x8008,
395         DEPTH_COMPONENT24 = 0x81A6,
396         MAX_TEXTURE_LOD_BIAS = 0x84FD,
397         TEXTURE_COMPARE_MODE = 0x884C,
398         TEXTURE_COMPARE_FUNC = 0x884D,
399         CURRENT_QUERY = 0x8865,
400         QUERY_RESULT = 0x8866,
401         QUERY_RESULT_AVAILABLE = 0x8867,
402         STREAM_READ = 0x88E1,
403         STREAM_COPY = 0x88E2,
404         STATIC_READ = 0x88E5,
405         STATIC_COPY = 0x88E6,
406         DYNAMIC_READ = 0x88E9,
407         DYNAMIC_COPY = 0x88EA,
408         MAX_DRAW_BUFFERS = 0x8824,
409         DRAW_BUFFER0 = 0x8825,
410         DRAW_BUFFER1 = 0x8826,
411         DRAW_BUFFER2 = 0x8827,
412         DRAW_BUFFER3 = 0x8828,
413         DRAW_BUFFER4 = 0x8829,
414         DRAW_BUFFER5 = 0x882A,
415         DRAW_BUFFER6 = 0x882B,
416         DRAW_BUFFER7 = 0x882C,
417         DRAW_BUFFER8 = 0x882D,
418         DRAW_BUFFER9 = 0x882E,
419         DRAW_BUFFER10 = 0x882F,
420         DRAW_BUFFER11 = 0x8830,
421         DRAW_BUFFER12 = 0x8831,
422         DRAW_BUFFER13 = 0x8832,
423         DRAW_BUFFER14 = 0x8833,
424         DRAW_BUFFER15 = 0x8834,
425         MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49,
426         MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A,
427         SAMPLER_3D = 0x8B5F,
428         SAMPLER_2D_SHADOW = 0x8B62,
429         FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B,
430         PIXEL_PACK_BUFFER = 0x88EB,
431         PIXEL_UNPACK_BUFFER = 0x88EC,
432         PIXEL_PACK_BUFFER_BINDING = 0x88ED,
433         PIXEL_UNPACK_BUFFER_BINDING = 0x88EF,
434         FLOAT_MAT2x3 = 0x8B65,
435         FLOAT_MAT2x4 = 0x8B66,
436         FLOAT_MAT3x2 = 0x8B67,
437         FLOAT_MAT3x4 = 0x8B68,
438         FLOAT_MAT4x2 = 0x8B69,
439         FLOAT_MAT4x3 = 0x8B6A,
440         SRGB = 0x8C40,
441         SRGB8 = 0x8C41,
442         SRGB_ALPHA = 0x8C42,
443         SRGB8_ALPHA8 = 0x8C43,
444         COMPARE_REF_TO_TEXTURE = 0x884E,
445         RGBA32F = 0x8814,
446         RGB32F = 0x8815,
447         RGBA16F = 0x881A,
448         RGB16F = 0x881B,
449         VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD,
450         MAX_ARRAY_TEXTURE_LAYERS = 0x88FF,
451         MIN_PROGRAM_TEXEL_OFFSET = 0x8904,
452         MAX_PROGRAM_TEXEL_OFFSET = 0x8905,
453         MAX_VARYING_COMPONENTS = 0x8B4B,
454         TEXTURE_2D_ARRAY = 0x8C1A,
455         TEXTURE_BINDING_2D_ARRAY = 0x8C1D,
456         R11F_G11F_B10F = 0x8C3A,
457         UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B,
458         RGB9_E5 = 0x8C3D,
459         UNSIGNED_INT_5_9_9_9_REV = 0x8C3E,
460         TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F,
461         MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80,
462         TRANSFORM_FEEDBACK_VARYINGS = 0x8C83,
463         TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84,
464         TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85,
465         TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88,
466         RASTERIZER_DISCARD = 0x8C89,
467         MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A,
468         MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B,
469         INTERLEAVED_ATTRIBS = 0x8C8C,
470         SEPARATE_ATTRIBS = 0x8C8D,
471         TRANSFORM_FEEDBACK_BUFFER = 0x8C8E,
472         TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F,
473         RGBA32UI = 0x8D70,
474         RGB32UI = 0x8D71,
475         RGBA16UI = 0x8D76,
476         RGB16UI = 0x8D77,
477         RGBA8UI = 0x8D7C,
478         RGB8UI = 0x8D7D,
479         RGBA32I = 0x8D82,
480         RGB32I = 0x8D83,
481         RGBA16I = 0x8D88,
482         RGB16I = 0x8D89,
483         RGBA8I = 0x8D8E,
484         RGB8I = 0x8D8F,
485         RED_INTEGER = 0x8D94,
486         RGB_INTEGER = 0x8D98,
487         RGBA_INTEGER = 0x8D99,
488         SAMPLER_2D_ARRAY = 0x8DC1,
489         SAMPLER_2D_ARRAY_SHADOW = 0x8DC4,
490         SAMPLER_CUBE_SHADOW = 0x8DC5,
491         UNSIGNED_INT_VEC2 = 0x8DC6,
492         UNSIGNED_INT_VEC3 = 0x8DC7,
493         UNSIGNED_INT_VEC4 = 0x8DC8,
494         INT_SAMPLER_2D = 0x8DCA,
495         INT_SAMPLER_3D = 0x8DCB,
496         INT_SAMPLER_CUBE = 0x8DCC,
497         INT_SAMPLER_2D_ARRAY = 0x8DCF,
498         UNSIGNED_INT_SAMPLER_2D = 0x8DD2,
499         UNSIGNED_INT_SAMPLER_3D = 0x8DD3,
500         UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4,
501         UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7,
502         DEPTH_COMPONENT32F = 0x8CAC,
503         DEPTH32F_STENCIL8 = 0x8CAD,
504         FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD,
505         FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210,
506         FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211,
507         FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212,
508         FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213,
509         FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214,
510         FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215,
511         FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216,
512         FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217,
513         FRAMEBUFFER_DEFAULT = 0x8218,
514         DEPTH_STENCIL_ATTACHMENT = 0x821A,
515         DEPTH_STENCIL = 0x84F9,
516         UNSIGNED_INT_24_8 = 0x84FA,
517         DEPTH24_STENCIL8 = 0x88F0,
518         UNSIGNED_NORMALIZED = 0x8C17,
519         DRAW_FRAMEBUFFER_BINDING = 0x8CA6, /* Same as FRAMEBUFFER_BINDING */
520         READ_FRAMEBUFFER = 0x8CA8,
521         DRAW_FRAMEBUFFER = 0x8CA9,
522         READ_FRAMEBUFFER_BINDING = 0x8CAA,
523         RENDERBUFFER_SAMPLES = 0x8CAB,
524         FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4,
525         MAX_COLOR_ATTACHMENTS = 0x8CDF,
526         COLOR_ATTACHMENT1 = 0x8CE1,
527         COLOR_ATTACHMENT2 = 0x8CE2,
528         COLOR_ATTACHMENT3 = 0x8CE3,
529         COLOR_ATTACHMENT4 = 0x8CE4,
530         COLOR_ATTACHMENT5 = 0x8CE5,
531         COLOR_ATTACHMENT6 = 0x8CE6,
532         COLOR_ATTACHMENT7 = 0x8CE7,
533         COLOR_ATTACHMENT8 = 0x8CE8,
534         COLOR_ATTACHMENT9 = 0x8CE9,
535         COLOR_ATTACHMENT10 = 0x8CEA,
536         COLOR_ATTACHMENT11 = 0x8CEB,
537         COLOR_ATTACHMENT12 = 0x8CEC,
538         COLOR_ATTACHMENT13 = 0x8CED,
539         COLOR_ATTACHMENT14 = 0x8CEE,
540         COLOR_ATTACHMENT15 = 0x8CEF,
541         FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
542         MAX_SAMPLES = 0x8D57,
543         HALF_FLOAT = 0x140B,
544         RG = 0x8227,
545         RG_INTEGER = 0x8228,
546         R8 = 0x8229,
547         RG8 = 0x822B,
548         R16F = 0x822D,
549         R32F = 0x822E,
550         RG16F = 0x822F,
551         RG32F = 0x8230,
552         R8I = 0x8231,
553         R8UI = 0x8232,
554         R16I = 0x8233,
555         R16UI = 0x8234,
556         R32I = 0x8235,
557         R32UI = 0x8236,
558         RG8I = 0x8237,
559         RG8UI = 0x8238,
560         RG16I = 0x8239,
561         RG16UI = 0x823A,
562         RG32I = 0x823B,
563         RG32UI = 0x823C,
564         VERTEX_ARRAY_BINDING = 0x85B5,
565         R8_SNORM = 0x8F94,
566         RG8_SNORM = 0x8F95,
567         RGB8_SNORM = 0x8F96,
568         RGBA8_SNORM = 0x8F97,
569         SIGNED_NORMALIZED = 0x8F9C,
570         COPY_READ_BUFFER = 0x8F36,
571         COPY_WRITE_BUFFER = 0x8F37,
572         COPY_READ_BUFFER_BINDING = 0x8F36, /* Same as COPY_READ_BUFFER */
573         COPY_WRITE_BUFFER_BINDING = 0x8F37, /* Same as COPY_WRITE_BUFFER */
574         UNIFORM_BUFFER = 0x8A11,
575         UNIFORM_BUFFER_BINDING = 0x8A28,
576         UNIFORM_BUFFER_START = 0x8A29,
577         UNIFORM_BUFFER_SIZE = 0x8A2A,
578         MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B,
579         MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D,
580         MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E,
581         MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F,
582         MAX_UNIFORM_BLOCK_SIZE = 0x8A30,
583         MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31,
584         MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33,
585         UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34,
586         ACTIVE_UNIFORM_BLOCKS = 0x8A36,
587         UNIFORM_TYPE = 0x8A37,
588         UNIFORM_SIZE = 0x8A38,
589         UNIFORM_BLOCK_INDEX = 0x8A3A,
590         UNIFORM_OFFSET = 0x8A3B,
591         UNIFORM_ARRAY_STRIDE = 0x8A3C,
592         UNIFORM_MATRIX_STRIDE = 0x8A3D,
593         UNIFORM_IS_ROW_MAJOR = 0x8A3E,
594         UNIFORM_BLOCK_BINDING = 0x8A3F,
595         UNIFORM_BLOCK_DATA_SIZE = 0x8A40,
596         UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42,
597         UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43,
598         UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44,
599         UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46,
600         INVALID_INDEX = 0xFFFFFFFF,
601         MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122,
602         MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125,
603         MAX_SERVER_WAIT_TIMEOUT = 0x9111,
604         OBJECT_TYPE = 0x9112,
605         SYNC_CONDITION = 0x9113,
606         SYNC_STATUS = 0x9114,
607         SYNC_FLAGS = 0x9115,
608         SYNC_FENCE = 0x9116,
609         SYNC_GPU_COMMANDS_COMPLETE = 0x9117,
610         UNSIGNALED = 0x9118,
611         SIGNALED = 0x9119,
612         ALREADY_SIGNALED = 0x911A,
613         TIMEOUT_EXPIRED = 0x911B,
614         CONDITION_SATISFIED = 0x911C,
615 #if PLATFORM(WIN)
616         WAIT_FAILED_WIN = 0x911D,
617 #else
618         WAIT_FAILED = 0x911D,
619 #endif
620         SYNC_FLUSH_COMMANDS_BIT = 0x00000001,
621         VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE,
622         ANY_SAMPLES_PASSED = 0x8C2F,
623         ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A,
624         SAMPLER_BINDING = 0x8919,
625         RGB10_A2UI = 0x906F,
626         TEXTURE_SWIZZLE_R = 0x8E42,
627         TEXTURE_SWIZZLE_G = 0x8E43,
628         TEXTURE_SWIZZLE_B = 0x8E44,
629         TEXTURE_SWIZZLE_A = 0x8E45,
630         GREEN = 0x1904,
631         BLUE = 0x1905,
632         INT_2_10_10_10_REV = 0x8D9F,
633         TRANSFORM_FEEDBACK = 0x8E22,
634         TRANSFORM_FEEDBACK_PAUSED = 0x8E23,
635         TRANSFORM_FEEDBACK_ACTIVE = 0x8E24,
636         TRANSFORM_FEEDBACK_BINDING = 0x8E25,
637         COMPRESSED_R11_EAC = 0x9270,
638         COMPRESSED_SIGNED_R11_EAC = 0x9271,
639         COMPRESSED_RG11_EAC = 0x9272,
640         COMPRESSED_SIGNED_RG11_EAC = 0x9273,
641         COMPRESSED_RGB8_ETC2 = 0x9274,
642         COMPRESSED_SRGB8_ETC2 = 0x9275,
643         COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
644         COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
645         COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
646         COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
647         TEXTURE_IMMUTABLE_FORMAT = 0x912F,
648         MAX_ELEMENT_INDEX = 0x8D6B,
649         NUM_SAMPLE_COUNTS = 0x9380,
650         TEXTURE_IMMUTABLE_LEVELS = 0x82DF,
651         PRIMITIVE_RESTART_FIXED_INDEX = 0x8D69,
652         PRIMITIVE_RESTART = 0x8F9D,
653
654         // OpenGL ES 3 constants.
655         MAP_READ_BIT = 0x0001,
656
657         // Necessary desktop OpenGL constants.
658         TEXTURE_RECTANGLE_ARB = 0x84F5
659     };
660
661     enum class DataFormat : uint8_t {
662         RGBA8 = 0,
663         RGBA16Little,
664         RGBA16Big,
665         RGBA16F,
666         RGBA32F,
667         RGB8,
668         RGB16Little,
669         RGB16Big,
670         RGB16F,
671         RGB32F,
672         BGR8,
673         BGRA8,
674         BGRA16Little,
675         BGRA16Big,
676         ARGB8,
677         ARGB16Little,
678         ARGB16Big,
679         ABGR8,
680         RGBA5551,
681         RGBA4444,
682         RGB565,
683         R8,
684         R16Little,
685         R16Big,
686         R16F,
687         R32F,
688         RA8,
689         RA16Little,
690         RA16Big,
691         RA16F,
692         RA32F,
693         AR8,
694         AR16Little,
695         AR16Big,
696         A8,
697         A16Little,
698         A16Big,
699         A16F,
700         A32F,
701         NumFormats
702     };
703
704     enum class Destination : uint8_t {
705         Offscreen,
706         DirectlyToHostWindow,
707     };
708
709     enum class ChannelBits : uint8_t {
710         Red = 1,
711         Green = 2,
712         Blue = 4,
713         Alpha = 8,
714         Depth = 16,
715         Stencil = 32,
716         RGB = Red | Green | Blue,
717         RGBA = RGB | Alpha,
718         DepthStencil = Depth | Stencil,
719     };
720
721     // Possible alpha operations that may need to occur during
722     // pixel packing. FIXME: kAlphaDoUnmultiply is lossy and must
723     // be removed.
724     enum AlphaOp : uint8_t {
725         DoNothing,
726         DoPremultiply,
727         DoUnmultiply,
728     };
729
730     enum class DOMSource : uint8_t {
731         Image,
732         Canvas,
733         Video,
734         None,
735     };
736
737     virtual PlatformGraphicsContext3D platformGraphicsContext3D() const = 0;
738     virtual Platform3DObject platformTexture() const = 0;
739     virtual PlatformLayer* platformLayer() const = 0;
740
741     ALWAYS_INLINE static bool hasAlpha(DataFormat format)
742     {
743         switch (format) {
744         case DataFormat::A8:
745         case DataFormat::A16F:
746         case DataFormat::A32F:
747         case DataFormat::RA8:
748         case DataFormat::AR8:
749         case DataFormat::RA16F:
750         case DataFormat::RA32F:
751         case DataFormat::RGBA8:
752         case DataFormat::BGRA8:
753         case DataFormat::ARGB8:
754         case DataFormat::ABGR8:
755         case DataFormat::RGBA16F:
756         case DataFormat::RGBA32F:
757         case DataFormat::RGBA4444:
758         case DataFormat::RGBA5551:
759             return true;
760         default:
761             return false;
762         }
763     }
764
765     ALWAYS_INLINE static bool hasColor(DataFormat format)
766     {
767         switch (format) {
768         case DataFormat::RGBA8:
769         case DataFormat::RGBA16F:
770         case DataFormat::RGBA32F:
771         case DataFormat::RGB8:
772         case DataFormat::RGB16F:
773         case DataFormat::RGB32F:
774         case DataFormat::BGR8:
775         case DataFormat::BGRA8:
776         case DataFormat::ARGB8:
777         case DataFormat::ABGR8:
778         case DataFormat::RGBA5551:
779         case DataFormat::RGBA4444:
780         case DataFormat::RGB565:
781         case DataFormat::R8:
782         case DataFormat::R16F:
783         case DataFormat::R32F:
784         case DataFormat::RA8:
785         case DataFormat::RA16F:
786         case DataFormat::RA32F:
787         case DataFormat::AR8:
788             return true;
789         default:
790             return false;
791         }
792     }
793
794     // Check if the format is one of the formats from the ImageData or DOM elements.
795     // The formats from ImageData is always RGBA8.
796     // The formats from DOM elements vary with Graphics ports. It can only be RGBA8 or BGRA8 for non-CG port while a little more for CG port.
797     static ALWAYS_INLINE bool srcFormatComesFromDOMElementOrImageData(DataFormat SrcFormat)
798     {
799 #if USE(CG)
800 #if CPU(BIG_ENDIAN)
801     return SrcFormat == DataFormat::RGBA8 || SrcFormat == DataFormat::ARGB8 || SrcFormat == DataFormat::RGB8
802         || SrcFormat == DataFormat::RA8 || SrcFormat == DataFormat::AR8 || SrcFormat == DataFormat::R8 || SrcFormat == DataFormat::A8;
803 #else
804     // That LITTLE_ENDIAN case has more possible formats than BIG_ENDIAN case is because some decoded image data is actually big endian
805     // even on little endian architectures.
806     return SrcFormat == DataFormat::BGRA8 || SrcFormat == DataFormat::ABGR8 || SrcFormat == DataFormat::BGR8
807         || SrcFormat == DataFormat::RGBA8 || SrcFormat == DataFormat::ARGB8 || SrcFormat == DataFormat::RGB8
808         || SrcFormat == DataFormat::R8 || SrcFormat == DataFormat::A8
809         || SrcFormat == DataFormat::RA8 || SrcFormat == DataFormat::AR8;
810 #endif
811 #else
812     return SrcFormat == DataFormat::BGRA8 || SrcFormat == DataFormat::RGBA8;
813 #endif
814     }
815
816     struct ActiveInfo {
817         String name;
818         GC3Denum type;
819         GC3Dint size;
820     };
821
822     GraphicsContext3DBase(GraphicsContext3DAttributes, Destination = Destination::Offscreen, GraphicsContext3DBase* sharedContext = nullptr);
823     virtual ~GraphicsContext3DBase() = default;
824
825     // ========== WebGL 1 entry points.
826
827     virtual void activeTexture(GC3Denum texture) = 0;
828     virtual void attachShader(Platform3DObject program, Platform3DObject shader) = 0;
829     virtual void bindAttribLocation(Platform3DObject, GC3Duint index, const String& name) = 0;
830     virtual void bindBuffer(GC3Denum target, Platform3DObject) = 0;
831     virtual void bindFramebuffer(GC3Denum target, Platform3DObject) = 0;
832     virtual void bindRenderbuffer(GC3Denum target, Platform3DObject) = 0;
833     virtual void bindTexture(GC3Denum target, Platform3DObject) = 0;
834     virtual void blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) = 0;
835     virtual void blendEquation(GC3Denum mode) = 0;
836     virtual void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) = 0;
837     virtual void blendFunc(GC3Denum sfactor, GC3Denum dfactor) = 0;
838     virtual void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) = 0;
839
840     virtual GC3Denum checkFramebufferStatus(GC3Denum target) = 0;
841     virtual void clear(GC3Dbitfield mask) = 0;
842     virtual void clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) = 0;
843     virtual void clearDepth(GC3Dclampf depth) = 0;
844     virtual void clearStencil(GC3Dint s) = 0;
845     virtual void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha) = 0;
846     virtual void compileShader(Platform3DObject) = 0;
847
848     virtual void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) = 0;
849     virtual void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) = 0;
850
851     virtual Platform3DObject createBuffer() = 0;
852     virtual Platform3DObject createFramebuffer() = 0;
853     virtual Platform3DObject createProgram() = 0;
854     virtual Platform3DObject createRenderbuffer() = 0;
855     virtual Platform3DObject createShader(GC3Denum) = 0;
856     virtual Platform3DObject createTexture() = 0;
857
858     virtual void cullFace(GC3Denum mode) = 0;
859
860     virtual void deleteBuffer(Platform3DObject) = 0;
861     virtual void deleteFramebuffer(Platform3DObject) = 0;
862     virtual void deleteProgram(Platform3DObject) = 0;
863     virtual void deleteRenderbuffer(Platform3DObject) = 0;
864     virtual void deleteShader(Platform3DObject) = 0;
865     virtual void deleteTexture(Platform3DObject) = 0;
866
867     virtual void depthFunc(GC3Denum func) = 0;
868     virtual void depthMask(GC3Dboolean flag) = 0;
869     virtual void depthRange(GC3Dclampf zNear, GC3Dclampf zFar) = 0;
870     virtual void detachShader(Platform3DObject, Platform3DObject) = 0;
871     virtual void disable(GC3Denum cap) = 0;
872     virtual void disableVertexAttribArray(GC3Duint index) = 0;
873     virtual void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count) = 0;
874     virtual void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset) = 0;
875
876     virtual void enable(GC3Denum cap) = 0;
877     virtual void enableVertexAttribArray(GC3Duint index) = 0;
878     virtual void finish() = 0;
879     virtual void flush() = 0;
880     virtual void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject) = 0;
881     virtual void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject, GC3Dint level) = 0;
882     virtual void frontFace(GC3Denum mode) = 0;
883
884     virtual void generateMipmap(GC3Denum target) = 0;
885
886     virtual bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&) = 0;
887     virtual bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&) = 0;
888     virtual void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders) = 0;
889
890     virtual GC3Dint getAttribLocation(Platform3DObject, const String& name) = 0;
891
892     virtual void getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) = 0;
893
894     // getParameter
895     virtual String getString(GC3Denum name) = 0;
896     virtual void getFloatv(GC3Denum pname, GC3Dfloat* value) = 0;
897     virtual void getIntegerv(GC3Denum pname, GC3Dint* value) = 0;
898     virtual void getInteger64v(GC3Denum pname, GC3Dint64* value) = 0;
899     virtual void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value) = 0;
900     virtual void getBooleanv(GC3Denum pname, GC3Dboolean* value) = 0;
901
902     virtual GC3Denum getError() = 0;
903
904     // getFramebufferAttachmentParameter
905     virtual void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value) = 0;
906
907     // getProgramParameter
908     virtual String getProgramInfoLog(Platform3DObject) = 0;
909
910     // getRenderbufferParameter
911     virtual void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) = 0;
912
913     // getShaderParameter
914     virtual void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value) = 0;
915
916     virtual String getShaderInfoLog(Platform3DObject) = 0;
917     virtual void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision) = 0;
918
919     virtual String getShaderSource(Platform3DObject) = 0;
920
921     // getTexParameter
922     virtual void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value) = 0;
923     virtual void getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) = 0;
924
925     // getUniform
926     virtual void getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value) = 0;
927     virtual void getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value) = 0;
928
929     virtual GC3Dint getUniformLocation(Platform3DObject, const String& name) = 0;
930
931     // getVertexAttrib
932     virtual void getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value) = 0;
933     virtual void getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value) = 0;
934
935     virtual GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname) = 0;
936
937     virtual void hint(GC3Denum target, GC3Denum mode) = 0;
938     virtual GC3Dboolean isBuffer(Platform3DObject) = 0;
939     virtual GC3Dboolean isEnabled(GC3Denum cap) = 0;
940     virtual GC3Dboolean isFramebuffer(Platform3DObject) = 0;
941     virtual GC3Dboolean isProgram(Platform3DObject) = 0;
942     virtual GC3Dboolean isRenderbuffer(Platform3DObject) = 0;
943     virtual GC3Dboolean isShader(Platform3DObject) = 0;
944     virtual GC3Dboolean isTexture(Platform3DObject) = 0;
945     virtual void lineWidth(GC3Dfloat) = 0;
946     virtual void linkProgram(Platform3DObject) = 0;
947     virtual void pixelStorei(GC3Denum pname, GC3Dint param) = 0;
948     virtual void polygonOffset(GC3Dfloat factor, GC3Dfloat units) = 0;
949
950     virtual void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) = 0;
951     virtual void sampleCoverage(GC3Dclampf value, GC3Dboolean invert) = 0;
952     virtual void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) = 0;
953
954     virtual void shaderSource(Platform3DObject, const String& string) = 0;
955
956     virtual void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) = 0;
957     virtual void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask) = 0;
958     virtual void stencilMask(GC3Duint mask) = 0;
959     virtual void stencilMaskSeparate(GC3Denum face, GC3Duint mask) = 0;
960     virtual void stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass) = 0;
961     virtual void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) = 0;
962
963     virtual void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param) = 0;
964     virtual void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param) = 0;
965
966     virtual void uniform1f(GC3Dint location, GC3Dfloat x) = 0;
967     virtual void uniform1fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) = 0;
968     virtual void uniform1i(GC3Dint location, GC3Dint x) = 0;
969     virtual void uniform1iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) = 0;
970     virtual void uniform2f(GC3Dint location, GC3Dfloat x, GC3Dfloat y) = 0;
971     virtual void uniform2fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) = 0;
972     virtual void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y) = 0;
973     virtual void uniform2iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) = 0;
974     virtual void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z) = 0;
975     virtual void uniform3fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) = 0;
976     virtual void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z) = 0;
977     virtual void uniform3iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) = 0;
978     virtual void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) = 0;
979     virtual void uniform4fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) = 0;
980     virtual void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w) = 0;
981     virtual void uniform4iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) = 0;
982     virtual void uniformMatrix2fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) = 0;
983     virtual void uniformMatrix3fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) = 0;
984     virtual void uniformMatrix4fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) = 0;
985
986     virtual void useProgram(Platform3DObject) = 0;
987     virtual void validateProgram(Platform3DObject) = 0;
988
989     virtual void vertexAttrib1f(GC3Duint index, GC3Dfloat x) = 0;
990     virtual void vertexAttrib1fv(GC3Duint index, const GC3Dfloat* values) = 0;
991     virtual void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y) = 0;
992     virtual void vertexAttrib2fv(GC3Duint index, const GC3Dfloat* values) = 0;
993     virtual void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z) = 0;
994     virtual void vertexAttrib3fv(GC3Duint index, const GC3Dfloat* values) = 0;
995     virtual void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) = 0;
996     virtual void vertexAttrib4fv(GC3Duint index, const GC3Dfloat* values) = 0;
997
998     virtual void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset) = 0;
999
1000     virtual void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) = 0;
1001
1002     virtual void bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage) = 0;
1003     virtual void bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage) = 0;
1004     virtual void bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data) = 0;
1005
1006     virtual void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data) = 0;
1007     virtual void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data) = 0;
1008
1009     virtual void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) = 0;
1010
1011     virtual bool texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) = 0;
1012     virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels) = 0;
1013
1014     virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) = 0;
1015     virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) = 0;
1016     virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor) = 0;
1017
1018     GraphicsContext3DAttributes contextAttributes() const { return m_attrs; }
1019     void setContextAttributes(const GraphicsContext3DAttributes& attrs) { m_attrs = attrs; }
1020
1021     // VertexArrayOject calls
1022     virtual Platform3DObject createVertexArray() = 0;
1023     virtual void deleteVertexArray(Platform3DObject) = 0;
1024     virtual GC3Dboolean isVertexArray(Platform3DObject) = 0;
1025     virtual void bindVertexArray(Platform3DObject) = 0;
1026
1027 #if USE(OPENGL) && ENABLE(WEBGL2)
1028     virtual void primitiveRestartIndex(GC3Duint) = 0;
1029 #endif
1030
1031     // Support for extensions. Returns a non-null object, though not
1032     // all methods it contains may necessarily be supported on the
1033     // current hardware. Must call Extensions3D::supports() to
1034     // determine this.
1035     virtual Extensions3D& getExtensions() = 0;
1036
1037     // ========== WebGL 2 entry points.
1038
1039     virtual void* mapBufferRange(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr length, GC3Dbitfield access) = 0;
1040     virtual GC3Dboolean unmapBuffer(GC3Denum target) = 0;
1041     virtual void copyBufferSubData(GC3Denum readTarget, GC3Denum writeTarget, GC3Dintptr readOffset, GC3Dintptr writeOffset, GC3Dsizeiptr) = 0;
1042
1043     // getInternalFormatParameter
1044     virtual void getInternalformativ(GC3Denum target, GC3Denum internalformat, GC3Denum pname, GC3Dsizei bufSize, GC3Dint* params) = 0;
1045
1046     virtual void renderbufferStorageMultisample(GC3Denum target, GC3Dsizei samples, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) = 0;
1047
1048     virtual void texStorage2D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) = 0;
1049     virtual void texStorage3D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dsizei depth) = 0;
1050
1051     virtual void getActiveUniforms(Platform3DObject program, const Vector<GC3Duint>& uniformIndices, GC3Denum pname, Vector<GC3Dint>& params) = 0;
1052
1053     // ========== Non-WebGL based entry points.
1054
1055     static unsigned getClearBitsByAttachmentType(GC3Denum);
1056     static unsigned getClearBitsByFormat(GC3Denum);
1057
1058     static uint8_t getChannelBitsByFormat(GC3Denum);
1059
1060     Destination destination() const { return m_destination; }
1061
1062 private:
1063     GraphicsContext3DAttributes m_attrs;
1064     Destination m_destination;
1065 };
1066
1067 } // namespace WebCore
1068
1069 #endif