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

Unified Diff: Source/platform/graphics/gpu/DrawingBuffer.h

Issue 169933002: WebGL: Don't destroy mailbox textures in the destructor until they're released. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase DrawingBufferTest to ToT Created 6 years, 8 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/platform/graphics/gpu/DrawingBuffer.h
diff --git a/Source/platform/graphics/gpu/DrawingBuffer.h b/Source/platform/graphics/gpu/DrawingBuffer.h
index 8d86b7b4cdf029088c0b94bc256db90301c6ac3e..abe3418dab51b21f162922f672f51898ccc8a05b 100644
--- a/Source/platform/graphics/gpu/DrawingBuffer.h
+++ b/Source/platform/graphics/gpu/DrawingBuffer.h
@@ -41,6 +41,7 @@
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "wtf/Deque.h"
#include "wtf/Noncopyable.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
@@ -73,6 +74,10 @@ class PLATFORM_EXPORT DrawingBuffer : public RefCounted<DrawingBuffer>, public b
blink::WebExternalTextureMailbox mailbox;
unsigned textureId;
IntSize size;
+ // This keeps the parent drawing buffer alive as long as the compositor is
+ // referring to one of the mailboxes DrawingBuffer produced. The parent drawing buffer is
+ // cleared when the compositor returns the mailbox. See mailboxReleased().
+ RefPtr<DrawingBuffer> m_parentDrawingBuffer;
};
public:
enum PreserveDrawingBuffer {
@@ -84,6 +89,9 @@ public:
virtual ~DrawingBuffer();
+ // Destruction will be completed after all mailboxes are released.
+ void beginDestruction();
+
// Issues a glClear() on all framebuffers associated with this DrawingBuffer. The caller is responsible for
// making the context current and setting the clear values and masks. Modifies the framebuffer binding.
void clearFramebuffers(GLbitfield clearMask);
@@ -139,7 +147,7 @@ public:
void paintRenderingResultsToCanvas(ImageBuffer*);
PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&);
-private:
+protected: // For unittests
DrawingBuffer(
PassOwnPtr<blink::WebGraphicsContext3D>,
PassOwnPtr<Extensions3DUtil>,
@@ -147,7 +155,9 @@ private:
bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>);
bool initialize(const IntSize&);
- void releaseResources();
+
+private:
+ void mailboxReleasedWhileDestructionInProgress(const blink::WebExternalTextureMailbox&);
unsigned createColorTexture(const IntSize& size = IntSize());
// Create the depth/stencil and multisample buffers, if needed.
@@ -163,6 +173,7 @@ private:
PassRefPtr<MailboxInfo> recycledMailbox();
PassRefPtr<MailboxInfo> createNewMailbox(unsigned);
+ void deleteMailbox(const blink::WebExternalTextureMailbox&);
// Updates the current size of the buffer, ensuring that s_currentResourceUsePixels is updated.
void setSize(const IntSize& size);
@@ -242,13 +253,14 @@ private:
int m_maxTextureSize;
int m_sampleCount;
int m_packAlignment;
+ bool m_destructionInProgress;
OwnPtr<blink::WebExternalTextureLayer> m_layer;
// All of the mailboxes that this DrawingBuffer has ever created.
Vector<RefPtr<MailboxInfo> > m_textureMailboxes;
- // Mailboxes that were released by the compositor and can be used again by this DrawingBuffer.
- Vector<RefPtr<MailboxInfo> > m_recycledMailboxes;
+ // Mailboxes that were released by the compositor can be used again by this DrawingBuffer.
+ Deque<blink::WebExternalTextureMailbox> m_recycledMailboxQueue;
RefPtr<ContextEvictionManager> m_contextEvictionManager;
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.cpp ('k') | Source/platform/graphics/gpu/DrawingBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698