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

Unified Diff: Source/core/html/canvas/WebGLRenderingContextBase.h

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Smaller adjustments Created 6 years, 5 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: Source/core/html/canvas/WebGLRenderingContextBase.h
diff --git a/Source/core/html/canvas/WebGLRenderingContextBase.h b/Source/core/html/canvas/WebGLRenderingContextBase.h
index afef14114adf46db85cd3466620991accc3d5a27..842fd8315279143a7ae69d7f814c84af04559bfa 100644
--- a/Source/core/html/canvas/WebGLRenderingContextBase.h
+++ b/Source/core/html/canvas/WebGLRenderingContextBase.h
@@ -91,6 +91,7 @@ class WebGLRenderbuffer;
class WebGLShader;
class WebGLShaderPrecisionFormat;
class WebGLSharedObject;
+class WebGLSharedWebGraphicsContext3D;
class WebGLTexture;
class WebGLUniformLocation;
class WebGLVertexArrayObjectOES;
@@ -147,12 +148,12 @@ public:
void copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
- PassRefPtr<WebGLBuffer> createBuffer();
- PassRefPtr<WebGLFramebuffer> createFramebuffer();
- PassRefPtr<WebGLProgram> createProgram();
- PassRefPtr<WebGLRenderbuffer> createRenderbuffer();
- PassRefPtr<WebGLShader> createShader(GLenum type);
- PassRefPtr<WebGLTexture> createTexture();
+ PassRefPtrWillBeRawPtr<WebGLBuffer> createBuffer();
+ PassRefPtrWillBeRawPtr<WebGLFramebuffer> createFramebuffer();
+ PassRefPtrWillBeRawPtr<WebGLProgram> createProgram();
+ PassRefPtrWillBeRawPtr<WebGLRenderbuffer> createRenderbuffer();
+ PassRefPtrWillBeRawPtr<WebGLShader> createShader(GLenum type);
+ PassRefPtrWillBeRawPtr<WebGLTexture> createTexture();
void cullFace(GLenum mode);
@@ -184,14 +185,15 @@ public:
void frontFace(GLenum mode);
void generateMipmap(GLenum target);
- PassRefPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuint index);
- PassRefPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLuint index);
- Nullable<Vector<RefPtr<WebGLShader> > > getAttachedShaders(WebGLProgram*);
+ PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveAttrib(WebGLProgram*, GLuint index);
+ PassRefPtrWillBeRawPtr<WebGLActiveInfo> getActiveUniform(WebGLProgram*, GLuint index);
+ bool getAttachedShaders(WebGLProgram*, WillBeHeapVector<RefPtrWillBeMember<WebGLShader> >&);
+ Nullable<WillBeHeapVector<RefPtrWillBeMember<WebGLShader> > > getAttachedShaders(WebGLProgram*);
GLint getAttribLocation(WebGLProgram*, const String& name);
WebGLGetInfo getBufferParameter(GLenum target, GLenum pname);
- PassRefPtr<WebGLContextAttributes> getContextAttributes();
+ PassRefPtrWillBeRawPtr<WebGLContextAttributes> getContextAttributes();
GLenum getError();
- PassRefPtr<WebGLExtension> getExtension(const String& name);
+ PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(const String& name);
WebGLGetInfo getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname);
WebGLGetInfo getParameter(GLenum pname);
WebGLGetInfo getProgramParameter(WebGLProgram*, GLenum pname);
@@ -199,12 +201,12 @@ public:
WebGLGetInfo getRenderbufferParameter(GLenum target, GLenum pname);
WebGLGetInfo getShaderParameter(WebGLShader*, GLenum pname);
String getShaderInfoLog(WebGLShader*);
- PassRefPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GLenum shaderType, GLenum precisionType);
+ PassRefPtrWillBeRawPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GLenum shaderType, GLenum precisionType);
String getShaderSource(WebGLShader*);
Nullable<Vector<String> > getSupportedExtensions();
WebGLGetInfo getTexParameter(GLenum target, GLenum pname);
WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*);
- PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const String&);
+ PassRefPtrWillBeRawPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const String&);
WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname);
long long getVertexAttribOffset(GLuint index, GLenum pname);
@@ -329,7 +331,7 @@ public:
void forceRestoreContext();
void loseContextImpl(LostContextMode);
- blink::WebGraphicsContext3D* webContext() const { return m_drawingBuffer->context(); }
+ blink::WebGraphicsContext3D* webContext() const { return drawingBuffer()->context(); }
WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); }
virtual blink::WebLayer* platformLayer() const OVERRIDE;
Extensions3DUtil* extensionsUtil();
@@ -351,11 +353,22 @@ public:
void setSavingImage(bool isSaving) { m_savingImage = isSaving; }
- virtual void trace(Visitor* visitor) OVERRIDE { CanvasRenderingContext::trace(visitor); }
+ virtual void trace(Visitor*) OVERRIDE;
+
+ class TextureUnitState {
+ ALLOW_ONLY_INLINE_ALLOCATION();
+ public:
+ RefPtrWillBeMember<WebGLTexture> m_texture2DBinding;
+ RefPtrWillBeMember<WebGLTexture> m_textureCubeMapBinding;
+
+ void trace(Visitor*);
+ };
+
protected:
friend class WebGLDrawBuffers;
friend class WebGLFramebuffer;
friend class WebGLObject;
+ friend class WebGLContextObject;
friend class OESVertexArrayObject;
friend class WebGLDebugShaders;
friend class WebGLCompressedTextureATC;
@@ -371,6 +384,10 @@ protected:
void initializeNewContext();
void setupFlags();
+#if ENABLE(OILPAN)
+ PassRefPtr<WebGLSharedWebGraphicsContext3D> sharedWebGraphicsContext3D() const;
+#endif
+
void addSharedObject(WebGLSharedObject*);
void addContextObject(WebGLContextObject*);
void detachAndRemoveAllObjects();
@@ -404,7 +421,13 @@ protected:
// Structure for rendering to a DrawingBuffer, instead of directly
// to the back-buffer of m_context.
+#if ENABLE(OILPAN)
+ RefPtr<WebGLSharedWebGraphicsContext3D> m_sharedWebGraphicsContext3D;
+#else
RefPtr<DrawingBuffer> m_drawingBuffer;
+#endif
+ DrawingBuffer* drawingBuffer() const;
+
RefPtr<WebGLContextGroup> m_contextGroup;
// Dispatches a context lost event once it is determined that one is needed.
@@ -418,17 +441,17 @@ protected:
bool m_needsUpdate;
bool m_markedCanvasDirty;
- HashSet<WebGLContextObject*> m_contextObjects;
+ WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLContextObject> > m_contextObjects;
- OwnPtr<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter;
- OwnPtr<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdapter;
+ OwnPtrWillBeMember<WebGLRenderingContextLostCallback> m_contextLostCallbackAdapter;
+ OwnPtrWillBeMember<WebGLRenderingContextErrorMessageCallback> m_errorMessageCallbackAdapter;
// List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and stored values for ELEMENT_ARRAY_BUFFER
- RefPtr<WebGLBuffer> m_boundArrayBuffer;
+ RefPtrWillBeMember<WebGLBuffer> m_boundArrayBuffer;
- RefPtr<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
- RefPtr<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
- void setBoundVertexArrayObject(PassRefPtr<WebGLVertexArrayObjectOES> arrayObject)
+ RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_defaultVertexArrayObject;
+ RefPtrWillBeMember<WebGLVertexArrayObjectOES> m_boundVertexArrayObject;
+ void setBoundVertexArrayObject(PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> arrayObject)
{
if (arrayObject)
m_boundVertexArrayObject = arrayObject;
@@ -455,25 +478,21 @@ protected:
};
Vector<VertexAttribValue> m_vertexAttribValue;
unsigned m_maxVertexAttribs;
- RefPtr<WebGLBuffer> m_vertexAttrib0Buffer;
+ RefPtrWillBeMember<WebGLBuffer> m_vertexAttrib0Buffer;
long m_vertexAttrib0BufferSize;
GLfloat m_vertexAttrib0BufferValue[4];
bool m_forceAttrib0BufferRefill;
bool m_vertexAttrib0UsedBefore;
- RefPtr<WebGLProgram> m_currentProgram;
- RefPtr<WebGLFramebuffer> m_framebufferBinding;
- RefPtr<WebGLRenderbuffer> m_renderbufferBinding;
- class TextureUnitState {
- public:
- RefPtr<WebGLTexture> m_texture2DBinding;
- RefPtr<WebGLTexture> m_textureCubeMapBinding;
- };
- Vector<TextureUnitState> m_textureUnits;
+ RefPtrWillBeMember<WebGLProgram> m_currentProgram;
+ RefPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding;
+ RefPtrWillBeMember<WebGLRenderbuffer> m_renderbufferBinding;
+
+ WillBeHeapVector<TextureUnitState> m_textureUnits;
unsigned long m_activeTextureUnit;
- RefPtr<WebGLTexture> m_blackTexture2D;
- RefPtr<WebGLTexture> m_blackTextureCubeMap;
+ RefPtrWillBeMember<WebGLTexture> m_blackTexture2D;
+ RefPtrWillBeMember<WebGLTexture> m_blackTextureCubeMap;
Vector<GLenum> m_compressedTextureFormats;
@@ -510,7 +529,7 @@ protected:
GLenum m_unpackColorspaceConversion;
bool m_contextLost;
LostContextMode m_contextLostMode;
- RefPtr<WebGLContextAttributes> m_requestedAttributes;
+ RefPtrWillBeMember<WebGLContextAttributes> m_requestedAttributes;
bool m_layerCleared;
GLfloat m_clearColor[4];
@@ -547,7 +566,7 @@ protected:
DraftExtension = 0x01,
};
- class ExtensionTracker {
+ class ExtensionTracker : public NoBaseWillBeGarbageCollected<ExtensionTracker> {
public:
ExtensionTracker(ExtensionFlags flags, const char* const* prefixes)
: m_draft(flags & DraftExtension)
@@ -555,9 +574,11 @@ protected:
{
}
+#if !ENABLE(OILPAN)
virtual ~ExtensionTracker()
{
}
+#endif
bool draft() const
{
@@ -567,11 +588,13 @@ protected:
const char* const* prefixes() const;
bool matchesNameWithPrefixes(const String&) const;
- virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBase*) = 0;
+ virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderingContextBase*) = 0;
virtual bool supported(WebGLRenderingContextBase*) const = 0;
virtual const char* extensionName() const = 0;
virtual void loseExtension() = 0;
+ virtual void trace(Visitor*) { }
+
private:
bool m_draft;
const char* const* m_prefixes;
@@ -580,13 +603,12 @@ protected:
template <typename T>
class TypedExtensionTracker FINAL : public ExtensionTracker {
public:
- TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, const char* const* prefixes)
- : ExtensionTracker(flags, prefixes)
- , m_extensionField(extensionField)
- , m_extension(nullptr)
+ static PassOwnPtrWillBeRawPtr<TypedExtensionTracker<T> > create(RefPtrWillBeMember<T>& extensionField, ExtensionFlags flags, const char* const* prefixes)
{
+ return adoptPtrWillBeNoop(new TypedExtensionTracker<T>(extensionField, flags, prefixes));
}
+#if !ENABLE(OILPAN)
virtual ~TypedExtensionTracker()
{
if (m_extension) {
@@ -594,8 +616,9 @@ protected:
m_extension = nullptr;
}
}
+#endif
- virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBase* context) OVERRIDE
+ virtual PassRefPtrWillBeRawPtr<WebGLExtension> getExtension(WebGLRenderingContextBase* context) OVERRIDE
{
if (!m_extension) {
m_extension = T::create(context);
@@ -624,20 +647,32 @@ protected:
}
}
+ virtual void trace(Visitor* visitor) OVERRIDE
+ {
+ visitor->trace(m_extension);
+ ExtensionTracker::trace(visitor);
+ }
+
private:
- RefPtr<T>& m_extensionField;
+ TypedExtensionTracker(RefPtrWillBeMember<T>& extensionField, ExtensionFlags flags, const char* const* prefixes)
+ : ExtensionTracker(flags, prefixes)
+ , m_extensionField(extensionField)
+ {
+ }
+
+ RefPtrWillBeMember<T>& m_extensionField;
// ExtensionTracker holds it's own reference to the extension to ensure
// that it is not deleted before this object's destructor is called
- RefPtr<T> m_extension;
+ RefPtrWillBeMember<T> m_extension;
};
bool m_extensionEnabled[WebGLExtensionNameCount];
- Vector<ExtensionTracker*> m_extensions;
+ WillBeHeapVector<OwnPtrWillBeMember<ExtensionTracker> > m_extensions;
template <typename T>
- void registerExtension(RefPtr<T>& extensionPtr, ExtensionFlags flags = ApprovedExtension, const char* const* prefixes = 0)
+ void registerExtension(RefPtrWillBeMember<T>& extensionPtr, ExtensionFlags flags = ApprovedExtension, const char* const* prefixes = 0)
{
- m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, prefixes));
+ m_extensions.append(TypedExtensionTracker<T>::create(extensionPtr, flags, prefixes));
}
bool extensionSupportedAndAllowed(const ExtensionTracker*);
@@ -911,4 +946,6 @@ DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
} // namespace blink
+WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(WebCore::WebGLRenderingContextBase::TextureUnitState);
+
#endif // WebGLRenderingContextBase_h

Powered by Google App Engine
This is Rietveld 408576698