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

Unified Diff: Source/platform/graphics/Canvas2DLayerBridge.h

Issue 117703004: Free temporary GPU and memory resources held by inactive or hidden 2D canvases (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed upstream git branch Created 7 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: Source/platform/graphics/Canvas2DLayerBridge.h
diff --git a/Source/platform/graphics/Canvas2DLayerBridge.h b/Source/platform/graphics/Canvas2DLayerBridge.h
index d259c5fcd9d678c4bc10e7f701853ece552f9247..c2983a2c75d1caf3c4195ec563a9184d1e13400a 100644
--- a/Source/platform/graphics/Canvas2DLayerBridge.h
+++ b/Source/platform/graphics/Canvas2DLayerBridge.h
@@ -48,10 +48,17 @@ class Canvas2DLayerBridgeTest;
namespace WebCore {
+class Canvas2DLayerBridgeClient {
+public:
+ virtual bool hidden() const = 0;
+ virtual ~Canvas2DLayerBridgeClient() { }
+};
+
class PLATFORM_EXPORT Canvas2DLayerBridge : public blink::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayerBridge>, public RefCounted<Canvas2DLayerBridge> {
WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
public:
- static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, int msaaSampleCount);
+ static PassRefPtr<Canvas2DLayerBridge> create(Canvas2DLayerBridgeClient*, const IntSize&, OpacityMode, int msaaSampleCount);
+
virtual ~Canvas2DLayerBridge();
// blink::WebExternalTextureLayerClient implementation.
@@ -77,15 +84,21 @@ public:
virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking
virtual void flush(); // virtual for mocking
virtual size_t storageAllocatedForRecording(); // virtual for faking
- size_t bytesAllocated() const {return m_bytesAllocated;}
+ size_t bytesAllocated() const { return m_bytesAllocated; }
void limitPendingFrames();
+ void freeReleasedMailbox();
+ bool hasReleasedMailbox() const { return m_releasedMailboxInfo; };
+ void freeTransientResources();
+ bool hasTransientResources() const;
+ bool hidden() const;
void beginDestruction();
protected:
- Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, PassOwnPtr<SkDeferredCanvas>, int, OpacityMode);
+ Canvas2DLayerBridge(Canvas2DLayerBridgeClient*, PassRefPtr<GraphicsContext3D>, PassOwnPtr<SkDeferredCanvas>, int, OpacityMode);
void setRateLimitingEnabled(bool);
+ Canvas2DLayerBridgeClient* m_client;
OwnPtr<SkDeferredCanvas> m_canvas;
OwnPtr<blink::WebExternalTextureLayer> m_layer;
RefPtr<GraphicsContext3D> m_context;
@@ -94,6 +107,7 @@ protected:
bool m_didRecordDrawCommand;
bool m_surfaceIsValid;
int m_framesPending;
+ int m_framesSinceMailboxRelease;
bool m_destructionInProgress;
bool m_rateLimitingEnabled;
@@ -110,7 +124,7 @@ protected:
struct MailboxInfo {
blink::WebExternalTextureMailbox m_mailbox;
- SkAutoTUnref<SkImage> m_image;
+ RefPtr<SkImage> m_image;
MailboxStatus m_status;
RefPtr<Canvas2DLayerBridge> m_parentLayerBridge;
@@ -121,6 +135,7 @@ protected:
uint32_t m_lastImageId;
Vector<MailboxInfo> m_mailboxes;
+ MailboxInfo* m_releasedMailboxInfo;
};
}
#endif

Powered by Google App Engine
This is Rietveld 408576698