tagging audio streams and changing audio sink to pulseaudio
[profile/ivi/webkit-efl.git] / Source / WebCore / platform / graphics / GraphicsContext3D.h
1 /*
2  * Copyright (C) 2009 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 COMPUTER, 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 COMPUTER, 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 #ifndef GraphicsContext3D_h
27 #define GraphicsContext3D_h
28
29 #include "IntRect.h"
30 #include "GraphicsLayer.h"
31 #include "GraphicsTypes3D.h"
32 #include "PlatformString.h"
33 #include <wtf/HashMap.h>
34 #include <wtf/ListHashSet.h>
35 #include <wtf/Noncopyable.h>
36 #include <wtf/RefCounted.h>
37
38 // FIXME: Find a better way to avoid the name confliction for NO_ERROR.
39 #if ((PLATFORM(CHROMIUM) && OS(WINDOWS)) || PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS)))
40 #undef NO_ERROR
41 #elif PLATFORM(GTK)
42 // This define is from the X11 headers, but it's used below, so we must undefine it.
43 #undef VERSION
44 #endif
45
46 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT)
47 #include "ANGLEWebKitBridge.h"
48 #endif
49
50 #if PLATFORM(MAC)
51 #include <OpenGL/OpenGL.h>
52 #include <wtf/RetainPtr.h>
53 OBJC_CLASS CALayer;
54 OBJC_CLASS WebGLLayer;
55 #elif PLATFORM(QT)
56 QT_BEGIN_NAMESPACE
57 class QPainter;
58 class QRect;
59 class QGLWidget;
60 class QGLContext;
61 class QOpenGLContext;
62 class QSurface;
63 QT_END_NAMESPACE
64 #elif PLATFORM(GTK) || PLATFORM(EFL)
65 typedef unsigned int GLuint;
66 #endif
67
68 #if PLATFORM(MAC)
69 typedef CGLContextObj PlatformGraphicsContext3D;
70 #elif PLATFORM(QT)
71 #if HAVE(QT5)
72 typedef QOpenGLContext* PlatformGraphicsContext3D;
73 typedef QSurface* PlatformGraphicsSurface3D;
74 #else
75 typedef QGLContext* PlatformGraphicsContext3D;
76 typedef QGLWidget* PlatformGraphicsSurface3D;
77 #endif
78 #else
79 typedef void* PlatformGraphicsContext3D;
80 #endif
81
82 #if PLATFORM(CHROMIUM) && USE(SKIA)
83 class GrContext;
84 #endif
85
86 // These are currently the same among all implementations.
87 const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0;
88 const Platform3DObject NullPlatform3DObject = 0;
89
90 #if USE(CG)
91 #include <CoreGraphics/CGContext.h>
92 #endif
93
94 namespace WebCore {
95 class DrawingBuffer;
96 class Extensions3D;
97 #if USE(OPENGL_ES_2) && !OS(TIZEN)
98 class Extensions3DOpenGLES;
99 #else
100 class Extensions3DOpenGL;
101 #endif
102 #if PLATFORM(QT)
103 class Extensions3DQt;
104 #endif
105 class HostWindow;
106 class Image;
107 class ImageBuffer;
108 class ImageData;
109 class IntRect;
110 class IntSize;
111 #if USE(CAIRO)
112 class PlatformContextCairo;
113 #elif PLATFORM(BLACKBERRY)
114 class GraphicsContext;
115 #endif
116
117 struct ActiveInfo {
118     String name;
119     GC3Denum type;
120     GC3Dint size;
121 };
122
123 // FIXME: ideally this would be used on all platforms.
124 #if PLATFORM(CHROMIUM) || PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
125 class GraphicsContext3DInternal;
126 #endif
127
128 class GraphicsContext3D : public RefCounted<GraphicsContext3D> {
129 public:
130     enum {
131         DEPTH_BUFFER_BIT = 0x00000100,
132         STENCIL_BUFFER_BIT = 0x00000400,
133         COLOR_BUFFER_BIT = 0x00004000,
134         POINTS = 0x0000,
135         LINES = 0x0001,
136         LINE_LOOP = 0x0002,
137         LINE_STRIP = 0x0003,
138         TRIANGLES = 0x0004,
139         TRIANGLE_STRIP = 0x0005,
140         TRIANGLE_FAN = 0x0006,
141         ZERO = 0,
142         ONE = 1,
143         SRC_COLOR = 0x0300,
144         ONE_MINUS_SRC_COLOR = 0x0301,
145         SRC_ALPHA = 0x0302,
146         ONE_MINUS_SRC_ALPHA = 0x0303,
147         DST_ALPHA = 0x0304,
148         ONE_MINUS_DST_ALPHA = 0x0305,
149         DST_COLOR = 0x0306,
150         ONE_MINUS_DST_COLOR = 0x0307,
151         SRC_ALPHA_SATURATE = 0x0308,
152         FUNC_ADD = 0x8006,
153         BLEND_EQUATION = 0x8009,
154         BLEND_EQUATION_RGB = 0x8009,
155         BLEND_EQUATION_ALPHA = 0x883D,
156         FUNC_SUBTRACT = 0x800A,
157         FUNC_REVERSE_SUBTRACT = 0x800B,
158         BLEND_DST_RGB = 0x80C8,
159         BLEND_SRC_RGB = 0x80C9,
160         BLEND_DST_ALPHA = 0x80CA,
161         BLEND_SRC_ALPHA = 0x80CB,
162         CONSTANT_COLOR = 0x8001,
163         ONE_MINUS_CONSTANT_COLOR = 0x8002,
164         CONSTANT_ALPHA = 0x8003,
165         ONE_MINUS_CONSTANT_ALPHA = 0x8004,
166         BLEND_COLOR = 0x8005,
167         ARRAY_BUFFER = 0x8892,
168         ELEMENT_ARRAY_BUFFER = 0x8893,
169         ARRAY_BUFFER_BINDING = 0x8894,
170         ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
171         STREAM_DRAW = 0x88E0,
172         STATIC_DRAW = 0x88E4,
173         DYNAMIC_DRAW = 0x88E8,
174         BUFFER_SIZE = 0x8764,
175         BUFFER_USAGE = 0x8765,
176         CURRENT_VERTEX_ATTRIB = 0x8626,
177         FRONT = 0x0404,
178         BACK = 0x0405,
179         FRONT_AND_BACK = 0x0408,
180         TEXTURE_2D = 0x0DE1,
181         CULL_FACE = 0x0B44,
182         BLEND = 0x0BE2,
183         DITHER = 0x0BD0,
184         STENCIL_TEST = 0x0B90,
185         DEPTH_TEST = 0x0B71,
186         SCISSOR_TEST = 0x0C11,
187         POLYGON_OFFSET_FILL = 0x8037,
188         SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
189         SAMPLE_COVERAGE = 0x80A0,
190         NO_ERROR = 0,
191         INVALID_ENUM = 0x0500,
192         INVALID_VALUE = 0x0501,
193         INVALID_OPERATION = 0x0502,
194         OUT_OF_MEMORY = 0x0505,
195         CW = 0x0900,
196         CCW = 0x0901,
197         LINE_WIDTH = 0x0B21,
198         ALIASED_POINT_SIZE_RANGE = 0x846D,
199         ALIASED_LINE_WIDTH_RANGE = 0x846E,
200         CULL_FACE_MODE = 0x0B45,
201         FRONT_FACE = 0x0B46,
202         DEPTH_RANGE = 0x0B70,
203         DEPTH_WRITEMASK = 0x0B72,
204         DEPTH_CLEAR_VALUE = 0x0B73,
205         DEPTH_FUNC = 0x0B74,
206         STENCIL_CLEAR_VALUE = 0x0B91,
207         STENCIL_FUNC = 0x0B92,
208         STENCIL_FAIL = 0x0B94,
209         STENCIL_PASS_DEPTH_FAIL = 0x0B95,
210         STENCIL_PASS_DEPTH_PASS = 0x0B96,
211         STENCIL_REF = 0x0B97,
212         STENCIL_VALUE_MASK = 0x0B93,
213         STENCIL_WRITEMASK = 0x0B98,
214         STENCIL_BACK_FUNC = 0x8800,
215         STENCIL_BACK_FAIL = 0x8801,
216         STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
217         STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
218         STENCIL_BACK_REF = 0x8CA3,
219         STENCIL_BACK_VALUE_MASK = 0x8CA4,
220         STENCIL_BACK_WRITEMASK = 0x8CA5,
221         VIEWPORT = 0x0BA2,
222         SCISSOR_BOX = 0x0C10,
223         COLOR_CLEAR_VALUE = 0x0C22,
224         COLOR_WRITEMASK = 0x0C23,
225         UNPACK_ALIGNMENT = 0x0CF5,
226         PACK_ALIGNMENT = 0x0D05,
227         MAX_TEXTURE_SIZE = 0x0D33,
228         MAX_VIEWPORT_DIMS = 0x0D3A,
229         SUBPIXEL_BITS = 0x0D50,
230         RED_BITS = 0x0D52,
231         GREEN_BITS = 0x0D53,
232         BLUE_BITS = 0x0D54,
233         ALPHA_BITS = 0x0D55,
234         DEPTH_BITS = 0x0D56,
235         STENCIL_BITS = 0x0D57,
236         POLYGON_OFFSET_UNITS = 0x2A00,
237         POLYGON_OFFSET_FACTOR = 0x8038,
238         TEXTURE_BINDING_2D = 0x8069,
239         SAMPLE_BUFFERS = 0x80A8,
240         SAMPLES = 0x80A9,
241         SAMPLE_COVERAGE_VALUE = 0x80AA,
242         SAMPLE_COVERAGE_INVERT = 0x80AB,
243         NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2,
244         COMPRESSED_TEXTURE_FORMATS = 0x86A3,
245         DONT_CARE = 0x1100,
246         FASTEST = 0x1101,
247         NICEST = 0x1102,
248         GENERATE_MIPMAP_HINT = 0x8192,
249         BYTE = 0x1400,
250         UNSIGNED_BYTE = 0x1401,
251         SHORT = 0x1402,
252         UNSIGNED_SHORT = 0x1403,
253         INT = 0x1404,
254         UNSIGNED_INT = 0x1405,
255         FLOAT = 0x1406,
256         FIXED = 0x140C,
257         DEPTH_COMPONENT = 0x1902,
258         ALPHA = 0x1906,
259         RGB = 0x1907,
260         RGBA = 0x1908,
261         LUMINANCE = 0x1909,
262         LUMINANCE_ALPHA = 0x190A,
263         UNSIGNED_SHORT_4_4_4_4 = 0x8033,
264         UNSIGNED_SHORT_5_5_5_1 = 0x8034,
265         UNSIGNED_SHORT_5_6_5 = 0x8363,
266         FRAGMENT_SHADER = 0x8B30,
267         VERTEX_SHADER = 0x8B31,
268         MAX_VERTEX_ATTRIBS = 0x8869,
269         MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
270         MAX_VARYING_VECTORS = 0x8DFC,
271         MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D,
272         MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C,
273         MAX_TEXTURE_IMAGE_UNITS = 0x8872,
274         MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
275         SHADER_TYPE = 0x8B4F,
276         DELETE_STATUS = 0x8B80,
277         LINK_STATUS = 0x8B82,
278         VALIDATE_STATUS = 0x8B83,
279         ATTACHED_SHADERS = 0x8B85,
280         ACTIVE_UNIFORMS = 0x8B86,
281         ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
282         ACTIVE_ATTRIBUTES = 0x8B89,
283         ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
284         SHADING_LANGUAGE_VERSION = 0x8B8C,
285         CURRENT_PROGRAM = 0x8B8D,
286         NEVER = 0x0200,
287         LESS = 0x0201,
288         EQUAL = 0x0202,
289         LEQUAL = 0x0203,
290         GREATER = 0x0204,
291         NOTEQUAL = 0x0205,
292         GEQUAL = 0x0206,
293         ALWAYS = 0x0207,
294         KEEP = 0x1E00,
295         REPLACE = 0x1E01,
296         INCR = 0x1E02,
297         DECR = 0x1E03,
298         INVERT = 0x150A,
299         INCR_WRAP = 0x8507,
300         DECR_WRAP = 0x8508,
301         VENDOR = 0x1F00,
302         RENDERER = 0x1F01,
303         VERSION = 0x1F02,
304         EXTENSIONS = 0x1F03,
305         NEAREST = 0x2600,
306         LINEAR = 0x2601,
307         NEAREST_MIPMAP_NEAREST = 0x2700,
308         LINEAR_MIPMAP_NEAREST = 0x2701,
309         NEAREST_MIPMAP_LINEAR = 0x2702,
310         LINEAR_MIPMAP_LINEAR = 0x2703,
311         TEXTURE_MAG_FILTER = 0x2800,
312         TEXTURE_MIN_FILTER = 0x2801,
313         TEXTURE_WRAP_S = 0x2802,
314         TEXTURE_WRAP_T = 0x2803,
315         TEXTURE = 0x1702,
316         TEXTURE_CUBE_MAP = 0x8513,
317         TEXTURE_BINDING_CUBE_MAP = 0x8514,
318         TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
319         TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
320         TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
321         TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
322         TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
323         TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A,
324         MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C,
325         TEXTURE0 = 0x84C0,
326         TEXTURE1 = 0x84C1,
327         TEXTURE2 = 0x84C2,
328         TEXTURE3 = 0x84C3,
329         TEXTURE4 = 0x84C4,
330         TEXTURE5 = 0x84C5,
331         TEXTURE6 = 0x84C6,
332         TEXTURE7 = 0x84C7,
333         TEXTURE8 = 0x84C8,
334         TEXTURE9 = 0x84C9,
335         TEXTURE10 = 0x84CA,
336         TEXTURE11 = 0x84CB,
337         TEXTURE12 = 0x84CC,
338         TEXTURE13 = 0x84CD,
339         TEXTURE14 = 0x84CE,
340         TEXTURE15 = 0x84CF,
341         TEXTURE16 = 0x84D0,
342         TEXTURE17 = 0x84D1,
343         TEXTURE18 = 0x84D2,
344         TEXTURE19 = 0x84D3,
345         TEXTURE20 = 0x84D4,
346         TEXTURE21 = 0x84D5,
347         TEXTURE22 = 0x84D6,
348         TEXTURE23 = 0x84D7,
349         TEXTURE24 = 0x84D8,
350         TEXTURE25 = 0x84D9,
351         TEXTURE26 = 0x84DA,
352         TEXTURE27 = 0x84DB,
353         TEXTURE28 = 0x84DC,
354         TEXTURE29 = 0x84DD,
355         TEXTURE30 = 0x84DE,
356         TEXTURE31 = 0x84DF,
357         ACTIVE_TEXTURE = 0x84E0,
358         REPEAT = 0x2901,
359         CLAMP_TO_EDGE = 0x812F,
360         MIRRORED_REPEAT = 0x8370,
361         FLOAT_VEC2 = 0x8B50,
362         FLOAT_VEC3 = 0x8B51,
363         FLOAT_VEC4 = 0x8B52,
364         INT_VEC2 = 0x8B53,
365         INT_VEC3 = 0x8B54,
366         INT_VEC4 = 0x8B55,
367         BOOL = 0x8B56,
368         BOOL_VEC2 = 0x8B57,
369         BOOL_VEC3 = 0x8B58,
370         BOOL_VEC4 = 0x8B59,
371         FLOAT_MAT2 = 0x8B5A,
372         FLOAT_MAT3 = 0x8B5B,
373         FLOAT_MAT4 = 0x8B5C,
374         SAMPLER_2D = 0x8B5E,
375         SAMPLER_CUBE = 0x8B60,
376         VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622,
377         VERTEX_ATTRIB_ARRAY_SIZE = 0x8623,
378         VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624,
379         VERTEX_ATTRIB_ARRAY_TYPE = 0x8625,
380         VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A,
381         VERTEX_ATTRIB_ARRAY_POINTER = 0x8645,
382         VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F,
383         COMPILE_STATUS = 0x8B81,
384         INFO_LOG_LENGTH = 0x8B84,
385         SHADER_SOURCE_LENGTH = 0x8B88,
386         SHADER_COMPILER = 0x8DFA,
387         SHADER_BINARY_FORMATS = 0x8DF8,
388         NUM_SHADER_BINARY_FORMATS = 0x8DF9,
389         LOW_FLOAT = 0x8DF0,
390         MEDIUM_FLOAT = 0x8DF1,
391         HIGH_FLOAT = 0x8DF2,
392         LOW_INT = 0x8DF3,
393         MEDIUM_INT = 0x8DF4,
394         HIGH_INT = 0x8DF5,
395         FRAMEBUFFER = 0x8D40,
396         RENDERBUFFER = 0x8D41,
397         RGBA4 = 0x8056,
398         RGB5_A1 = 0x8057,
399         RGB565 = 0x8D62,
400         DEPTH_COMPONENT16 = 0x81A5,
401         STENCIL_INDEX = 0x1901,
402         STENCIL_INDEX8 = 0x8D48,
403         DEPTH_STENCIL = 0x84F9,
404         UNSIGNED_INT_24_8 = 0x84FA,
405         RENDERBUFFER_WIDTH = 0x8D42,
406         RENDERBUFFER_HEIGHT = 0x8D43,
407         RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
408         RENDERBUFFER_RED_SIZE = 0x8D50,
409         RENDERBUFFER_GREEN_SIZE = 0x8D51,
410         RENDERBUFFER_BLUE_SIZE = 0x8D52,
411         RENDERBUFFER_ALPHA_SIZE = 0x8D53,
412         RENDERBUFFER_DEPTH_SIZE = 0x8D54,
413         RENDERBUFFER_STENCIL_SIZE = 0x8D55,
414         FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0,
415         FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1,
416         FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2,
417         FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3,
418         COLOR_ATTACHMENT0 = 0x8CE0,
419         DEPTH_ATTACHMENT = 0x8D00,
420         STENCIL_ATTACHMENT = 0x8D20,
421         DEPTH_STENCIL_ATTACHMENT = 0x821A,
422         NONE = 0,
423         FRAMEBUFFER_COMPLETE = 0x8CD5,
424         FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
425         FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7,
426         FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9,
427         FRAMEBUFFER_UNSUPPORTED = 0x8CDD,
428         FRAMEBUFFER_BINDING = 0x8CA6,
429         RENDERBUFFER_BINDING = 0x8CA7,
430         MAX_RENDERBUFFER_SIZE = 0x84E8,
431         INVALID_FRAMEBUFFER_OPERATION = 0x0506,
432
433         // WebGL-specific enums
434         UNPACK_FLIP_Y_WEBGL = 0x9240,
435         UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241,
436         CONTEXT_LOST_WEBGL = 0x9242,
437         UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243,
438         BROWSER_DEFAULT_WEBGL = 0x9244
439     };
440
441     // Context creation attributes.
442     struct Attributes {
443         Attributes()
444             : alpha(true)
445             , depth(true)
446             , stencil(false)
447             , antialias(true)
448             , premultipliedAlpha(true)
449             , preserveDrawingBuffer(false)
450             , noExtensions(false)
451             , shareResources(true)
452             , preferDiscreteGPU(false)
453         {
454         }
455
456         bool alpha;
457         bool depth;
458         bool stencil;
459         bool antialias;
460         bool premultipliedAlpha;
461         bool preserveDrawingBuffer;
462         bool noExtensions;
463         bool shareResources;
464         bool preferDiscreteGPU;
465     };
466
467     enum RenderStyle {
468         RenderOffscreen,
469         RenderDirectlyToHostWindow
470     };
471
472     class ContextLostCallback {
473     public:
474         virtual void onContextLost() = 0;
475         virtual ~ContextLostCallback() {}
476     };
477
478     class ErrorMessageCallback {
479     public:
480         virtual void onErrorMessage(const String& message, GC3Dint id) = 0;
481         virtual ~ErrorMessageCallback() { }
482     };
483
484     void setContextLostCallback(PassOwnPtr<ContextLostCallback>);
485     void setErrorMessageCallback(PassOwnPtr<ErrorMessageCallback>);
486
487     static PassRefPtr<GraphicsContext3D> create(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
488     ~GraphicsContext3D();
489
490 #if PLATFORM(MAC)
491     PlatformGraphicsContext3D platformGraphicsContext3D() const { return m_contextObj; }
492     Platform3DObject platformTexture() const { return m_compositorTexture; }
493     CALayer* platformLayer() const { return reinterpret_cast<CALayer*>(m_webGLLayer.get()); }
494 #elif PLATFORM(CHROMIUM)
495     PlatformGraphicsContext3D platformGraphicsContext3D() const;
496     Platform3DObject platformTexture() const;
497 #if USE(SKIA)
498     GrContext* grContext();
499 #endif
500 #if USE(ACCELERATED_COMPOSITING)
501     PlatformLayer* platformLayer() const;
502 #endif
503 #elif PLATFORM(QT)
504     PlatformGraphicsContext3D platformGraphicsContext3D();
505     Platform3DObject platformTexture() const;
506 #if USE(ACCELERATED_COMPOSITING)
507     PlatformLayer* platformLayer() const;
508 #endif
509 #elif PLATFORM(GTK)
510     PlatformGraphicsContext3D platformGraphicsContext3D();
511     Platform3DObject platformTexture() const { return m_texture; }
512 #if USE(ACCELERATED_COMPOSITING)
513     PlatformLayer* platformLayer() const;
514 #endif
515 #elif PLATFORM(EFL)
516     PlatformGraphicsContext3D platformGraphicsContext3D();
517     Platform3DObject platformTexture() const;
518 #if USE(ACCELERATED_COMPOSITING)
519     PlatformLayer* platformLayer() const;
520 #endif
521 #else
522     PlatformGraphicsContext3D platformGraphicsContext3D() const { return NullPlatformGraphicsContext3D; }
523     Platform3DObject platformTexture() const { return NullPlatform3DObject; }
524 #if USE(ACCELERATED_COMPOSITING)
525     PlatformLayer* platformLayer() const { return 0; }
526 #endif
527 #endif
528     bool makeContextCurrent();
529
530 #if PLATFORM(MAC) || PLATFORM(CHROMIUM) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL)
531     // With multisampling on, blit from multisampleFBO to regular FBO.
532     void prepareTexture();
533 #endif
534
535     // Helper to texImage2D with pixel==0 case: pixels are initialized to 0.
536     // Return true if no GL error is synthesized.
537     // By default, alignment is 4, the OpenGL default setting.
538     bool texImage2DResourceSafe(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, GC3Dint alignment = 4);
539
540     bool isGLES2Compliant() const;
541
542     //----------------------------------------------------------------------
543     // Helpers for texture uploading and pixel readback.
544     //
545
546     // Computes the components per pixel and bytes per component
547     // for the given format and type combination. Returns false if
548     // either was an invalid enum.
549     static bool computeFormatAndTypeParameters(GC3Denum format,
550                                                GC3Denum type,
551                                                unsigned int* componentsPerPixel,
552                                                unsigned int* bytesPerComponent);
553
554     // Computes the image size in bytes. If paddingInBytes is not null, padding
555     // is also calculated in return. Returns NO_ERROR if succeed, otherwise
556     // return the suggested GL error indicating the cause of the failure:
557     //   INVALID_VALUE if width/height is negative or overflow happens.
558     //   INVALID_ENUM if format/type is illegal.
559     static GC3Denum computeImageSizeInBytes(GC3Denum format,
560                                      GC3Denum type,
561                                      GC3Dsizei width,
562                                      GC3Dsizei height,
563                                      GC3Dint alignment,
564                                      unsigned int* imageSizeInBytes,
565                                      unsigned int* paddingInBytes);
566
567     // Extracts the contents of the given Image into the passed Vector,
568     // packing the pixel data according to the given format and type,
569     // and obeying the flipY, premultiplyAlpha, and ignoreGammaAndColorProfile
570     // flags. Returns true upon success.
571     static bool extractImageData(Image*,
572                           GC3Denum format,
573                           GC3Denum type,
574                           bool flipY,
575                           bool premultiplyAlpha,
576                           bool ignoreGammaAndColorProfile,
577                           Vector<uint8_t>& data);
578
579     // Extracts the contents of the given ImageData into the passed Vector,
580     // packing the pixel data according to the given format and type,
581     // and obeying the flipY and premultiplyAlpha flags. Returns true
582     // upon success.
583     static bool extractImageData(ImageData*,
584                           GC3Denum format,
585                           GC3Denum type,
586                           bool flipY,
587                           bool premultiplyAlpha,
588                           Vector<uint8_t>& data);
589
590     // Helper function which extracts the user-supplied texture
591     // data, applying the flipY and premultiplyAlpha parameters.
592     // If the data is not tightly packed according to the passed
593     // unpackAlignment, the output data will be tightly packed.
594     // Returns true if successful, false if any error occurred.
595     static bool extractTextureData(unsigned int width, unsigned int height,
596                             GC3Denum format, GC3Denum type,
597                             unsigned int unpackAlignment,
598                             bool flipY, bool premultiplyAlpha,
599                             const void* pixels,
600                             Vector<uint8_t>& data);
601
602     // Flips the given image data vertically, in-place.
603     static void flipVertically(void* imageData,
604                         unsigned int width,
605                         unsigned int height,
606                         unsigned int bytesPerPixel,
607                         unsigned int unpackAlignment);
608
609     // Attempt to enumerate all possible native image formats to
610     // reduce the amount of temporary allocations during texture
611     // uploading. This enum must be public because it is accessed
612     // by non-member functions.
613     enum SourceDataFormat {
614         SourceFormatRGBA8 = 0,
615         SourceFormatRGBA16Little,
616         SourceFormatRGBA16Big,
617         SourceFormatRGBA32F,
618         SourceFormatRGB8,
619         SourceFormatRGB16Little,
620         SourceFormatRGB16Big,
621         SourceFormatRGB32F,
622         SourceFormatBGR8,
623         SourceFormatBGRA8,
624         SourceFormatBGRA16Little,
625         SourceFormatBGRA16Big,
626         SourceFormatARGB8,
627         SourceFormatARGB16Little,
628         SourceFormatARGB16Big,
629         SourceFormatABGR8,
630         SourceFormatRGBA5551,
631         SourceFormatRGBA4444,
632         SourceFormatRGB565,
633         SourceFormatR8,
634         SourceFormatR16Little,
635         SourceFormatR16Big,
636         SourceFormatR32F,
637         SourceFormatRA8,
638         SourceFormatRA16Little,
639         SourceFormatRA16Big,
640         SourceFormatRA32F,
641         SourceFormatAR8,
642         SourceFormatAR16Little,
643         SourceFormatAR16Big,
644         SourceFormatA8,
645         SourceFormatA16Little,
646         SourceFormatA16Big,
647         SourceFormatA32F,
648         SourceFormatNumFormats
649     };
650
651     //----------------------------------------------------------------------
652     // Entry points for WebGL.
653     //
654
655     void activeTexture(GC3Denum texture);
656     void attachShader(Platform3DObject program, Platform3DObject shader);
657     void bindAttribLocation(Platform3DObject, GC3Duint index, const String& name);
658     void bindBuffer(GC3Denum target, Platform3DObject);
659     void bindFramebuffer(GC3Denum target, Platform3DObject);
660     void bindRenderbuffer(GC3Denum target, Platform3DObject);
661     void bindTexture(GC3Denum target, Platform3DObject);
662     void blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha);
663     void blendEquation(GC3Denum mode);
664     void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha);
665     void blendFunc(GC3Denum sfactor, GC3Denum dfactor);
666     void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha);
667
668     void bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage);
669     void bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage);
670     void bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data);
671
672     GC3Denum checkFramebufferStatus(GC3Denum target);
673     void clear(GC3Dbitfield mask);
674     void clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha);
675     void clearDepth(GC3Dclampf depth);
676     void clearStencil(GC3Dint s);
677     void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha);
678     void compileShader(Platform3DObject);
679
680     void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data);
681     void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data);
682     void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border);
683     void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
684     void cullFace(GC3Denum mode);
685     void depthFunc(GC3Denum func);
686     void depthMask(GC3Dboolean flag);
687     void depthRange(GC3Dclampf zNear, GC3Dclampf zFar);
688     void detachShader(Platform3DObject, Platform3DObject);
689     void disable(GC3Denum cap);
690     void disableVertexAttribArray(GC3Duint index);
691     void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count);
692     void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset);
693
694     void enable(GC3Denum cap);
695     void enableVertexAttribArray(GC3Duint index);
696     void finish();
697     void flush();
698     void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject);
699     void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject, GC3Dint level);
700     void frontFace(GC3Denum mode);
701     void generateMipmap(GC3Denum target);
702
703     bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&);
704     bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&);
705     void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders);
706     GC3Dint getAttribLocation(Platform3DObject, const String& name);
707     void getBooleanv(GC3Denum pname, GC3Dboolean* value);
708     void getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
709     Attributes getContextAttributes();
710     GC3Denum getError();
711     void getFloatv(GC3Denum pname, GC3Dfloat* value);
712     void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value);
713     void getIntegerv(GC3Denum pname, GC3Dint* value);
714     void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value);
715     String getProgramInfoLog(Platform3DObject);
716     void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
717     void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value);
718     String getShaderInfoLog(Platform3DObject);
719     void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision);
720     String getShaderSource(Platform3DObject);
721     String getString(GC3Denum name);
722     void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value);
723     void getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
724     void getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value);
725     void getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value);
726     GC3Dint getUniformLocation(Platform3DObject, const String& name);
727     void getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value);
728     void getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value);
729     GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname);
730
731     void hint(GC3Denum target, GC3Denum mode);
732     GC3Dboolean isBuffer(Platform3DObject);
733     GC3Dboolean isEnabled(GC3Denum cap);
734     GC3Dboolean isFramebuffer(Platform3DObject);
735     GC3Dboolean isProgram(Platform3DObject);
736     GC3Dboolean isRenderbuffer(Platform3DObject);
737     GC3Dboolean isShader(Platform3DObject);
738     GC3Dboolean isTexture(Platform3DObject);
739     void lineWidth(GC3Dfloat);
740     void linkProgram(Platform3DObject);
741     void pixelStorei(GC3Denum pname, GC3Dint param);
742     void polygonOffset(GC3Dfloat factor, GC3Dfloat units);
743
744     void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data);
745
746     void releaseShaderCompiler();
747
748     void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height);
749     void sampleCoverage(GC3Dclampf value, GC3Dboolean invert);
750     void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
751     void shaderSource(Platform3DObject, const String& string);
752     void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask);
753     void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask);
754     void stencilMask(GC3Duint mask);
755     void stencilMaskSeparate(GC3Denum face, GC3Duint mask);
756     void stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass);
757     void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass);
758
759     bool texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels);
760     void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param);
761     void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param);
762     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels);
763
764     void uniform1f(GC3Dint location, GC3Dfloat x);
765     void uniform1fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v);
766     void uniform1i(GC3Dint location, GC3Dint x);
767     void uniform1iv(GC3Dint location, GC3Dsizei, GC3Dint* v);
768     void uniform2f(GC3Dint location, GC3Dfloat x, GC3Dfloat y);
769     void uniform2fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v);
770     void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y);
771     void uniform2iv(GC3Dint location, GC3Dsizei, GC3Dint* v);
772     void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z);
773     void uniform3fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v);
774     void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z);
775     void uniform3iv(GC3Dint location, GC3Dsizei, GC3Dint* v);
776     void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w);
777     void uniform4fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v);
778     void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w);
779     void uniform4iv(GC3Dint location, GC3Dsizei, GC3Dint* v);
780     void uniformMatrix2fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value);
781     void uniformMatrix3fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value);
782     void uniformMatrix4fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value);
783
784     void useProgram(Platform3DObject);
785     void validateProgram(Platform3DObject);
786
787     void vertexAttrib1f(GC3Duint index, GC3Dfloat x);
788     void vertexAttrib1fv(GC3Duint index, GC3Dfloat* values);
789     void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y);
790     void vertexAttrib2fv(GC3Duint index, GC3Dfloat* values);
791     void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z);
792     void vertexAttrib3fv(GC3Duint index, GC3Dfloat* values);
793     void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w);
794     void vertexAttrib4fv(GC3Duint index, GC3Dfloat* values);
795     void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized,
796                              GC3Dsizei stride, GC3Dintptr offset);
797
798     void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
799
800     void reshape(int width, int height);
801
802 #if PLATFORM(EFL)
803     void modifySurface(Evas_Object* evas);
804 #endif
805
806 #if USE(CG)
807     static void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
808                               int canvasWidth, int canvasHeight, CGContextRef);
809 #elif PLATFORM(GTK) || PLATFORM(EFL)
810     void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
811                        int canvasWidth, int canvasHeight, PlatformContextCairo* context);
812 #elif PLATFORM(QT)
813     void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
814                        int canvasWidth, int canvasHeight, QPainter* context);
815 #elif PLATFORM(BLACKBERRY)
816     void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
817                        int canvasWidth, int canvasHeight, GraphicsContext*);
818 #endif
819
820     void markContextChanged();
821     void markLayerComposited();
822     bool layerComposited() const;
823
824     void paintRenderingResultsToCanvas(ImageBuffer*, DrawingBuffer*);
825     PassRefPtr<ImageData> paintRenderingResultsToImageData(DrawingBuffer*);
826     bool paintCompositedResultsToCanvas(ImageBuffer*);
827
828 #if PLATFORM(EFL)
829     void readRenderingResults(unsigned char* pixels, int pixelsSize);
830 #endif
831
832     // Support for buffer creation and deletion
833     Platform3DObject createBuffer();
834     Platform3DObject createFramebuffer();
835     Platform3DObject createProgram();
836     Platform3DObject createRenderbuffer();
837     Platform3DObject createShader(GC3Denum);
838     Platform3DObject createTexture();
839
840     void deleteBuffer(Platform3DObject);
841     void deleteFramebuffer(Platform3DObject);
842     void deleteProgram(Platform3DObject);
843     void deleteRenderbuffer(Platform3DObject);
844     void deleteShader(Platform3DObject);
845     void deleteTexture(Platform3DObject);
846
847     // Synthesizes an OpenGL error which will be returned from a
848     // later call to getError. This is used to emulate OpenGL ES
849     // 2.0 behavior on the desktop and to enforce additional error
850     // checking mandated by WebGL.
851     //
852     // Per the behavior of glGetError, this stores at most one
853     // instance of any given error, and returns them from calls to
854     // getError in the order they were added.
855     void synthesizeGLError(GC3Denum error);
856
857     // Support for extensions. Returns a non-null object, though not
858     // all methods it contains may necessarily be supported on the
859     // current hardware. Must call Extensions3D::supports() to
860     // determine this.
861     Extensions3D* getExtensions();
862
863     IntSize getInternalFramebufferSize() const;
864
865     static unsigned getClearBitsByAttachmentType(GC3Denum);
866     static unsigned getClearBitsByFormat(GC3Denum);
867
868     enum ChannelBits {
869         ChannelRed = 1,
870         ChannelGreen = 2,
871         ChannelBlue = 4,
872         ChannelAlpha = 8,
873         ChannelDepth = 16,
874         ChannelStencil = 32,
875         ChannelRGB = ChannelRed | ChannelGreen | ChannelBlue,
876         ChannelRGBA = ChannelRGB | ChannelAlpha,
877     };
878
879     static unsigned getChannelBitsByFormat(GC3Denum);
880
881   private:
882     GraphicsContext3D(Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow);
883
884     // Each platform must provide an implementation of this method.
885     //
886     // Gets the data for the given Image into outputVector in the
887     // format specified by the (OpenGL-style) format and type
888     // arguments. Despite the fact that the outputVector contains
889     // uint8_t, if the format and type specify packed pixels, then
890     // it will essentially contain uint16_t after the extraction
891     // process.
892     //
893     // If premultiplyAlpha is true, the alpha channel, if any,
894     // will be multiplied into the color channels during the
895     // extraction process. This premultiplication occurs before
896     // any packing of pixel data.
897     //
898     // If ignoreGammaAndColorProfile is true, gamma correction and ICC
899     // profile won't be applied.
900     //
901     // No vertical flip of the image data is performed by this
902     // method.
903     static bool getImageData(Image*,
904                       GC3Denum format,
905                       GC3Denum type,
906                       bool premultiplyAlpha,
907                       bool ignoreGammaAndColorProfile,
908                       Vector<uint8_t>& outputVector);
909
910     // Possible alpha operations that may need to occur during
911     // pixel packing. FIXME: kAlphaDoUnmultiply is lossy and must
912     // be removed.
913     enum AlphaOp {
914         AlphaDoNothing = 0,
915         AlphaDoPremultiply = 1,
916         AlphaDoUnmultiply = 2
917     };
918
919     // Helper for getImageData which implements packing of pixel
920     // data into the specified OpenGL destination format and type.
921     // A sourceUnpackAlignment of zero indicates that the source
922     // data is tightly packed. Non-zero values may take a slow path.
923     // Destination data will have no gaps between rows.
924     static bool packPixels(const uint8_t* sourceData,
925                     SourceDataFormat sourceDataFormat,
926                     unsigned int width,
927                     unsigned int height,
928                     unsigned int sourceUnpackAlignment,
929                     unsigned int destinationFormat,
930                     unsigned int destinationType,
931                     AlphaOp alphaOp,
932                     void* destinationData);
933
934 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT)
935     // Take into account the user's requested context creation attributes,
936     // in particular stencil and antialias, and determine which could or
937     // could not be honored based on the capabilities of the OpenGL
938     // implementation.
939     void validateDepthStencil(const char* packedDepthStencilExtension);
940     void validateAttributes();
941
942     // Read rendering results into a pixel array with the same format as the
943     // backbuffer.
944     void readRenderingResults(unsigned char* pixels, int pixelsSize);
945     void readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels);
946 #endif
947
948 #if PLATFORM(BLACKBERRY)
949     void logFrameBufferStatus(int line);
950     void readPixelsIMG(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data);
951 #endif
952
953     bool reshapeFBOs(const IntSize&);
954     void resolveMultisamplingIfNecessary(const IntRect& = IntRect());
955 #if PLATFORM(QT) && USE(GRAPHICS_SURFACE) || ENABLE(TIZEN_CANVAS_GRAPHICS_SURFACE)
956     void createGraphicsSurfaces(const IntSize&);
957 #endif
958
959     int m_currentWidth, m_currentHeight;
960     bool isResourceSafe();
961
962 #if PLATFORM(MAC)
963     CGLContextObj m_contextObj;
964     RetainPtr<WebGLLayer> m_webGLLayer;
965 #elif PLATFORM(BLACKBERRY)
966 #if USE(ACCELERATED_COMPOSITING)
967     RefPtr<PlatformLayer> m_compositingLayer;
968 #endif
969     void* m_context;
970 #endif
971
972 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT)
973     typedef struct {
974         String source;
975         String log;
976         bool isValid;
977     } ShaderSourceEntry;
978     HashMap<Platform3DObject, ShaderSourceEntry> m_shaderSourceMap;
979
980     ANGLEWebKitBridge m_compiler;
981 #endif
982
983 #if PLATFORM(BLACKBERRY) || (PLATFORM(QT) && defined(QT_OPENGL_ES_2))
984     friend class Extensions3DOpenGLES;
985     OwnPtr<Extensions3DOpenGLES> m_extensions;
986 #elif !PLATFORM(CHROMIUM) && !OS(TIZEN)
987     friend class Extensions3DOpenGL;
988     OwnPtr<Extensions3DOpenGL> m_extensions;
989 #endif
990     friend class Extensions3DOpenGLCommon;
991
992     Attributes m_attrs;
993     Vector<Vector<float> > m_vertexArray;
994
995     GC3Duint m_texture;
996 #if !PLATFORM(BLACKBERRY)
997     GC3Duint m_compositorTexture;
998 #endif
999     GC3Duint m_fbo;
1000
1001 #if !PLATFORM(BLACKBERRY)
1002     GC3Duint m_depthBuffer;
1003     GC3Duint m_stencilBuffer;
1004 #endif
1005     GC3Duint m_depthStencilBuffer;
1006
1007     bool m_layerComposited;
1008     GC3Duint m_internalColorFormat;
1009
1010     // For tracking which FBO/texture is bound
1011     GC3Duint m_boundFBO;
1012     GC3Denum m_activeTexture;
1013     GC3Duint m_boundTexture0;
1014
1015     // For multisampling
1016     GC3Duint m_multisampleFBO;
1017     GC3Duint m_multisampleDepthStencilBuffer;
1018     GC3Duint m_multisampleColorBuffer;
1019
1020     // Errors raised by synthesizeGLError().
1021     ListHashSet<GC3Denum> m_syntheticErrors;
1022
1023 #if PLATFORM(BLACKBERRY)
1024     bool m_isImaginationHardware;
1025 #endif
1026
1027 #if OS(TIZEN)
1028     friend class GraphicsContext3DInternal;
1029     OwnPtr<GraphicsContext3DInternal> m_internal;
1030 #endif
1031
1032 #if !PLATFORM(BLACKBERRY) && !OS(TIZEN)
1033     friend class GraphicsContext3DPrivate;
1034     OwnPtr<GraphicsContext3DPrivate> m_private;
1035 #endif
1036     bool systemAllowsMultisamplingOnATICards() const;
1037 };
1038
1039 } // namespace WebCore
1040
1041 #endif // GraphicsContext3D_h