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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLObject.cpp

Issue 2547813002: Remove WebGLObject maps from WebGLRenderingContextBase and WebGLContextGroup. (Closed)
Patch Set: Fixed WebGLContextObject::validate. Made WebGLExtension non-finalized. Created 4 years 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/WebGLObject.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLObject.cpp b/third_party/WebKit/Source/modules/webgl/WebGLObject.cpp
index ad18c67b40ef29a8558cfcddaabe25b03687677a..69909cb8fb0527e0454e0580fd03ebf97997e8fc 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLObject.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLObject.cpp
@@ -29,12 +29,16 @@
namespace blink {
-WebGLObject::WebGLObject(WebGLRenderingContextBase*)
- : m_attachmentCount(0), m_deleted(false) {}
+WebGLObject::WebGLObject(WebGLRenderingContextBase* context)
+ : m_cachedNumberOfContextLosses(context->numberOfContextLosses()),
+ m_attachmentCount(0),
+ m_deleted(false),
+ m_destructionInProgress(false) {}
-WebGLObject::~WebGLObject() {
- // Verify that platform objects have been explicitly deleted.
- ASSERT(m_deleted);
+WebGLObject::~WebGLObject() {}
+
+uint32_t WebGLObject::cachedNumberOfContextLosses() const {
+ return m_cachedNumberOfContextLosses;
}
void WebGLObject::deleteObject(gpu::gles2::GLES2Interface* gl) {
@@ -45,6 +49,11 @@ void WebGLObject::deleteObject(gpu::gles2::GLES2Interface* gl) {
if (!hasGroupOrContext())
return;
+ if (currentNumberOfContextLosses() != m_cachedNumberOfContextLosses) {
haraken 2016/12/05 05:15:59 Can we use validate()?
Ken Russell (switch to Gerrit) 2016/12/05 06:03:40 Sorry, no. We don't have a reference to our contex
+ // This object has been invalidated.
+ return;
+ }
+
if (!m_attachmentCount) {
if (!gl)
gl = getAGLInterface();
@@ -63,13 +72,23 @@ void WebGLObject::detach() {
void WebGLObject::detachAndDeleteObject() {
// To ensure that all platform objects are deleted after being detached,
// this method does them together.
- //
- // The individual WebGL destructors need to call detachAndDeleteObject()
- // rather than do it based on Oilpan GC.
detach();
deleteObject(nullptr);
}
+void WebGLObject::runDestructor() {
+ DCHECK(!m_destructionInProgress);
+ // This boilerplate destructor is sufficient for all subclasses, as long
+ // as they implement deleteObjectImpl properly, and don't try to touch
+ // other objects on the Oilpan heap if the destructor's been entered.
+ m_destructionInProgress = true;
+ detachAndDeleteObject();
+}
+
+bool WebGLObject::destructionInProgress() const {
+ return m_destructionInProgress;
+}
+
void WebGLObject::onDetached(gpu::gles2::GLES2Interface* gl) {
if (m_attachmentCount)
--m_attachmentCount;
@@ -77,4 +96,6 @@ void WebGLObject::onDetached(gpu::gles2::GLES2Interface* gl) {
deleteObject(gl);
}
+DEFINE_TRACE_WRAPPERS(WebGLObject) {}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698