Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContext.h

Issue 24096029: Moved the majority of WebGL functionality into WebGLRenderingContextBase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed typo in gypi, was only causing issues on Windows (?!?) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef WebGLRenderingContext_h 26 #ifndef WebGLRenderingContext_h
27 #define WebGLRenderingContext_h 27 #define WebGLRenderingContext_h
28 28
29 #include "core/dom/ActiveDOMObject.h" 29 #include "core/html/canvas/WebGLRenderingContextBase.h"
30 #include "core/html/canvas/CanvasRenderingContext.h"
31 #include "core/html/canvas/WebGLGetInfo.h"
32 #include "core/page/Page.h"
33 #include "platform/Timer.h"
34 #include "platform/graphics/GraphicsTypes3D.h"
35 #include "platform/graphics/ImageBuffer.h"
36 #include "platform/graphics/gpu/Extensions3DUtil.h"
37 #include "platform/graphics/gpu/WebGLImageConversion.h"
38 #include "public/platform/WebGraphicsContext3D.h"
39 #include "wtf/Float32Array.h"
40 #include "wtf/Int32Array.h"
41 #include "wtf/OwnPtr.h"
42 #include "wtf/text/WTFString.h"
43
44 namespace blink {
45 class WebLayer;
46 }
47 30
48 namespace WebCore { 31 namespace WebCore {
49 32
50 class ANGLEInstancedArrays; 33 class WebGLRenderingContext FINAL : public WebGLRenderingContextBase {
51 class DrawingBuffer;
52 class EXTFragDepth;
53 class EXTTextureFilterAnisotropic;
54 class ExceptionState;
55 class HTMLImageElement;
56 class HTMLVideoElement;
57 class ImageBuffer;
58 class ImageData;
59 class IntSize;
60 class OESElementIndexUint;
61 class OESStandardDerivatives;
62 class OESTextureFloat;
63 class OESTextureFloatLinear;
64 class OESTextureHalfFloat;
65 class OESTextureHalfFloatLinear;
66 class OESVertexArrayObject;
67 class WebGLActiveInfo;
68 class WebGLBuffer;
69 class WebGLCompressedTextureATC;
70 class WebGLCompressedTexturePVRTC;
71 class WebGLCompressedTextureS3TC;
72 class WebGLContextAttributes;
73 class WebGLContextGroup;
74 class WebGLContextObject;
75 class WebGLDebugRendererInfo;
76 class WebGLDebugShaders;
77 class WebGLDepthTexture;
78 class WebGLDrawBuffers;
79 class WebGLExtension;
80 class WebGLFramebuffer;
81 class WebGLLoseContext;
82 class WebGLObject;
83 class WebGLProgram;
84 class WebGLRenderbuffer;
85 class WebGLShader;
86 class WebGLShaderPrecisionFormat;
87 class WebGLSharedObject;
88 class WebGLTexture;
89 class WebGLUniformLocation;
90 class WebGLVertexArrayObjectOES;
91
92 class WebGLRenderingContextLostCallback;
93 class WebGLRenderingContextErrorMessageCallback;
94
95 class WebGLRenderingContext FINAL : public CanvasRenderingContext, public Active DOMObject, private Page::MultisamplingChangedObserver {
96 public: 34 public:
97 static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLCon textAttributes*); 35 static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLCon textAttributes*);
98 virtual ~WebGLRenderingContext(); 36 virtual ~WebGLRenderingContext();
99 37
100 virtual bool is3d() const OVERRIDE { return true; } 38 virtual unsigned version() const OVERRIDE { return 1; }
101 virtual bool isAccelerated() const OVERRIDE { return true; } 39 virtual String contextName() const OVERRIDE { return "WebGLRenderingContext" ; }
40 virtual void registerContextExtensions() OVERRIDE;
102 41
103 int drawingBufferWidth() const; 42 private:
104 int drawingBufferHeight() const;
105
106 void activeTexture(GLenum texture);
107 void attachShader(WebGLProgram*, WebGLShader*);
108 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name);
109 void bindBuffer(GLenum target, WebGLBuffer*);
110 void bindFramebuffer(GLenum target, WebGLFramebuffer*);
111 void bindRenderbuffer(GLenum target, WebGLRenderbuffer*);
112 void bindTexture(GLenum target, WebGLTexture*);
113 void blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
114 void blendEquation(GLenum mode);
115 void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
116 void blendFunc(GLenum sfactor, GLenum dfactor);
117 void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
118
119 void bufferData(GLenum target, long long size, GLenum usage);
120 void bufferData(GLenum target, ArrayBuffer* data, GLenum usage);
121 void bufferData(GLenum target, ArrayBufferView* data, GLenum usage);
122 void bufferSubData(GLenum target, long long offset, ArrayBuffer* data);
123 void bufferSubData(GLenum target, long long offset, ArrayBufferView* data);
124
125 GLenum checkFramebufferStatus(GLenum target);
126 void clear(GLbitfield mask);
127 void clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
128 void clearDepth(GLfloat);
129 void clearStencil(GLint);
130 void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alp ha);
131 void compileShader(WebGLShader*);
132
133 void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView* data);
134 void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin t yoffset, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* data);
135
136 void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
137 void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoff set, GLint x, GLint y, GLsizei width, GLsizei height);
138
139 PassRefPtr<WebGLBuffer> createBuffer();
140 PassRefPtr<WebGLFramebuffer> createFramebuffer();
141 PassRefPtr<WebGLProgram> createProgram();
142 PassRefPtr<WebGLRenderbuffer> createRenderbuffer();
143 PassRefPtr<WebGLShader> createShader(GLenum type);
144 PassRefPtr<WebGLTexture> createTexture();
145
146 void cullFace(GLenum mode);
147
148 void deleteBuffer(WebGLBuffer*);
149 void deleteFramebuffer(WebGLFramebuffer*);
150 void deleteProgram(WebGLProgram*);
151 void deleteRenderbuffer(WebGLRenderbuffer*);
152 void deleteShader(WebGLShader*);
153 void deleteTexture(WebGLTexture*);
154
155 void depthFunc(GLenum);
156 void depthMask(GLboolean);
157 void depthRange(GLfloat zNear, GLfloat zFar);
158 void detachShader(WebGLProgram*, WebGLShader*);
159 void disable(GLenum cap);
160 void disableVertexAttribArray(GLuint index);
161 void drawArrays(GLenum mode, GLint first, GLsizei count);
162 void drawElements(GLenum mode, GLsizei count, GLenum type, long long offset) ;
163
164 void drawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsiz ei primcount);
165 void drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, GLi ntptr offset, GLsizei primcount);
166
167 void enable(GLenum cap);
168 void enableVertexAttribArray(GLuint index);
169 void finish();
170 void flush();
171 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*);
172 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level);
173 void frontFace(GLenum mode);
174 void generateMipmap(GLenum target);
175
176 PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuint index);
177 PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLuint index);
178 bool getAttachedShaders(WebGLProgram*, Vector<RefPtr<WebGLShader> >&);
179 GLint getAttribLocation(WebGLProgram*, const String& name);
180 WebGLGetInfo getBufferParameter(GLenum target, GLenum pname);
181 PassRefPtr<WebGLContextAttributes> getContextAttributes();
182 GLenum getError();
183 PassRefPtr<WebGLExtension> getExtension(const String& name);
184 WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachm ent, GLenum pname);
185 WebGLGetInfo getParameter(GLenum pname);
186 WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname);
187 String getProgramInfoLog(WebGLProgram*);
188 WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname);
189 WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname);
190 String getShaderInfoLog(WebGLShader*);
191 PassRefPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GLenum shade rType, GLenum precisionType);
192 String getShaderSource(WebGLShader*);
193 Vector<String> getSupportedExtensions();
194 WebGLGetInfo getTexParameter(GLenum target, GLenum pname);
195 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*);
196 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const Str ing&);
197 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname);
198 long long getVertexAttribOffset(GLuint index, GLenum pname);
199
200 void hint(GLenum target, GLenum mode);
201 GLboolean isBuffer(WebGLBuffer*);
202 bool isContextLost();
203 GLboolean isEnabled(GLenum cap);
204 GLboolean isFramebuffer(WebGLFramebuffer*);
205 GLboolean isProgram(WebGLProgram*);
206 GLboolean isRenderbuffer(WebGLRenderbuffer*);
207 GLboolean isShader(WebGLShader*);
208 GLboolean isTexture(WebGLTexture*);
209
210 void lineWidth(GLfloat);
211 void linkProgram(WebGLProgram*);
212 void pixelStorei(GLenum pname, GLint param);
213 void polygonOffset(GLfloat factor, GLfloat units);
214 void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum form at, GLenum type, ArrayBufferView* pixels);
215 void renderbufferStorage(GLenum target, GLenum internalformat, GLsizei width , GLsizei height);
216 void sampleCoverage(GLfloat value, GLboolean invert);
217 void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
218 void shaderSource(WebGLShader*, const String&);
219 void stencilFunc(GLenum func, GLint ref, GLuint mask);
220 void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
221 void stencilMask(GLuint);
222 void stencilMaskSeparate(GLenum face, GLuint mask);
223 void stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
224 void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) ;
225
226 void texImage2D(GLenum target, GLint level, GLenum internalformat,
227 GLsizei width, GLsizei height, GLint border,
228 GLenum format, GLenum type, ArrayBufferView*, ExceptionState&);
229 void texImage2D(GLenum target, GLint level, GLenum internalformat,
230 GLenum format, GLenum type, ImageData*, ExceptionState&);
231 void texImage2D(GLenum target, GLint level, GLenum internalformat,
232 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&);
233 void texImage2D(GLenum target, GLint level, GLenum internalformat,
234 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&);
235 void texImage2D(GLenum target, GLint level, GLenum internalformat,
236 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&);
237
238 void texParameterf(GLenum target, GLenum pname, GLfloat param);
239 void texParameteri(GLenum target, GLenum pname, GLint param);
240
241 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
242 GLsizei width, GLsizei height,
243 GLenum format, GLenum type, ArrayBufferView*, ExceptionState&);
244 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
245 GLenum format, GLenum type, ImageData*, ExceptionState&);
246 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
247 GLenum format, GLenum type, HTMLImageElement*, ExceptionState&);
248 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
249 GLenum format, GLenum type, HTMLCanvasElement*, ExceptionState&);
250 void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
251 GLenum format, GLenum type, HTMLVideoElement*, ExceptionState&);
252
253 void uniform1f(const WebGLUniformLocation*, GLfloat x);
254 void uniform1fv(const WebGLUniformLocation*, Float32Array* v);
255 void uniform1fv(const WebGLUniformLocation*, GLfloat* v, GLsizei);
256 void uniform1i(const WebGLUniformLocation*, GLint x);
257 void uniform1iv(const WebGLUniformLocation*, Int32Array* v);
258 void uniform1iv(const WebGLUniformLocation*, GLint* v, GLsizei);
259 void uniform2f(const WebGLUniformLocation*, GLfloat x, GLfloat y);
260 void uniform2fv(const WebGLUniformLocation*, Float32Array* v);
261 void uniform2fv(const WebGLUniformLocation*, GLfloat* v, GLsizei);
262 void uniform2i(const WebGLUniformLocation*, GLint x, GLint y);
263 void uniform2iv(const WebGLUniformLocation*, Int32Array* v);
264 void uniform2iv(const WebGLUniformLocation*, GLint* v, GLsizei);
265 void uniform3f(const WebGLUniformLocation*, GLfloat x, GLfloat y, GLfloat z) ;
266 void uniform3fv(const WebGLUniformLocation*, Float32Array* v);
267 void uniform3fv(const WebGLUniformLocation*, GLfloat* v, GLsizei);
268 void uniform3i(const WebGLUniformLocation*, GLint x, GLint y, GLint z);
269 void uniform3iv(const WebGLUniformLocation*, Int32Array* v);
270 void uniform3iv(const WebGLUniformLocation*, GLint* v, GLsizei);
271 void uniform4f(const WebGLUniformLocation*, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
272 void uniform4fv(const WebGLUniformLocation*, Float32Array* v);
273 void uniform4fv(const WebGLUniformLocation*, GLfloat* v, GLsizei);
274 void uniform4i(const WebGLUniformLocation*, GLint x, GLint y, GLint z, GLint w);
275 void uniform4iv(const WebGLUniformLocation*, Int32Array* v);
276 void uniform4iv(const WebGLUniformLocation*, GLint* v, GLsizei);
277 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, Floa t32Array* value);
278 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, GLfl oat* value, GLsizei);
279 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, Floa t32Array* value);
280 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, GLfl oat* value, GLsizei);
281 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, Floa t32Array* value);
282 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, GLfl oat* value, GLsizei);
283
284 void useProgram(WebGLProgram*);
285 void validateProgram(WebGLProgram*);
286
287 void vertexAttrib1f(GLuint index, GLfloat x);
288 void vertexAttrib1fv(GLuint index, Float32Array* values);
289 void vertexAttrib1fv(GLuint index, GLfloat* values, GLsizei);
290 void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y);
291 void vertexAttrib2fv(GLuint index, Float32Array* values);
292 void vertexAttrib2fv(GLuint index, GLfloat* values, GLsizei);
293 void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z);
294 void vertexAttrib3fv(GLuint index, Float32Array* values);
295 void vertexAttrib3fv(GLuint index, GLfloat* values, GLsizei);
296 void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
297 void vertexAttrib4fv(GLuint index, Float32Array* values);
298 void vertexAttrib4fv(GLuint index, GLfloat* values, GLsizei);
299 void vertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean no rmalized,
300 GLsizei stride, long long offset);
301
302 void vertexAttribDivisorANGLE(GLuint index, GLuint divisor);
303
304 void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
305
306 // WEBKIT_lose_context support
307 enum LostContextMode {
308 // Lost context occurred at the graphics system level.
309 RealLostContext,
310
311 // Lost context provoked by WEBKIT_lose_context.
312 SyntheticLostContext,
313
314 // A synthetic lost context that should attempt to recover automatically
315 AutoRecoverSyntheticLostContext
316 };
317 void forceLostContext(LostContextMode);
318 void forceRestoreContext();
319 void loseContextImpl(LostContextMode);
320
321 blink::WebGraphicsContext3D* webGraphicsContext3D() const { return m_context .get(); }
322 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); }
323 virtual blink::WebLayer* platformLayer() const OVERRIDE;
324 Extensions3DUtil* extensionsUtil();
325
326 void reshape(int width, int height);
327
328 void markLayerComposited();
329 virtual void paintRenderingResultsToCanvas() OVERRIDE;
330 PassRefPtr<ImageData> paintRenderingResultsToImageData();
331
332 void removeSharedObject(WebGLSharedObject*);
333 void removeContextObject(WebGLContextObject*);
334
335 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; }
336
337 // ActiveDOMObject notifications
338 virtual bool hasPendingActivity() const OVERRIDE;
339 virtual void stop() OVERRIDE;
340
341 private:
342 friend class WebGLDrawBuffers;
343 friend class WebGLFramebuffer;
344 friend class WebGLObject;
345 friend class OESVertexArrayObject;
346 friend class WebGLDebugShaders;
347 friend class WebGLCompressedTextureATC;
348 friend class WebGLCompressedTexturePVRTC;
349 friend class WebGLCompressedTextureS3TC;
350 friend class WebGLRenderingContextErrorMessageCallback;
351 friend class WebGLVertexArrayObjectOES;
352
353 WebGLRenderingContext(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsConte xt3D>, WebGLContextAttributes*); 43 WebGLRenderingContext(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsConte xt3D>, WebGLContextAttributes*);
354 void initializeNewContext();
355 void setupFlags();
356
357 void addSharedObject(WebGLSharedObject*);
358 void addContextObject(WebGLContextObject*);
359 void detachAndRemoveAllObjects();
360
361 void destroyContext();
362 void markContextChanged();
363
364 // Query if the GL implementation is NPOT strict.
365 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; }
366 // Query if depth_stencil buffer is supported.
367 bool isDepthStencilSupported() { return m_isDepthStencilSupported; }
368
369 // Helper to return the size in bytes of OpenGL data types
370 // like GL_FLOAT, GL_INT, etc.
371 unsigned sizeInBytes(GLenum type);
372
373 // Check if each enabled vertex attribute is bound to a buffer.
374 bool validateRenderingState(const char*);
375
376 bool validateWebGLObject(const char*, WebGLObject*);
377
378 // Adds a compressed texture format.
379 void addCompressedTextureFormat(GLenum);
380 void removeAllCompressedTextureFormats();
381
382 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height);
383
384 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy);
385
386 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*);
387
388 OwnPtr<blink::WebGraphicsContext3D> m_context;
389 RefPtr<WebGLContextGroup> m_contextGroup;
390
391 // Structure for rendering to a DrawingBuffer, instead of directly
392 // to the back-buffer of m_context.
393 RefPtr<DrawingBuffer> m_drawingBuffer;
394
395 // Dispatches a context lost event once it is determined that one is needed.
396 // This is used both for synthetic and real context losses. For real ones, i t's
397 // likely that there's no JavaScript on the stack, but that might be depende nt
398 // on how exactly the platform discovers that the context was lost. For bett er
399 // portability we always defer the dispatch of the event.
400 Timer<WebGLRenderingContext> m_dispatchContextLostEventTimer;
401 bool m_restoreAllowed;
402 Timer<WebGLRenderingContext> m_restoreTimer;
403
404 bool m_needsUpdate;
405 bool m_markedCanvasDirty;
406 HashSet<WebGLContextObject*> m_contextObjects;
407
408 OwnPtr<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter;
409 OwnPtr<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdap ter;
410
411 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER
412 RefPtr<WebGLBuffer> m_boundArrayBuffer;
413
414 RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
415 RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
416 void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayOb ject)
417 {
418 if (arrayObject)
419 m_boundVertexArrayObject = arrayObject;
420 else
421 m_boundVertexArrayObject = m_defaultVertexArrayObject;
422 }
423
424 class VertexAttribValue {
425 public:
426 VertexAttribValue()
427 {
428 initValue();
429 }
430
431 void initValue()
432 {
433 value[0] = 0.0f;
434 value[1] = 0.0f;
435 value[2] = 0.0f;
436 value[3] = 1.0f;
437 }
438
439 GLfloat value[4];
440 };
441 Vector<VertexAttribValue> m_vertexAttribValue;
442 unsigned m_maxVertexAttribs;
443 RefPtr<WebGLBuffer> m_vertexAttrib0Buffer;
444 long m_vertexAttrib0BufferSize;
445 GLfloat m_vertexAttrib0BufferValue[4];
446 bool m_forceAttrib0BufferRefill;
447 bool m_vertexAttrib0UsedBefore;
448
449 RefPtr<WebGLProgram> m_currentProgram;
450 RefPtr<WebGLFramebuffer> m_framebufferBinding;
451 RefPtr<WebGLRenderbuffer> m_renderbufferBinding;
452 class TextureUnitState {
453 public:
454 RefPtr<WebGLTexture> m_texture2DBinding;
455 RefPtr<WebGLTexture> m_textureCubeMapBinding;
456 };
457 Vector<TextureUnitState> m_textureUnits;
458 unsigned long m_activeTextureUnit;
459
460 RefPtr<WebGLTexture> m_blackTexture2D;
461 RefPtr<WebGLTexture> m_blackTextureCubeMap;
462
463 Vector<GLenum> m_compressedTextureFormats;
464
465 // Fixed-size cache of reusable image buffers for video texImage2D calls.
466 class LRUImageBufferCache {
467 public:
468 LRUImageBufferCache(int capacity);
469 // The pointer returned is owned by the image buffer map.
470 ImageBuffer* imageBuffer(const IntSize& size);
471 private:
472 void bubbleToFront(int idx);
473 OwnPtr<OwnPtr<ImageBuffer>[]> m_buffers;
474 int m_capacity;
475 };
476 LRUImageBufferCache m_generatedImageCache;
477
478 GLint m_maxTextureSize;
479 GLint m_maxCubeMapTextureSize;
480 GLint m_maxRenderbufferSize;
481 GLint m_maxViewportDims[2];
482 GLint m_maxTextureLevel;
483 GLint m_maxCubeMapTextureLevel;
484
485 GLint m_maxDrawBuffers;
486 GLint m_maxColorAttachments;
487 GLenum m_backDrawBuffer;
488 bool m_drawBuffersWebGLRequirementsChecked;
489 bool m_drawBuffersSupported;
490
491 GLint m_packAlignment;
492 GLint m_unpackAlignment;
493 bool m_unpackFlipY;
494 bool m_unpackPremultiplyAlpha;
495 GLenum m_unpackColorspaceConversion;
496 bool m_contextLost;
497 LostContextMode m_contextLostMode;
498 RefPtr<WebGLContextAttributes> m_requestedAttributes;
499
500 bool m_layerCleared;
501 GLfloat m_clearColor[4];
502 bool m_scissorEnabled;
503 GLfloat m_clearDepth;
504 GLint m_clearStencil;
505 GLboolean m_colorMask[4];
506 GLboolean m_depthMask;
507
508 bool m_stencilEnabled;
509 GLuint m_stencilMask, m_stencilMaskBack;
510 GLint m_stencilFuncRef, m_stencilFuncRefBack; // Note that these are the use r specified values, not the internal clamped value.
511 GLuint m_stencilFuncMask, m_stencilFuncMaskBack;
512
513 bool m_isGLES2NPOTStrict;
514 bool m_isDepthStencilSupported;
515
516 bool m_synthesizedErrorsToConsole;
517 int m_numGLErrorsToConsoleAllowed;
518
519 bool m_multisamplingAllowed;
520 bool m_multisamplingObserverRegistered;
521
522 GLuint m_onePlusMaxEnabledAttribIndex;
523 unsigned long m_onePlusMaxNonDefaultTextureUnit;
524
525 OwnPtr<Extensions3DUtil> m_extensionsUtil;
526 44
527 // Enabled extension objects. 45 // Enabled extension objects.
528 RefPtr<ANGLEInstancedArrays> m_angleInstancedArrays; 46 RefPtr<ANGLEInstancedArrays> m_angleInstancedArrays;
529 RefPtr<EXTFragDepth> m_extFragDepth; 47 RefPtr<EXTFragDepth> m_extFragDepth;
530 RefPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic; 48 RefPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic;
531 RefPtr<OESTextureFloat> m_oesTextureFloat; 49 RefPtr<OESTextureFloat> m_oesTextureFloat;
532 RefPtr<OESTextureFloatLinear> m_oesTextureFloatLinear; 50 RefPtr<OESTextureFloatLinear> m_oesTextureFloatLinear;
533 RefPtr<OESTextureHalfFloat> m_oesTextureHalfFloat; 51 RefPtr<OESTextureHalfFloat> m_oesTextureHalfFloat;
534 RefPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear; 52 RefPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear;
535 RefPtr<OESStandardDerivatives> m_oesStandardDerivatives; 53 RefPtr<OESStandardDerivatives> m_oesStandardDerivatives;
536 RefPtr<OESVertexArrayObject> m_oesVertexArrayObject; 54 RefPtr<OESVertexArrayObject> m_oesVertexArrayObject;
537 RefPtr<OESElementIndexUint> m_oesElementIndexUint; 55 RefPtr<OESElementIndexUint> m_oesElementIndexUint;
538 RefPtr<WebGLLoseContext> m_webglLoseContext; 56 RefPtr<WebGLLoseContext> m_webglLoseContext;
539 RefPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo; 57 RefPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo;
540 RefPtr<WebGLDebugShaders> m_webglDebugShaders; 58 RefPtr<WebGLDebugShaders> m_webglDebugShaders;
541 RefPtr<WebGLDrawBuffers> m_webglDrawBuffers; 59 RefPtr<WebGLDrawBuffers> m_webglDrawBuffers;
542 RefPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC; 60 RefPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC;
543 RefPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC; 61 RefPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC;
544 RefPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC; 62 RefPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC;
545 RefPtr<WebGLDepthTexture> m_webglDepthTexture; 63 RefPtr<WebGLDepthTexture> m_webglDepthTexture;
546
547 enum ExtensionFlags {
548 ApprovedExtension = 0x00,
549 DraftExtension = 0x01,
550 PrivilegedExtension = 0x02,
551 PrefixedExtension = 0x04,
552 WebGLDebugRendererInfoExtension = 0x08,
553 };
554
555 class ExtensionTracker {
556 public:
557 ExtensionTracker(ExtensionFlags flags, const char* const* prefixes)
558 : m_privileged(flags & PrivilegedExtension)
559 , m_draft(flags & DraftExtension)
560 , m_prefixed(flags & PrefixedExtension)
561 , m_webglDebugRendererInfo(flags & WebGLDebugRendererInfoExtension)
562 , m_prefixes(prefixes)
563 {
564 }
565
566 virtual ~ExtensionTracker()
567 {
568 }
569
570 bool prefixed() const
571 {
572 return m_prefixed;
573 }
574
575 bool privileged() const
576 {
577 return m_privileged;
578 }
579
580 bool draft() const
581 {
582 return m_draft;
583 }
584
585 bool webglDebugRendererInfo() const
586 {
587 return m_webglDebugRendererInfo;
588 }
589
590 bool matchesNameWithPrefixes(const String&) const;
591
592 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext*) const = 0;
593 virtual bool supported(WebGLRenderingContext*) const = 0;
594 virtual const char* extensionName() const = 0;
595 virtual void loseExtension() = 0;
596
597 private:
598 bool m_privileged;
599 bool m_draft;
600 bool m_prefixed;
601 bool m_webglDebugRendererInfo;
602 const char* const* m_prefixes;
603 };
604
605 template <typename T>
606 class TypedExtensionTracker FINAL : public ExtensionTracker {
607 public:
608 TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes)
609 : ExtensionTracker(flags, prefixes)
610 , m_extensionField(extensionField)
611 {
612 }
613
614 virtual ~TypedExtensionTracker()
615 {
616 if (m_extensionField) {
617 m_extensionField->lose(true);
618 m_extensionField = nullptr;
619 }
620 }
621
622 virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext* c ontext) const OVERRIDE
623 {
624 if (!m_extensionField)
625 m_extensionField = T::create(context);
626
627 return m_extensionField;
628 }
629
630 virtual bool supported(WebGLRenderingContext* context) const OVERRIDE
631 {
632 return T::supported(context);
633 }
634
635 virtual const char* extensionName() const OVERRIDE
636 {
637 return T::extensionName();
638 }
639
640 virtual void loseExtension() OVERRIDE
641 {
642 if (m_extensionField) {
643 m_extensionField->lose(false);
644 if (m_extensionField->isLost())
645 m_extensionField = nullptr;
646 }
647 }
648
649 private:
650 RefPtr<T>& m_extensionField;
651 };
652
653 Vector<ExtensionTracker*> m_extensions;
654
655 template <typename T>
656 void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = Appro vedExtension, const char* const* prefixes = 0)
657 {
658 m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, pr efixes));
659 }
660
661 // Errors raised by synthesizeGLError() while the context is lost.
662 Vector<GLenum> m_lostContextErrors;
663
664 // Helpers for getParameter and others
665 WebGLGetInfo getBooleanParameter(GLenum);
666 WebGLGetInfo getBooleanArrayParameter(GLenum);
667 WebGLGetInfo getFloatParameter(GLenum);
668 WebGLGetInfo getIntParameter(GLenum);
669 WebGLGetInfo getUnsignedIntParameter(GLenum);
670 WebGLGetInfo getWebGLFloatArrayParameter(GLenum);
671 WebGLGetInfo getWebGLIntArrayParameter(GLenum);
672
673 // Clear the backbuffer if it was composited since the last operation.
674 // clearMask is set to the bitfield of any clear that would happen anyway at this time
675 // and the function returns true if that clear is now unnecessary.
676 bool clearIfComposited(GLbitfield clearMask = 0);
677
678 // Helper to restore state that clearing the framebuffer may destroy.
679 void restoreStateAfterClear();
680
681 // Convert texture internal format.
682 GLenum convertTexInternalFormat(GLenum internalformat, GLenum type);
683
684 void texImage2DBase(GLenum target, GLint level, GLenum internalformat, GLsiz ei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels, ExceptionState&);
685 void texImage2DImpl(GLenum target, GLint level, GLenum internalformat, GLenu m format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSource, bool fl ipY, bool premultiplyAlpha, ExceptionState&);
686 void texSubImage2DBase(GLenum target, GLint level, GLint xoffset, GLint yoff set, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixe ls, ExceptionState&);
687 void texSubImage2DImpl(GLenum target, GLint level, GLint xoffset, GLint yoff set, GLenum format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSourc e, bool flipY, bool premultiplyAlpha, ExceptionState&);
688
689 void handleTextureCompleteness(const char*, bool);
690 void createFallbackBlackTextures1x1();
691
692 // Helper function for copyTex{Sub}Image, check whether the internalformat
693 // and the color buffer format of the current bound framebuffer combination
694 // is valid.
695 bool isTexInternalFormatColorBufferCombinationValid(GLenum texInternalFormat , GLenum colorBufferFormat);
696
697 // Helper function to get the bound framebuffer's color buffer format.
698 GLenum boundFramebufferColorFormat();
699
700 // Helper function to verify limits on the length of uniform and attribute l ocations.
701 bool validateLocationLength(const char* functionName, const String&);
702
703 // Helper function to check if size is non-negative.
704 // Generate GL error and return false for negative inputs; otherwise, return true.
705 bool validateSize(const char* functionName, GLint x, GLint y);
706
707 // Helper function to check if all characters in the string belong to the
708 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1.
709 bool validateString(const char* functionName, const String&);
710
711 // Helper function to check target and texture bound to the target.
712 // Generate GL errors and return 0 if target is invalid or texture bound is
713 // null. Otherwise, return the texture bound to the target.
714 WebGLTexture* validateTextureBinding(const char* functionName, GLenum target , bool useSixEnumsForCubeMap);
715
716 // Helper function to check input format/type for functions {copy}Tex{Sub}Im age.
717 // Generates GL error and returns false if parameters are invalid.
718 bool validateTexFuncFormatAndType(const char* functionName, GLenum format, G Lenum type, GLint level);
719
720 // Helper function to check input level for functions {copy}Tex{Sub}Image.
721 // Generates GL error and returns false if level is invalid.
722 bool validateTexFuncLevel(const char* functionName, GLenum target, GLint lev el);
723
724 enum TexFuncValidationFunctionType {
725 NotTexSubImage2D,
726 TexSubImage2D,
727 };
728
729 enum TexFuncValidationSourceType {
730 SourceArrayBufferView,
731 SourceImageData,
732 SourceHTMLImageElement,
733 SourceHTMLCanvasElement,
734 SourceHTMLVideoElement,
735 };
736
737 // Helper function for tex{Sub}Image2D to check if the input format/type/lev el/target/width/height/border/xoffset/yoffset are valid.
738 // Otherwise, it would return quickly without doing other work.
739 bool validateTexFunc(const char* functionName, TexFuncValidationFunctionType , TexFuncValidationSourceType, GLenum target, GLint level, GLenum internalformat , GLsizei width,
740 GLsizei height, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset);
741
742 // Helper function to check input width and height for functions {copy, comp ressed}Tex{Sub}Image.
743 // Generates GL error and returns false if width or height is invalid.
744 bool validateTexFuncDimensions(const char* functionName, TexFuncValidationFu nctionType, GLenum target, GLint level, GLsizei width, GLsizei height);
745
746 // Helper function to check input parameters for functions {copy}Tex{Sub}Ima ge.
747 // Generates GL error and returns false if parameters are invalid.
748 bool validateTexFuncParameters(const char* functionName, TexFuncValidationFu nctionType, GLenum target, GLint level, GLenum internalformat, GLsizei width, GL sizei height, GLint border, GLenum format, GLenum type);
749
750 enum NullDisposition {
751 NullAllowed,
752 NullNotAllowed
753 };
754
755 // Helper function to validate that the given ArrayBufferView
756 // is of the correct type and contains enough data for the texImage call.
757 // Generates GL error and returns false if parameters are invalid.
758 bool validateTexFuncData(const char* functionName, GLint level, GLsizei widt h, GLsizei height, GLenum format, GLenum type, ArrayBufferView* pixels, NullDisp osition);
759
760 // Helper function to validate a given texture format is settable as in
761 // you can supply data to texImage2D, or call texImage2D, copyTexImage2D and
762 // copyTexSubImage2D.
763 // Generates GL error and returns false if the format is not settable.
764 bool validateSettableTexFormat(const char* functionName, GLenum format);
765
766 // Helper function to validate compressed texture data is correct size
767 // for the given format and dimensions.
768 bool validateCompressedTexFuncData(const char* functionName, GLsizei width, GLsizei height, GLenum format, ArrayBufferView* pixels);
769
770 // Helper function for validating compressed texture formats.
771 bool validateCompressedTexFormat(GLenum format);
772
773 // Helper function to validate compressed texture dimensions are valid for
774 // the given format.
775 bool validateCompressedTexDimensions(const char* functionName, TexFuncValida tionFunctionType, GLenum target, GLint level, GLsizei width, GLsizei height, GLe num format);
776
777 // Helper function to validate compressed texture dimensions are valid for
778 // the given format.
779 bool validateCompressedTexSubDimensions(const char* functionName, GLenum tar get, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, G Lenum format, WebGLTexture*);
780
781 // Helper function to validate mode for draw{Arrays/Elements}.
782 bool validateDrawMode(const char* functionName, GLenum);
783
784 // Helper function to validate if front/back stencilMask and stencilFunc set tings are the same.
785 bool validateStencilSettings(const char* functionName);
786
787 // Helper function to validate stencil or depth func.
788 bool validateStencilOrDepthFunc(const char* functionName, GLenum);
789
790 // Helper function for texParameterf and texParameteri.
791 void texParameter(GLenum target, GLenum pname, GLfloat parami, GLint paramf, bool isFloat);
792
793 // Helper function to print GL errors to console.
794 void printGLErrorToConsole(const String&);
795
796 // Helper function to print warnings to console. Currently
797 // used only to warn about use of obsolete functions.
798 void printWarningToConsole(const String&);
799
800 // Helper function to validate input parameters for framebuffer functions.
801 // Generate GL error if parameters are illegal.
802 bool validateFramebufferFuncParameters(const char* functionName, GLenum targ et, GLenum attachment);
803
804 // Helper function to validate blend equation mode.
805 bool validateBlendEquation(const char* functionName, GLenum);
806
807 // Helper function to validate blend func factors.
808 bool validateBlendFuncFactors(const char* functionName, GLenum src, GLenum d st);
809
810 // Helper function to validate a GL capability.
811 bool validateCapability(const char* functionName, GLenum);
812
813 // Helper function to validate input parameters for uniform functions.
814 bool validateUniformParameters(const char* functionName, const WebGLUniformL ocation*, Float32Array*, GLsizei mod);
815 bool validateUniformParameters(const char* functionName, const WebGLUniformL ocation*, Int32Array*, GLsizei mod);
816 bool validateUniformParameters(const char* functionName, const WebGLUniformL ocation*, void*, GLsizei, GLsizei mod);
817 bool validateUniformMatrixParameters(const char* functionName, const WebGLUn iformLocation*, GLboolean transpose, Float32Array*, GLsizei mod);
818 bool validateUniformMatrixParameters(const char* functionName, const WebGLUn iformLocation*, GLboolean transpose, void*, GLsizei, GLsizei mod);
819
820 // Helper function to validate parameters for bufferData.
821 // Return the current bound buffer to target, or 0 if parameters are invalid .
822 WebGLBuffer* validateBufferDataParameters(const char* functionName, GLenum t arget, GLenum usage);
823
824 // Helper function for tex{Sub}Image2D to make sure image is ready and would n't taint Origin.
825 bool validateHTMLImageElement(const char* functionName, HTMLImageElement*, E xceptionState&);
826
827 // Helper function for tex{Sub}Image2D to make sure canvas is ready and woul dn't taint Origin.
828 bool validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement*, ExceptionState&);
829
830 // Helper function for tex{Sub}Image2D to make sure video is ready wouldn't taint Origin.
831 bool validateHTMLVideoElement(const char* functionName, HTMLVideoElement*, E xceptionState&);
832
833 // Helper function to validate drawArrays(Instanced) calls
834 bool validateDrawArrays(const char* functionName, GLenum mode, GLint first, GLsizei count);
835
836 // Helper function to validate drawElements(Instanced) calls
837 bool validateDrawElements(const char* functionName, GLenum mode, GLsizei cou nt, GLenum type, long long offset);
838
839 // Helper function to validate draw*Instanced calls
840 bool validateDrawInstanced(const char* functionName, GLsizei primcount);
841
842 // Helper functions for vertexAttribNf{v}.
843 void vertexAttribfImpl(const char* functionName, GLuint index, GLsizei expec tedSize, GLfloat, GLfloat, GLfloat, GLfloat);
844 void vertexAttribfvImpl(const char* functionName, GLuint index, Float32Array *, GLsizei expectedSize);
845 void vertexAttribfvImpl(const char* functionName, GLuint index, GLfloat*, GL sizei, GLsizei expectedSize);
846
847 // Helper function for delete* (deleteBuffer, deleteProgram, etc) functions.
848 // Return false if caller should return without further processing.
849 bool deleteObject(WebGLObject*);
850
851 // Helper function for bind* (bindBuffer, bindTexture, etc) and useProgram.
852 // If the object has already been deleted, set deleted to true upon return.
853 // Return false if caller should return without further processing.
854 bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& dele ted);
855
856 void dispatchContextLostEvent(Timer<WebGLRenderingContext>*);
857 // Helper for restoration after context lost.
858 void maybeRestoreContext(Timer<WebGLRenderingContext>*);
859
860 // Determine if we are running privileged code in the browser, for example,
861 // a Safari or Chrome extension.
862 bool allowPrivilegedExtensions() const;
863
864 // Determine if WEBGL_debug_renderer_info extension is enabled. For the
865 // moment it can be enabled either through a chromium finch experiment
866 // or for privileged code in the browser.
867 bool allowWebGLDebugRendererInfo() const;
868
869 enum ConsoleDisplayPreference {
870 DisplayInConsole,
871 DontDisplayInConsole
872 };
873
874 // Wrapper for WebGraphicsContext3D::synthesizeGLError that sends a message
875 // to the JavaScript console.
876 void synthesizeGLError(GLenum, const char* functionName, const char* descrip tion, ConsoleDisplayPreference = DisplayInConsole);
877 void emitGLWarning(const char* function, const char* reason);
878
879 String ensureNotNull(const String&) const;
880
881 // Enable or disable stencil test based on user setting and
882 // whether the current FBO has a stencil buffer.
883 void applyStencilTest();
884
885 // Helper for enabling or disabling a capability.
886 void enableOrDisable(GLenum capability, bool enable);
887
888 // Clamp the width and height to GL_MAX_VIEWPORT_DIMS.
889 IntSize clampedCanvasSize();
890
891 // First time called, if EXT_draw_buffers is supported, query the value; oth erwise return 0.
892 // Later, return the cached value.
893 GLint maxDrawBuffers();
894 GLint maxColorAttachments();
895
896 void setBackDrawBuffer(GLenum);
897
898 void restoreCurrentFramebuffer();
899 void restoreCurrentTexture2D();
900
901 virtual void multisamplingChanged(bool) OVERRIDE;
902
903 void findNewMaxEnabledAttribIndex();
904 void findNewMaxNonDefaultTextureUnit();
905
906 friend class WebGLStateRestorer;
907 friend class WebGLRenderingContextEvictionManager;
908
909 static Vector<WebGLRenderingContext*>& activeContexts();
910 static Vector<WebGLRenderingContext*>& forciblyEvictedContexts();
911
912 static void activateContext(WebGLRenderingContext*);
913 static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList );
914 static void willDestroyContext(WebGLRenderingContext*);
915 static void forciblyLoseOldestContext(const String& reason);
916 // Return the least recently used context's position in the active context v ector.
917 // If the vector is empty, return the maximum allowed active context number.
918 static size_t oldestContextIndex();
919 static IntSize oldestContextSize();
920 }; 64 };
921 65
922 DEFINE_TYPE_CASTS(WebGLRenderingContext, CanvasRenderingContext, context, contex t->is3d(), context.is3d()); 66 DEFINE_TYPE_CASTS(WebGLRenderingContext, CanvasRenderingContext, context,
67 context->is3d() && WebGLRenderingContextBase::getWebGLVersion(context) == 1,
68 context.is3d() && WebGLRenderingContextBase::getWebGLVersion(&context) == 1) ;
923 69
924 } // namespace WebCore 70 } // namespace WebCore
925 71
926 #endif 72 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698