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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h

Issue 2273683003: Use visitDOMWrapper to preserve WebGL JS object wrappers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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
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 WebGLRenderingContextBase_h 26 #ifndef WebGLRenderingContextBase_h
27 #define WebGLRenderingContextBase_h 27 #define WebGLRenderingContextBase_h
28 28
29 #include "bindings/core/v8/Nullable.h" 29 #include "bindings/core/v8/Nullable.h"
30 #include "bindings/core/v8/ScopedPersistent.h"
31 #include "bindings/core/v8/ScriptState.h" 30 #include "bindings/core/v8/ScriptState.h"
32 #include "bindings/core/v8/ScriptValue.h" 31 #include "bindings/core/v8/ScriptValue.h"
33 #include "bindings/core/v8/ScriptWrappable.h" 32 #include "bindings/core/v8/ScriptWrappable.h"
34 #include "core/CoreExport.h" 33 #include "core/CoreExport.h"
35 #include "core/dom/DOMTypedArray.h" 34 #include "core/dom/DOMTypedArray.h"
36 #include "core/dom/TypedFlexibleArrayBufferView.h" 35 #include "core/dom/TypedFlexibleArrayBufferView.h"
37 #include "core/html/canvas/CanvasContextCreationAttributes.h" 36 #include "core/html/canvas/CanvasContextCreationAttributes.h"
38 #include "core/html/canvas/CanvasRenderingContext.h" 37 #include "core/html/canvas/CanvasRenderingContext.h"
39 #include "core/layout/ContentChangeType.h" 38 #include "core/layout/ContentChangeType.h"
40 #include "modules/webgl/WebGLContextAttributes.h" 39 #include "modules/webgl/WebGLContextAttributes.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex t3DProvider(HTMLCanvasElement*, const CanvasContextCreationAttributes&, unsigned webGLVersion); 142 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex t3DProvider(HTMLCanvasElement*, const CanvasContextCreationAttributes&, unsigned webGLVersion);
144 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex t3DProvider(ScriptState*, const CanvasContextCreationAttributes&, unsigned webGL Version); 143 static std::unique_ptr<WebGraphicsContext3DProvider> createWebGraphicsContex t3DProvider(ScriptState*, const CanvasContextCreationAttributes&, unsigned webGL Version);
145 static void forceNextWebGLContextCreationToFail(); 144 static void forceNextWebGLContextCreationToFail();
146 145
147 unsigned version() const { return m_version; } 146 unsigned version() const { return m_version; }
148 147
149 int drawingBufferWidth() const; 148 int drawingBufferWidth() const;
150 int drawingBufferHeight() const; 149 int drawingBufferHeight() const;
151 150
152 void activeTexture(GLenum texture); 151 void activeTexture(GLenum texture);
153 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*); 152 void attachShader(WebGLProgram*, WebGLShader*);
154 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); 153 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name);
155 void bindBuffer(ScriptState*, GLenum target, WebGLBuffer*); 154 void bindBuffer(GLenum target, WebGLBuffer*);
156 virtual void bindFramebuffer(ScriptState*, GLenum target, WebGLFramebuffer*) ; 155 virtual void bindFramebuffer(GLenum target, WebGLFramebuffer*);
157 void bindRenderbuffer(ScriptState*, GLenum target, WebGLRenderbuffer*); 156 void bindRenderbuffer(GLenum target, WebGLRenderbuffer*);
158 void bindTexture(ScriptState*, GLenum target, WebGLTexture*); 157 void bindTexture(GLenum target, WebGLTexture*);
159 void blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); 158 void blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
160 void blendEquation(GLenum mode); 159 void blendEquation(GLenum mode);
161 void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); 160 void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
162 void blendFunc(GLenum sfactor, GLenum dfactor); 161 void blendFunc(GLenum sfactor, GLenum dfactor);
163 void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); 162 void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
164 163
165 void bufferData(GLenum target, long long size, GLenum usage); 164 void bufferData(GLenum target, long long size, GLenum usage);
166 void bufferData(GLenum target, DOMArrayBuffer* data, GLenum usage); 165 void bufferData(GLenum target, DOMArrayBuffer* data, GLenum usage);
167 void bufferData(GLenum target, DOMArrayBufferView* data, GLenum usage); 166 void bufferData(GLenum target, DOMArrayBufferView* data, GLenum usage);
168 void bufferSubData(GLenum target, long long offset, DOMArrayBuffer* data); 167 void bufferSubData(GLenum target, long long offset, DOMArrayBuffer* data);
(...skipping 25 matching lines...) Expand all
194 void deleteBuffer(WebGLBuffer*); 193 void deleteBuffer(WebGLBuffer*);
195 virtual void deleteFramebuffer(WebGLFramebuffer*); 194 virtual void deleteFramebuffer(WebGLFramebuffer*);
196 void deleteProgram(WebGLProgram*); 195 void deleteProgram(WebGLProgram*);
197 void deleteRenderbuffer(WebGLRenderbuffer*); 196 void deleteRenderbuffer(WebGLRenderbuffer*);
198 void deleteShader(WebGLShader*); 197 void deleteShader(WebGLShader*);
199 void deleteTexture(WebGLTexture*); 198 void deleteTexture(WebGLTexture*);
200 199
201 void depthFunc(GLenum); 200 void depthFunc(GLenum);
202 void depthMask(GLboolean); 201 void depthMask(GLboolean);
203 void depthRange(GLfloat zNear, GLfloat zFar); 202 void depthRange(GLfloat zNear, GLfloat zFar);
204 void detachShader(ScriptState*, WebGLProgram*, WebGLShader*); 203 void detachShader(WebGLProgram*, WebGLShader*);
205 void disable(GLenum cap); 204 void disable(GLenum cap);
206 void disableVertexAttribArray(GLuint index); 205 void disableVertexAttribArray(GLuint index);
207 void drawArrays(GLenum mode, GLint first, GLsizei count); 206 void drawArrays(GLenum mode, GLint first, GLsizei count);
208 void drawElements(GLenum mode, GLsizei count, GLenum type, long long offset) ; 207 void drawElements(GLenum mode, GLsizei count, GLenum type, long long offset) ;
209 208
210 void drawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsiz ei primcount); 209 void drawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsiz ei primcount);
211 void drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, lon g long offset, GLsizei primcount); 210 void drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, lon g long offset, GLsizei primcount);
212 211
213 void enable(GLenum cap); 212 void enable(GLenum cap);
214 void enableVertexAttribArray(GLuint index); 213 void enableVertexAttribArray(GLuint index);
215 void finish(); 214 void finish();
216 void flush(); 215 void flush();
217 void framebufferRenderbuffer(ScriptState*, GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer*); 216 void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum render buffertarget, WebGLRenderbuffer*);
218 void framebufferTexture2D(ScriptState*, GLenum target, GLenum attachment, GL enum textarget, WebGLTexture*, GLint level); 217 void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget , WebGLTexture*, GLint level);
219 void frontFace(GLenum mode); 218 void frontFace(GLenum mode);
220 void generateMipmap(GLenum target); 219 void generateMipmap(GLenum target);
221 220
222 WebGLActiveInfo* getActiveAttrib(WebGLProgram*, GLuint index); 221 WebGLActiveInfo* getActiveAttrib(WebGLProgram*, GLuint index);
223 WebGLActiveInfo* getActiveUniform(WebGLProgram*, GLuint index); 222 WebGLActiveInfo* getActiveUniform(WebGLProgram*, GLuint index);
224 bool getAttachedShaders(WebGLProgram*, HeapVector<Member<WebGLShader>>&); 223 bool getAttachedShaders(WebGLProgram*, HeapVector<Member<WebGLShader>>&);
225 Nullable<HeapVector<Member<WebGLShader>>> getAttachedShaders(WebGLProgram*); 224 Nullable<HeapVector<Member<WebGLShader>>> getAttachedShaders(WebGLProgram*);
226 GLint getAttribLocation(WebGLProgram*, const String& name); 225 GLint getAttribLocation(WebGLProgram*, const String& name);
227 ScriptValue getBufferParameter(ScriptState*, GLenum target, GLenum pname); 226 ScriptValue getBufferParameter(ScriptState*, GLenum target, GLenum pname);
228 void getContextAttributes(Nullable<WebGLContextAttributes>&); 227 void getContextAttributes(Nullable<WebGLContextAttributes>&);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 void uniform4i(const WebGLUniformLocation*, GLint x, GLint y, GLint z, GLint w); 324 void uniform4i(const WebGLUniformLocation*, GLint x, GLint y, GLint z, GLint w);
326 void uniform4iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&); 325 void uniform4iv(const WebGLUniformLocation*, const FlexibleInt32ArrayView&);
327 void uniform4iv(const WebGLUniformLocation*, Vector<GLint>&); 326 void uniform4iv(const WebGLUniformLocation*, Vector<GLint>&);
328 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); 327 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value);
329 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); 328 void uniformMatrix2fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value);
330 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); 329 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value);
331 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); 330 void uniformMatrix3fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value);
332 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value); 331 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, DOMF loat32Array* value);
333 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value); 332 void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, Vect or<GLfloat>& value);
334 333
335 void useProgram(ScriptState*, WebGLProgram*); 334 void useProgram(WebGLProgram*);
336 void validateProgram(WebGLProgram*); 335 void validateProgram(WebGLProgram*);
337 336
338 void vertexAttrib1f(GLuint index, GLfloat x); 337 void vertexAttrib1f(GLuint index, GLfloat x);
339 void vertexAttrib1fv(GLuint index, const DOMFloat32Array* values); 338 void vertexAttrib1fv(GLuint index, const DOMFloat32Array* values);
340 void vertexAttrib1fv(GLuint index, const Vector<GLfloat>& values); 339 void vertexAttrib1fv(GLuint index, const Vector<GLfloat>& values);
341 void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y); 340 void vertexAttrib2f(GLuint index, GLfloat x, GLfloat y);
342 void vertexAttrib2fv(GLuint index, const DOMFloat32Array* values); 341 void vertexAttrib2fv(GLuint index, const DOMFloat32Array* values);
343 void vertexAttrib2fv(GLuint index, const Vector<GLfloat>& values); 342 void vertexAttrib2fv(GLuint index, const Vector<GLfloat>& values);
344 void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z); 343 void vertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z);
345 void vertexAttrib3fv(GLuint index, const DOMFloat32Array* values); 344 void vertexAttrib3fv(GLuint index, const DOMFloat32Array* values);
346 void vertexAttrib3fv(GLuint index, const Vector<GLfloat>& values); 345 void vertexAttrib3fv(GLuint index, const Vector<GLfloat>& values);
347 void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); 346 void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
348 void vertexAttrib4fv(GLuint index, const DOMFloat32Array* values); 347 void vertexAttrib4fv(GLuint index, const DOMFloat32Array* values);
349 void vertexAttrib4fv(GLuint index, const Vector<GLfloat>& values); 348 void vertexAttrib4fv(GLuint index, const Vector<GLfloat>& values);
350 void vertexAttribPointer(ScriptState*, GLuint index, GLint size, GLenum type , GLboolean normalized, 349 void vertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean no rmalized,
351 GLsizei stride, long long offset); 350 GLsizei stride, long long offset);
352 351
353 void vertexAttribDivisorANGLE(GLuint index, GLuint divisor); 352 void vertexAttribDivisorANGLE(GLuint index, GLuint divisor);
354 353
355 void viewport(GLint x, GLint y, GLsizei width, GLsizei height); 354 void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
356 355
357 // WEBGL_lose_context support 356 // WEBGL_lose_context support
358 enum AutoRecoveryMethod { 357 enum AutoRecoveryMethod {
359 // Don't restore automatically. 358 // Don't restore automatically.
360 Manual, 359 Manual,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 friend class WebGLDebugShaders; 426 friend class WebGLDebugShaders;
428 friend class WebGLCompressedTextureASTC; 427 friend class WebGLCompressedTextureASTC;
429 friend class WebGLCompressedTextureATC; 428 friend class WebGLCompressedTextureATC;
430 friend class WebGLCompressedTextureETC1; 429 friend class WebGLCompressedTextureETC1;
431 friend class WebGLCompressedTexturePVRTC; 430 friend class WebGLCompressedTexturePVRTC;
432 friend class WebGLCompressedTextureS3TC; 431 friend class WebGLCompressedTextureS3TC;
433 friend class WebGLRenderingContextErrorMessageCallback; 432 friend class WebGLRenderingContextErrorMessageCallback;
434 friend class WebGLVertexArrayObjectBase; 433 friend class WebGLVertexArrayObjectBase;
435 friend class ScopedTexture2DRestorer; 434 friend class ScopedTexture2DRestorer;
436 friend class ScopedFramebufferRestorer; 435 friend class ScopedFramebufferRestorer;
436 // To allow V8WebGL[2]RenderingContext to call visitChildDOMWrappers.
437 friend class V8WebGLRenderingContext;
437 438
438 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon text3DProvider>, const CanvasContextCreationAttributes&, unsigned); 439 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon text3DProvider>, const CanvasContextCreationAttributes&, unsigned);
439 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte xt3DProvider>, const CanvasContextCreationAttributes&, unsigned); 440 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte xt3DProvider>, const CanvasContextCreationAttributes&, unsigned);
440 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon text3DProvider>); 441 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon text3DProvider>);
441 void setupFlags(); 442 void setupFlags();
442 443
443 // CanvasRenderingContext implementation. 444 // CanvasRenderingContext implementation.
444 bool is3d() const override { return true; } 445 bool is3d() const override { return true; }
445 bool isAccelerated() const override { return true; } 446 bool isAccelerated() const override { return true; }
446 void setIsHidden(bool) override; 447 void setIsHidden(bool) override;
(...skipping 26 matching lines...) Expand all
473 474
474 // Adds a compressed texture format. 475 // Adds a compressed texture format.
475 void addCompressedTextureFormat(GLenum); 476 void addCompressedTextureFormat(GLenum);
476 void removeAllCompressedTextureFormats(); 477 void removeAllCompressedTextureFormats();
477 478
478 // Set UNPACK_ALIGNMENT to 1, all other parameters to 0. 479 // Set UNPACK_ALIGNMENT to 1, all other parameters to 0.
479 virtual void resetUnpackParameters(); 480 virtual void resetUnpackParameters();
480 // Restore the client unpack parameters. 481 // Restore the client unpack parameters.
481 virtual void restoreUnpackParameters(); 482 virtual void restoreUnpackParameters();
482 483
484 static void trySetWrapperReferencesInAllWorlds(const v8::Persistent<v8::Obje ct>&, ScriptWrappable*, v8::Isolate*);
485 virtual void visitChildDOMWrappers(v8::Isolate*, const v8::Persistent<v8::Ob ject>&);
486
483 PassRefPtr<Image> drawImageIntoBuffer(PassRefPtr<Image>, int width, int heig ht, const char* functionName); 487 PassRefPtr<Image> drawImageIntoBuffer(PassRefPtr<Image>, int width, int heig ht, const char* functionName);
484 488
485 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*); 489 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*);
486 490
487 // Structure for rendering to a DrawingBuffer, instead of directly 491 // Structure for rendering to a DrawingBuffer, instead of directly
488 // to the back-buffer of m_context. 492 // to the back-buffer of m_context.
489 RefPtr<DrawingBuffer> m_drawingBuffer; 493 RefPtr<DrawingBuffer> m_drawingBuffer;
490 DrawingBuffer* drawingBuffer() const; 494 DrawingBuffer* drawingBuffer() const;
491 495
492 RefPtr<WebGLContextGroup> m_contextGroup; 496 RefPtr<WebGLContextGroup> m_contextGroup;
(...skipping 11 matching lines...) Expand all
504 Timer<WebGLRenderingContextBase> m_restoreTimer; 508 Timer<WebGLRenderingContextBase> m_restoreTimer;
505 509
506 bool m_markedCanvasDirty; 510 bool m_markedCanvasDirty;
507 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects; 511 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects;
508 512
509 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER 513 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER a nd stored values for ELEMENT_ARRAY_BUFFER
510 Member<WebGLBuffer> m_boundArrayBuffer; 514 Member<WebGLBuffer> m_boundArrayBuffer;
511 515
512 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject; 516 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject;
513 Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; 517 Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject;
514 bool m_preservedDefaultVAOObjectWrapper; 518 void setBoundVertexArrayObject(WebGLVertexArrayObjectBase*);
515 void setBoundVertexArrayObject(ScriptState*, WebGLVertexArrayObjectBase*);
516 519
517 enum VertexAttribValueType { 520 enum VertexAttribValueType {
518 Float32ArrayType, 521 Float32ArrayType,
519 Int32ArrayType, 522 Int32ArrayType,
520 Uint32ArrayType, 523 Uint32ArrayType,
521 }; 524 };
522 525
523 Vector<VertexAttribValueType> m_vertexAttribType; 526 Vector<VertexAttribValueType> m_vertexAttribType;
524 unsigned m_maxVertexAttribs; 527 unsigned m_maxVertexAttribs;
525 void setVertexAttribType(GLuint index, VertexAttribValueType); 528 void setVertexAttribType(GLuint index, VertexAttribValueType);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 } 614 }
612 615
613 const char* const* prefixes() const; 616 const char* const* prefixes() const;
614 bool matchesNameWithPrefixes(const String&) const; 617 bool matchesNameWithPrefixes(const String&) const;
615 618
616 virtual WebGLExtension* getExtension(WebGLRenderingContextBase*) = 0; 619 virtual WebGLExtension* getExtension(WebGLRenderingContextBase*) = 0;
617 virtual bool supported(WebGLRenderingContextBase*) const = 0; 620 virtual bool supported(WebGLRenderingContextBase*) const = 0;
618 virtual const char* extensionName() const = 0; 621 virtual const char* extensionName() const = 0;
619 virtual void loseExtension(bool) = 0; 622 virtual void loseExtension(bool) = 0;
620 623
624 // This is only used for keeping the JS wrappers of extensions alive.
625 virtual WebGLExtension* getExtensionObjectIfAlreadyEnabled() = 0;
626
621 DEFINE_INLINE_VIRTUAL_TRACE() { } 627 DEFINE_INLINE_VIRTUAL_TRACE() { }
622 628
623 private: 629 private:
624 bool m_draft; 630 bool m_draft;
625 const char* const* m_prefixes; 631 const char* const* m_prefixes;
626 }; 632 };
627 633
628 template <typename T> 634 template <typename T>
629 class TypedExtensionTracker final : public ExtensionTracker { 635 class TypedExtensionTracker final : public ExtensionTracker {
630 public: 636 public:
(...skipping 24 matching lines...) Expand all
655 661
656 void loseExtension(bool force) override 662 void loseExtension(bool force) override
657 { 663 {
658 if (m_extension) { 664 if (m_extension) {
659 m_extension->lose(force); 665 m_extension->lose(force);
660 if (m_extension->isLost()) 666 if (m_extension->isLost())
661 m_extension = nullptr; 667 m_extension = nullptr;
662 } 668 }
663 } 669 }
664 670
671 WebGLExtension* getExtensionObjectIfAlreadyEnabled() override
672 {
673 return m_extension;
674 }
675
665 DEFINE_INLINE_VIRTUAL_TRACE() 676 DEFINE_INLINE_VIRTUAL_TRACE()
666 { 677 {
667 visitor->trace(m_extension); 678 visitor->trace(m_extension);
668 ExtensionTracker::trace(visitor); 679 ExtensionTracker::trace(visitor);
669 } 680 }
670 681
671 private: 682 private:
672 TypedExtensionTracker(Member<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes) 683 TypedExtensionTracker(Member<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes)
673 : ExtensionTracker(flags, prefixes) 684 : ExtensionTracker(flags, prefixes)
674 , m_extensionField(extensionField) 685 , m_extensionField(extensionField)
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 void setBackDrawBuffer(GLenum); 1058 void setBackDrawBuffer(GLenum);
1048 void setFramebuffer(GLenum, WebGLFramebuffer*); 1059 void setFramebuffer(GLenum, WebGLFramebuffer*);
1049 1060
1050 virtual void restoreCurrentFramebuffer(); 1061 virtual void restoreCurrentFramebuffer();
1051 void restoreCurrentTexture2D(); 1062 void restoreCurrentTexture2D();
1052 1063
1053 void findNewMaxNonDefaultTextureUnit(); 1064 void findNewMaxNonDefaultTextureUnit();
1054 1065
1055 virtual void renderbufferStorageImpl(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, const char* functionName); 1066 virtual void renderbufferStorageImpl(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, const char* functionName);
1056 1067
1057 // Ensures that the JavaScript wrappers for objects that are
1058 // latched into the context's state, or which are implicitly
1059 // linked together (like programs and their attached shaders), are
1060 // not garbage collected before they should be.
1061 ScopedPersistent<v8::Array> m_wrappersOf2DTextures;
1062 ScopedPersistent<v8::Array> m_wrappersOf2DArrayTextures;
1063 ScopedPersistent<v8::Array> m_wrappersOf3DTextures;
1064 ScopedPersistent<v8::Array> m_cubeMapTextureWrappers;
1065 ScopedPersistent<v8::Array> m_extensionWrappers;
1066
1067 // The "catch-all" array for the rest of the preserved object
1068 // wrappers. The enum below defines how the indices in this array
1069 // are used.
1070 enum PreservedWrapperIndex {
1071 PreservedArrayBuffer,
1072 PreservedElementArrayBuffer,
1073 PreservedFramebuffer,
1074 PreservedProgram,
1075 PreservedRenderbuffer,
1076 PreservedDefaultVAO,
1077 PreservedVAO,
1078 PreservedTransformFeedback,
1079 };
1080 ScopedPersistent<v8::Array> m_miscWrappers;
1081
1082 static void preserveObjectWrapper(ScriptState*, ScriptWrappable* sourceObjec t, v8::Local<v8::String> hiddenValueName, ScopedPersistent<v8::Array>* persisten tCache, uint32_t index, ScriptWrappable* targetObject);
1083
1084 // Called to lazily instantiate the wrapper for the default VAO
1085 // during calls to bindBuffer and vertexAttribPointer (from
1086 // JavaScript).
1087 void maybePreserveDefaultVAOObjectWrapper(ScriptState*);
1088
1089 friend class WebGLStateRestorer; 1068 friend class WebGLStateRestorer;
1090 friend class WebGLRenderingContextEvictionManager; 1069 friend class WebGLRenderingContextEvictionManager;
1091 1070
1092 static void activateContext(WebGLRenderingContextBase*); 1071 static void activateContext(WebGLRenderingContextBase*);
1093 static void deactivateContext(WebGLRenderingContextBase*); 1072 static void deactivateContext(WebGLRenderingContextBase*);
1094 static void addToEvictedList(WebGLRenderingContextBase*); 1073 static void addToEvictedList(WebGLRenderingContextBase*);
1095 static void removeFromEvictedList(WebGLRenderingContextBase*); 1074 static void removeFromEvictedList(WebGLRenderingContextBase*);
1096 static void willDestroyContext(WebGLRenderingContextBase*); 1075 static void willDestroyContext(WebGLRenderingContextBase*);
1097 static void forciblyLoseOldestContext(const String& reason); 1076 static void forciblyLoseOldestContext(const String& reason);
1098 // Return the least recently used context's position in the active context v ector. 1077 // Return the least recently used context's position in the active context v ector.
(...skipping 23 matching lines...) Expand all
1122 bool isPaintable() const final { return drawingBuffer(); } 1101 bool isPaintable() const final { return drawingBuffer(); }
1123 }; 1102 };
1124 1103
1125 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 1104 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
1126 1105
1127 } // namespace blink 1106 } // namespace blink
1128 1107
1129 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState); 1108 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState);
1130 1109
1131 #endif // WebGLRenderingContextBase_h 1110 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698