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

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: style 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 friend class WebGLDebugShaders; 427 friend class WebGLDebugShaders;
429 friend class WebGLCompressedTextureASTC; 428 friend class WebGLCompressedTextureASTC;
430 friend class WebGLCompressedTextureATC; 429 friend class WebGLCompressedTextureATC;
431 friend class WebGLCompressedTextureETC1; 430 friend class WebGLCompressedTextureETC1;
432 friend class WebGLCompressedTexturePVRTC; 431 friend class WebGLCompressedTexturePVRTC;
433 friend class WebGLCompressedTextureS3TC; 432 friend class WebGLCompressedTextureS3TC;
434 friend class WebGLRenderingContextErrorMessageCallback; 433 friend class WebGLRenderingContextErrorMessageCallback;
435 friend class WebGLVertexArrayObjectBase; 434 friend class WebGLVertexArrayObjectBase;
436 friend class ScopedTexture2DRestorer; 435 friend class ScopedTexture2DRestorer;
437 friend class ScopedFramebufferRestorer; 436 friend class ScopedFramebufferRestorer;
437 // To allow V8WebGL[2]RenderingContext to call visitChildDOMWrappers.
438 friend class V8WebGLRenderingContext;
438 439
439 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon text3DProvider>, const CanvasContextCreationAttributes&, unsigned); 440 WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsCon text3DProvider>, const CanvasContextCreationAttributes&, unsigned);
440 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte xt3DProvider>, const CanvasContextCreationAttributes&, unsigned); 441 WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsConte xt3DProvider>, const CanvasContextCreationAttributes&, unsigned);
441 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon text3DProvider>); 442 PassRefPtr<DrawingBuffer> createDrawingBuffer(std::unique_ptr<WebGraphicsCon text3DProvider>);
442 void setupFlags(); 443 void setupFlags();
443 444
444 // CanvasRenderingContext implementation. 445 // CanvasRenderingContext implementation.
445 bool is3d() const override { return true; } 446 bool is3d() const override { return true; }
446 bool isAccelerated() const override { return true; } 447 bool isAccelerated() const override { return true; }
447 void setIsHidden(bool) override; 448 void setIsHidden(bool) override;
(...skipping 26 matching lines...) Expand all
474 475
475 // Adds a compressed texture format. 476 // Adds a compressed texture format.
476 void addCompressedTextureFormat(GLenum); 477 void addCompressedTextureFormat(GLenum);
477 void removeAllCompressedTextureFormats(); 478 void removeAllCompressedTextureFormats();
478 479
479 // Set UNPACK_ALIGNMENT to 1, all other parameters to 0. 480 // Set UNPACK_ALIGNMENT to 1, all other parameters to 0.
480 virtual void resetUnpackParameters(); 481 virtual void resetUnpackParameters();
481 // Restore the client unpack parameters. 482 // Restore the client unpack parameters.
482 virtual void restoreUnpackParameters(); 483 virtual void restoreUnpackParameters();
483 484
485 virtual void visitChildDOMWrappers(v8::Isolate*, const v8::Persistent<v8::Ob ject>&);
486
484 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);
485 488
486 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*); 489 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*);
487 490
488 // Structure for rendering to a DrawingBuffer, instead of directly 491 // Structure for rendering to a DrawingBuffer, instead of directly
489 // to the back-buffer of m_context. 492 // to the back-buffer of m_context.
490 RefPtr<DrawingBuffer> m_drawingBuffer; 493 RefPtr<DrawingBuffer> m_drawingBuffer;
491 DrawingBuffer* drawingBuffer() const; 494 DrawingBuffer* drawingBuffer() const;
492 495
493 RefPtr<WebGLContextGroup> m_contextGroup; 496 RefPtr<WebGLContextGroup> m_contextGroup;
(...skipping 11 matching lines...) Expand all
505 Timer<WebGLRenderingContextBase> m_restoreTimer; 508 Timer<WebGLRenderingContextBase> m_restoreTimer;
506 509
507 bool m_markedCanvasDirty; 510 bool m_markedCanvasDirty;
508 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects; 511 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects;
509 512
510 // 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
511 Member<WebGLBuffer> m_boundArrayBuffer; 514 Member<WebGLBuffer> m_boundArrayBuffer;
512 515
513 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject; 516 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject;
514 Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; 517 Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject;
515 bool m_preservedDefaultVAOObjectWrapper; 518 void setBoundVertexArrayObject(WebGLVertexArrayObjectBase*);
516 void setBoundVertexArrayObject(ScriptState*, WebGLVertexArrayObjectBase*);
517 519
518 enum VertexAttribValueType { 520 enum VertexAttribValueType {
519 Float32ArrayType, 521 Float32ArrayType,
520 Int32ArrayType, 522 Int32ArrayType,
521 Uint32ArrayType, 523 Uint32ArrayType,
522 }; 524 };
523 525
524 Vector<VertexAttribValueType> m_vertexAttribType; 526 Vector<VertexAttribValueType> m_vertexAttribType;
525 unsigned m_maxVertexAttribs; 527 unsigned m_maxVertexAttribs;
526 void setVertexAttribType(GLuint index, VertexAttribValueType); 528 void setVertexAttribType(GLuint index, VertexAttribValueType);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 614 }
613 615
614 const char* const* prefixes() const; 616 const char* const* prefixes() const;
615 bool matchesNameWithPrefixes(const String&) const; 617 bool matchesNameWithPrefixes(const String&) const;
616 618
617 virtual WebGLExtension* getExtension(WebGLRenderingContextBase*) = 0; 619 virtual WebGLExtension* getExtension(WebGLRenderingContextBase*) = 0;
618 virtual bool supported(WebGLRenderingContextBase*) const = 0; 620 virtual bool supported(WebGLRenderingContextBase*) const = 0;
619 virtual const char* extensionName() const = 0; 621 virtual const char* extensionName() const = 0;
620 virtual void loseExtension(bool) = 0; 622 virtual void loseExtension(bool) = 0;
621 623
624 // This is only used for keeping the JS wrappers of extensions alive.
625 virtual WebGLExtension* getExtensionObjectIfAlreadyEnabled() = 0;
626
622 DEFINE_INLINE_VIRTUAL_TRACE() { } 627 DEFINE_INLINE_VIRTUAL_TRACE() { }
623 628
624 private: 629 private:
625 bool m_draft; 630 bool m_draft;
626 const char* const* m_prefixes; 631 const char* const* m_prefixes;
627 }; 632 };
628 633
629 template <typename T> 634 template <typename T>
630 class TypedExtensionTracker final : public ExtensionTracker { 635 class TypedExtensionTracker final : public ExtensionTracker {
631 public: 636 public:
(...skipping 24 matching lines...) Expand all
656 661
657 void loseExtension(bool force) override 662 void loseExtension(bool force) override
658 { 663 {
659 if (m_extension) { 664 if (m_extension) {
660 m_extension->lose(force); 665 m_extension->lose(force);
661 if (m_extension->isLost()) 666 if (m_extension->isLost())
662 m_extension = nullptr; 667 m_extension = nullptr;
663 } 668 }
664 } 669 }
665 670
671 WebGLExtension* getExtensionObjectIfAlreadyEnabled() override
672 {
673 return m_extension;
674 }
675
666 DEFINE_INLINE_VIRTUAL_TRACE() 676 DEFINE_INLINE_VIRTUAL_TRACE()
667 { 677 {
668 visitor->trace(m_extension); 678 visitor->trace(m_extension);
669 ExtensionTracker::trace(visitor); 679 ExtensionTracker::trace(visitor);
670 } 680 }
671 681
672 private: 682 private:
673 TypedExtensionTracker(Member<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes) 683 TypedExtensionTracker(Member<T>& extensionField, ExtensionFlags flags, c onst char* const* prefixes)
674 : ExtensionTracker(flags, prefixes) 684 : ExtensionTracker(flags, prefixes)
675 , m_extensionField(extensionField) 685 , m_extensionField(extensionField)
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 void setBackDrawBuffer(GLenum); 1058 void setBackDrawBuffer(GLenum);
1049 void setFramebuffer(GLenum, WebGLFramebuffer*); 1059 void setFramebuffer(GLenum, WebGLFramebuffer*);
1050 1060
1051 virtual void restoreCurrentFramebuffer(); 1061 virtual void restoreCurrentFramebuffer();
1052 void restoreCurrentTexture2D(); 1062 void restoreCurrentTexture2D();
1053 1063
1054 void findNewMaxNonDefaultTextureUnit(); 1064 void findNewMaxNonDefaultTextureUnit();
1055 1065
1056 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);
1057 1067
1058 // Ensures that the JavaScript wrappers for objects that are
1059 // latched into the context's state, or which are implicitly
1060 // linked together (like programs and their attached shaders), are
1061 // not garbage collected before they should be.
1062 ScopedPersistent<v8::Array> m_wrappersOf2DTextures;
1063 ScopedPersistent<v8::Array> m_wrappersOf2DArrayTextures;
1064 ScopedPersistent<v8::Array> m_wrappersOf3DTextures;
1065 ScopedPersistent<v8::Array> m_cubeMapTextureWrappers;
1066 ScopedPersistent<v8::Array> m_extensionWrappers;
1067
1068 // The "catch-all" array for the rest of the preserved object
1069 // wrappers. The enum below defines how the indices in this array
1070 // are used.
1071 enum PreservedWrapperIndex {
1072 PreservedArrayBuffer,
1073 PreservedElementArrayBuffer,
1074 PreservedFramebuffer,
1075 PreservedProgram,
1076 PreservedRenderbuffer,
1077 PreservedDefaultVAO,
1078 PreservedVAO,
1079 PreservedTransformFeedback,
1080 };
1081 ScopedPersistent<v8::Array> m_miscWrappers;
1082
1083 static void preserveObjectWrapper(ScriptState*, ScriptWrappable* sourceObjec t, v8::Local<v8::String> hiddenValueName, ScopedPersistent<v8::Array>* persisten tCache, uint32_t index, ScriptWrappable* targetObject);
1084
1085 // Called to lazily instantiate the wrapper for the default VAO
1086 // during calls to bindBuffer and vertexAttribPointer (from
1087 // JavaScript).
1088 void maybePreserveDefaultVAOObjectWrapper(ScriptState*);
1089
1090 friend class WebGLStateRestorer; 1068 friend class WebGLStateRestorer;
1091 friend class WebGLRenderingContextEvictionManager; 1069 friend class WebGLRenderingContextEvictionManager;
1092 1070
1093 static void activateContext(WebGLRenderingContextBase*); 1071 static void activateContext(WebGLRenderingContextBase*);
1094 static void deactivateContext(WebGLRenderingContextBase*); 1072 static void deactivateContext(WebGLRenderingContextBase*);
1095 static void addToEvictedList(WebGLRenderingContextBase*); 1073 static void addToEvictedList(WebGLRenderingContextBase*);
1096 static void removeFromEvictedList(WebGLRenderingContextBase*); 1074 static void removeFromEvictedList(WebGLRenderingContextBase*);
1097 static void willDestroyContext(WebGLRenderingContextBase*); 1075 static void willDestroyContext(WebGLRenderingContextBase*);
1098 static void forciblyLoseOldestContext(const String& reason); 1076 static void forciblyLoseOldestContext(const String& reason);
1099 // 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
1123 bool isPaintable() const final { return drawingBuffer(); } 1101 bool isPaintable() const final { return drawingBuffer(); }
1124 }; 1102 };
1125 1103
1126 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 1104 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
1127 1105
1128 } // namespace blink 1106 } // namespace blink
1129 1107
1130 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);
1131 1109
1132 #endif // WebGLRenderingContextBase_h 1110 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698