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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
index 4c5824f71f469208ecf09c2479290a9cc46f2047..756e0c6608de48583da2c8385c74110d0ab2f159 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
@@ -27,7 +27,6 @@
#define WebGLRenderingContextBase_h
#include "bindings/core/v8/Nullable.h"
-#include "bindings/core/v8/ScopedPersistent.h"
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/ScriptWrappable.h"
@@ -150,12 +149,12 @@ public:
int drawingBufferHeight() const;
void activeTexture(GLenum texture);
- void attachShader(ScriptState*, WebGLProgram*, WebGLShader*);
+ void attachShader(WebGLProgram*, WebGLShader*);
void bindAttribLocation(WebGLProgram*, GLuint index, const String& name);
- void bindBuffer(ScriptState*, GLenum target, WebGLBuffer*);
- virtual void bindFramebuffer(ScriptState*, GLenum target, WebGLFramebuffer*);
- void bindRenderbuffer(ScriptState*, GLenum target, WebGLRenderbuffer*);
- void bindTexture(ScriptState*, GLenum target, WebGLTexture*);
+ void bindBuffer(GLenum target, WebGLBuffer*);
+ virtual void bindFramebuffer(GLenum target, WebGLFramebuffer*);
+ void bindRenderbuffer(GLenum target, WebGLRenderbuffer*);
+ void bindTexture(GLenum target, WebGLTexture*);
void blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void blendEquation(GLenum mode);
void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
@@ -201,7 +200,7 @@ public:
void depthFunc(GLenum);
void depthMask(GLboolean);
void depthRange(GLfloat zNear, GLfloat zFar);
- void detachShader(ScriptState*, WebGLProgram*, WebGLShader*);
+ void detachShader(WebGLProgram*, WebGLShader*);
void disable(GLenum cap);
void disableVertexAttribArray(GLuint index);
void drawArrays(GLenum mode, GLint first, GLsizei count);
@@ -214,8 +213,8 @@ public:
void enableVertexAttribArray(GLuint index);
void finish();
void flush();
- void framebufferRenderbuffer(ScriptState*, GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer*);
- void framebufferTexture2D(ScriptState*, GLenum target, GLenum attachment, GLenum textarget, WebGLTexture*, GLint level);
+ void framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer*);
+ void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, WebGLTexture*, GLint level);
void frontFace(GLenum mode);
void generateMipmap(GLenum target);
@@ -332,7 +331,7 @@ public:
void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, DOMFloat32Array* value);
void uniformMatrix4fv(const WebGLUniformLocation*, GLboolean transpose, Vector<GLfloat>& value);
- void useProgram(ScriptState*, WebGLProgram*);
+ void useProgram(WebGLProgram*);
void validateProgram(WebGLProgram*);
void vertexAttrib1f(GLuint index, GLfloat x);
@@ -347,7 +346,7 @@ public:
void vertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void vertexAttrib4fv(GLuint index, const DOMFloat32Array* values);
void vertexAttrib4fv(GLuint index, const Vector<GLfloat>& values);
- void vertexAttribPointer(ScriptState*, GLuint index, GLint size, GLenum type, GLboolean normalized,
+ void vertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized,
GLsizei stride, long long offset);
void vertexAttribDivisorANGLE(GLuint index, GLuint divisor);
@@ -435,6 +434,8 @@ protected:
friend class WebGLVertexArrayObjectBase;
friend class ScopedTexture2DRestorer;
friend class ScopedFramebufferRestorer;
+ // To allow V8WebGL[2]RenderingContext to call visitChildDOMWrappers.
+ friend class V8WebGLRenderingContext;
WebGLRenderingContextBase(HTMLCanvasElement*, std::unique_ptr<WebGraphicsContext3DProvider>, const CanvasContextCreationAttributes&, unsigned);
WebGLRenderingContextBase(OffscreenCanvas*, std::unique_ptr<WebGraphicsContext3DProvider>, const CanvasContextCreationAttributes&, unsigned);
@@ -481,6 +482,8 @@ protected:
// Restore the client unpack parameters.
virtual void restoreUnpackParameters();
+ virtual void visitChildDOMWrappers(v8::Isolate*, const v8::Persistent<v8::Object>&);
+
PassRefPtr<Image> drawImageIntoBuffer(PassRefPtr<Image>, int width, int height, const char* functionName);
PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*);
@@ -512,8 +515,7 @@ protected:
Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject;
Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject;
- bool m_preservedDefaultVAOObjectWrapper;
- void setBoundVertexArrayObject(ScriptState*, WebGLVertexArrayObjectBase*);
+ void setBoundVertexArrayObject(WebGLVertexArrayObjectBase*);
enum VertexAttribValueType {
Float32ArrayType,
@@ -619,6 +621,9 @@ protected:
virtual const char* extensionName() const = 0;
virtual void loseExtension(bool) = 0;
+ // This is only used for keeping the JS wrappers of extensions alive.
+ virtual WebGLExtension* getExtensionObjectIfAlreadyEnabled() = 0;
+
DEFINE_INLINE_VIRTUAL_TRACE() { }
private:
@@ -663,6 +668,11 @@ protected:
}
}
+ WebGLExtension* getExtensionObjectIfAlreadyEnabled() override
+ {
+ return m_extension;
+ }
+
DEFINE_INLINE_VIRTUAL_TRACE()
{
visitor->trace(m_extension);
@@ -1055,38 +1065,6 @@ protected:
virtual void renderbufferStorageImpl(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, const char* functionName);
- // Ensures that the JavaScript wrappers for objects that are
- // latched into the context's state, or which are implicitly
- // linked together (like programs and their attached shaders), are
- // not garbage collected before they should be.
- ScopedPersistent<v8::Array> m_wrappersOf2DTextures;
- ScopedPersistent<v8::Array> m_wrappersOf2DArrayTextures;
- ScopedPersistent<v8::Array> m_wrappersOf3DTextures;
- ScopedPersistent<v8::Array> m_cubeMapTextureWrappers;
- ScopedPersistent<v8::Array> m_extensionWrappers;
-
- // The "catch-all" array for the rest of the preserved object
- // wrappers. The enum below defines how the indices in this array
- // are used.
- enum PreservedWrapperIndex {
- PreservedArrayBuffer,
- PreservedElementArrayBuffer,
- PreservedFramebuffer,
- PreservedProgram,
- PreservedRenderbuffer,
- PreservedDefaultVAO,
- PreservedVAO,
- PreservedTransformFeedback,
- };
- ScopedPersistent<v8::Array> m_miscWrappers;
-
- static void preserveObjectWrapper(ScriptState*, ScriptWrappable* sourceObject, v8::Local<v8::String> hiddenValueName, ScopedPersistent<v8::Array>* persistentCache, uint32_t index, ScriptWrappable* targetObject);
-
- // Called to lazily instantiate the wrapper for the default VAO
- // during calls to bindBuffer and vertexAttribPointer (from
- // JavaScript).
- void maybePreserveDefaultVAOObjectWrapper(ScriptState*);
-
friend class WebGLStateRestorer;
friend class WebGLRenderingContextEvictionManager;

Powered by Google App Engine
This is Rietveld 408576698