OLD | NEW |
---|---|
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 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 | 163 |
164 static unsigned getWebGLVersion(const CanvasRenderingContext*); | 164 static unsigned getWebGLVersion(const CanvasRenderingContext*); |
165 | 165 |
166 static PassOwnPtr<WebGraphicsContext3D> createWebGraphicsContext3D(HTMLCanva sElement*, WebGLContextAttributes, unsigned webGLVersion); | 166 static PassOwnPtr<WebGraphicsContext3D> createWebGraphicsContext3D(HTMLCanva sElement*, WebGLContextAttributes, unsigned webGLVersion); |
167 static void forceNextWebGLContextCreationToFail(); | 167 static void forceNextWebGLContextCreationToFail(); |
168 | 168 |
169 int drawingBufferWidth() const; | 169 int drawingBufferWidth() const; |
170 int drawingBufferHeight() const; | 170 int drawingBufferHeight() const; |
171 | 171 |
172 void activeTexture(GLenum texture); | 172 void activeTexture(GLenum texture); |
173 void attachShader(WebGLProgram*, WebGLShader*); | 173 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*); |
174 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); | 174 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); |
175 void bindBuffer(GLenum target, WebGLBuffer*); | 175 void bindBuffer(ScriptState*, GLenum target, WebGLBuffer*); |
176 virtual void bindFramebuffer(GLenum target, WebGLFramebuffer*); | 176 virtual void bindFramebuffer(ScriptState*, GLenum target, WebGLFramebuffer*) ; |
177 void bindRenderbuffer(GLenum target, WebGLRenderbuffer*); | 177 void bindRenderbuffer(ScriptState*, GLenum target, WebGLRenderbuffer*); |
178 void bindTexture(GLenum target, WebGLTexture*); | 178 void bindTexture(ScriptState*, GLenum target, WebGLTexture*); |
179 void blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); | 179 void blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); |
180 void blendEquation(GLenum mode); | 180 void blendEquation(GLenum mode); |
181 void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); | 181 void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); |
182 void blendFunc(GLenum sfactor, GLenum dfactor); | 182 void blendFunc(GLenum sfactor, GLenum dfactor); |
183 void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); | 183 void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); |
184 | 184 |
185 void bufferData(GLenum target, long long size, GLenum usage); | 185 void bufferData(GLenum target, long long size, GLenum usage); |
186 void bufferData(GLenum target, DOMArrayBuffer* data, GLenum usage); | 186 void bufferData(GLenum target, DOMArrayBuffer* data, GLenum usage); |
187 void bufferData(GLenum target, DOMArrayBufferView* data, GLenum usage); | 187 void bufferData(GLenum target, DOMArrayBufferView* data, GLenum usage); |
188 void bufferSubData(GLenum target, long long offset, DOMArrayBuffer* data); | 188 void bufferSubData(GLenum target, long long offset, DOMArrayBuffer* data); |
(...skipping 25 matching lines...) Expand all Loading... | |
214 void deleteBuffer(WebGLBuffer*); | 214 void deleteBuffer(WebGLBuffer*); |
215 virtual void deleteFramebuffer(WebGLFramebuffer*); | 215 virtual void deleteFramebuffer(WebGLFramebuffer*); |
216 void deleteProgram(WebGLProgram*); | 216 void deleteProgram(WebGLProgram*); |
217 void deleteRenderbuffer(WebGLRenderbuffer*); | 217 void deleteRenderbuffer(WebGLRenderbuffer*); |
218 void deleteShader(WebGLShader*); | 218 void deleteShader(WebGLShader*); |
219 void deleteTexture(WebGLTexture*); | 219 void deleteTexture(WebGLTexture*); |
220 | 220 |
221 void depthFunc(GLenum); | 221 void depthFunc(GLenum); |
222 void depthMask(GLboolean); | 222 void depthMask(GLboolean); |
223 void depthRange(GLfloat zNear, GLfloat zFar); | 223 void depthRange(GLfloat zNear, GLfloat zFar); |
224 void detachShader(WebGLProgram*, WebGLShader*); | 224 void detachShader(ScriptState*, WebGLProgram*, WebGLShader*); |
225 void disable(GLenum cap); | 225 void disable(GLenum cap); |
226 void disableVertexAttribArray(GLuint index); | 226 void disableVertexAttribArray(GLuint index); |
227 void drawArrays(GLenum mode, GLint first, GLsizei count); | 227 void drawArrays(GLenum mode, GLint first, GLsizei count); |
228 void drawElements(GLenum mode, GLsizei count, GLenum type, long long offset) ; | 228 void drawElements(GLenum mode, GLsizei count, GLenum type, long long offset) ; |
229 | 229 |
230 void drawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsiz ei primcount); | 230 void drawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsiz ei primcount); |
231 void drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, lon g long offset, GLsizei primcount); | 231 void drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, lon g long offset, GLsizei primcount); |
232 | 232 |
233 void enable(GLenum cap); | 233 void enable(GLenum cap); |
234 void enableVertexAttribArray(GLuint index); | 234 void enableVertexAttribArray(GLuint index); |
235 void finish(); | 235 void finish(); |
236 void flush(); | 236 void flush(); |
237 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*); | 237 void framebufferRenderbuffer(ScriptState*, GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer*); |
238 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level); | 238 void framebufferTexture2D(ScriptState*, GLenum target, GLenum attachment, GL enum textarget, WebGLTexture*, GLint level); |
239 void frontFace(GLenum mode); | 239 void frontFace(GLenum mode); |
240 void generateMipmap(GLenum target); | 240 void generateMipmap(GLenum target); |
241 | 241 |
242 WebGLActiveInfo* getActiveAttrib(WebGLProgram*, GLuint index); | 242 WebGLActiveInfo* getActiveAttrib(WebGLProgram*, GLuint index); |
243 WebGLActiveInfo* getActiveUniform(WebGLProgram*, GLuint index); | 243 WebGLActiveInfo* getActiveUniform(WebGLProgram*, GLuint index); |
244 bool getAttachedShaders(WebGLProgram*, HeapVector<Member<WebGLShader>>&); | 244 bool getAttachedShaders(WebGLProgram*, HeapVector<Member<WebGLShader>>&); |
245 Nullable<HeapVector<Member<WebGLShader>>> getAttachedShaders(WebGLProgram*); | 245 Nullable<HeapVector<Member<WebGLShader>>> getAttachedShaders(WebGLProgram*); |
246 GLint getAttribLocation(WebGLProgram*, const String& name); | 246 GLint getAttribLocation(WebGLProgram*, const String& name); |
247 ScriptValue getBufferParameter(ScriptState*, GLenum target, GLenum pname); | 247 ScriptValue getBufferParameter(ScriptState*, GLenum target, GLenum pname); |
248 void getContextAttributes(Nullable<WebGLContextAttributes>&); | 248 void getContextAttributes(Nullable<WebGLContextAttributes>&); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 void uniform4i(const WebGLUniformLocation*, GLint x, GLint y, GLint z, GLint w); | 341 void uniform4i(const WebGLUniformLocation*, GLint x, GLint y, GLint z, GLint w); |
342 void uniform4iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); | 342 void uniform4iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); |
343 void uniform4iv(const WebGLUniformLocation*, Vector<GLint>&); | 343 void uniform4iv(const WebGLUniformLocation*, Vector<GLint>&); |
344 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); | 344 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); |
345 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); | 345 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); |
346 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); | 346 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); |
347 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); | 347 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); |
348 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); | 348 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); |
349 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); | 349 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); |
350 | 350 |
351 void useProgram(WebGLProgram*); | 351 void useProgram(ScriptState*, WebGLProgram*); |
352 void validateProgram(WebGLProgram*); | 352 void validateProgram(WebGLProgram*); |
353 | 353 |
354 void vertexAttrib1f(GLuint index, GLfloat x); | 354 void vertexAttrib1f(GLuint index, GLfloat x); |
355 void vertexAttrib1fv(GLuint index, const DOMFloat32Array* values); | 355 void vertexAttrib1fv(GLuint index, const DOMFloat32Array* values); |
356 void vertexAttrib1fv(GLuint index, const Vector<GLfloat>& values); | 356 void vertexAttrib1fv(GLuint index, const Vector<GLfloat>& values); |
357 void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y); | 357 void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y); |
358 void vertexAttrib2fv(GLuint index, const DOMFloat32Array* values); | 358 void vertexAttrib2fv(GLuint index, const DOMFloat32Array* values); |
359 void vertexAttrib2fv(GLuint index, const Vector<GLfloat>& values); | 359 void vertexAttrib2fv(GLuint index, const Vector<GLfloat>& values); |
360 void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z); | 360 void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z); |
361 void vertexAttrib3fv(GLuint index, const DOMFloat32Array* values); | 361 void vertexAttrib3fv(GLuint index, const DOMFloat32Array* values); |
362 void vertexAttrib3fv(GLuint index, const Vector<GLfloat>& values); | 362 void vertexAttrib3fv(GLuint index, const Vector<GLfloat>& values); |
363 void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); | 363 void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); |
364 void vertexAttrib4fv(GLuint index, const DOMFloat32Array* values); | 364 void vertexAttrib4fv(GLuint index, const DOMFloat32Array* values); |
365 void vertexAttrib4fv(GLuint index, const Vector<GLfloat>& values); | 365 void vertexAttrib4fv(GLuint index, const Vector<GLfloat>& values); |
366 void vertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean no rmalized, | 366 void vertexAttribPointer(ScriptState*, GLuint index, GLint size, GLenum type , GLboolean normalized, |
367 GLsizei stride, long long offset); | 367 GLsizei stride, long long offset); |
368 | 368 |
369 void vertexAttribDivisorANGLE(GLuint index, GLuint divisor); | 369 void vertexAttribDivisorANGLE(GLuint index, GLuint divisor); |
370 | 370 |
371 void viewport(GLint x, GLint y, GLsizei width, GLsizei height); | 371 void viewport(GLint x, GLint y, GLsizei width, GLsizei height); |
372 | 372 |
373 // WEBGL_lose_context support | 373 // WEBGL_lose_context support |
374 enum AutoRecoveryMethod { | 374 enum AutoRecoveryMethod { |
375 // Don't restore automatically. | 375 // Don't restore automatically. |
376 Manual, | 376 Manual, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 #endif | 524 #endif |
525 | 525 |
526 PersistentWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallb ackAdapter; | 526 PersistentWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallb ackAdapter; |
527 PersistentWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMes sageCallbackAdapter; | 527 PersistentWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMes sageCallbackAdapter; |
528 | 528 |
529 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER | 529 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER |
530 PersistentWillBeMember<WebGLBuffer> m_boundArrayBuffer; | 530 PersistentWillBeMember<WebGLBuffer> m_boundArrayBuffer; |
531 | 531 |
532 PersistentWillBeMember<WebGLVertexArrayObjectBase> m_defaultVertexArrayObjec t; | 532 PersistentWillBeMember<WebGLVertexArrayObjectBase> m_defaultVertexArrayObjec t; |
533 PersistentWillBeMember<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; | 533 PersistentWillBeMember<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; |
534 void setBoundVertexArrayObject(WebGLVertexArrayObjectBase* arrayObject) | 534 bool m_preservedDefaultVAOObjectWrapper; |
535 { | 535 void setBoundVertexArrayObject(ScriptState*, WebGLVertexArrayObjectBase*); |
536 if (arrayObject) | |
537 m_boundVertexArrayObject = arrayObject; | |
538 else | |
539 m_boundVertexArrayObject = m_defaultVertexArrayObject; | |
540 } | |
541 | 536 |
542 enum VertexAttribValueType { | 537 enum VertexAttribValueType { |
543 Float32ArrayType, | 538 Float32ArrayType, |
544 Int32ArrayType, | 539 Int32ArrayType, |
545 Uint32ArrayType, | 540 Uint32ArrayType, |
546 }; | 541 }; |
547 | 542 |
548 class VertexAttribValue { | 543 class VertexAttribValue { |
549 public: | 544 public: |
550 VertexAttribValue() | 545 VertexAttribValue() |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1097 | 1092 |
1098 virtual void restoreCurrentFramebuffer(); | 1093 virtual void restoreCurrentFramebuffer(); |
1099 void restoreCurrentTexture2D(); | 1094 void restoreCurrentTexture2D(); |
1100 | 1095 |
1101 void multisamplingChanged(bool) override; | 1096 void multisamplingChanged(bool) override; |
1102 | 1097 |
1103 void findNewMaxNonDefaultTextureUnit(); | 1098 void findNewMaxNonDefaultTextureUnit(); |
1104 | 1099 |
1105 virtual void renderbufferStorageImpl(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, const char* functionName); | 1100 virtual void renderbufferStorageImpl(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, const char* functionName); |
1106 | 1101 |
1102 // Ensures that the JavaScript wrappers for objects that are | |
1103 // latched into the context's state, or which are implicitly | |
1104 // linked together (like programs and their attached shaders), are | |
1105 // not garbage collected before they should be. | |
1106 static void preserveObjectWrapper(ScriptState*, ScriptWrappable* sourceObjec t, const char* baseName, unsigned long index, ScriptWrappable* targetObject); | |
1107 void maybePreserveDefaultVAOObjectWrapper(ScriptState*); | |
haraken
2015/10/13 06:32:28
It's still not clear to me when maybePreserveDefau
| |
1108 | |
1107 friend class WebGLStateRestorer; | 1109 friend class WebGLStateRestorer; |
1108 friend class WebGLRenderingContextEvictionManager; | 1110 friend class WebGLRenderingContextEvictionManager; |
1109 | 1111 |
1110 static Vector<WebGLRenderingContextBase*>& activeContexts(); | 1112 static Vector<WebGLRenderingContextBase*>& activeContexts(); |
1111 static Vector<WebGLRenderingContextBase*>& forciblyEvictedContexts(); | 1113 static Vector<WebGLRenderingContextBase*>& forciblyEvictedContexts(); |
1112 | 1114 |
1113 static void activateContext(WebGLRenderingContextBase*); | 1115 static void activateContext(WebGLRenderingContextBase*); |
1114 static void deactivateContext(WebGLRenderingContextBase*); | 1116 static void deactivateContext(WebGLRenderingContextBase*); |
1115 static void addToEvictedList(WebGLRenderingContextBase*); | 1117 static void addToEvictedList(WebGLRenderingContextBase*); |
1116 static void removeFromEvictedList(WebGLRenderingContextBase*); | 1118 static void removeFromEvictedList(WebGLRenderingContextBase*); |
1117 static void willDestroyContext(WebGLRenderingContextBase*); | 1119 static void willDestroyContext(WebGLRenderingContextBase*); |
1118 static void forciblyLoseOldestContext(const String& reason); | 1120 static void forciblyLoseOldestContext(const String& reason); |
1119 // Return the least recently used context's position in the active context v ector. | 1121 // Return the least recently used context's position in the active context v ector. |
1120 // If the vector is empty, return the maximum allowed active context number. | 1122 // If the vector is empty, return the maximum allowed active context number. |
1121 static size_t oldestContextIndex(); | 1123 static size_t oldestContextIndex(); |
1122 static IntSize oldestContextSize(); | 1124 static IntSize oldestContextSize(); |
1123 }; | 1125 }; |
1124 | 1126 |
1125 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); | 1127 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); |
1126 | 1128 |
1127 } // namespace blink | 1129 } // namespace blink |
1128 | 1130 |
1129 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState); | 1131 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState); |
1130 | 1132 |
1131 #endif // WebGLRenderingContextBase_h | 1133 #endif // WebGLRenderingContextBase_h |
OLD | NEW |