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

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

Issue 14217005: Limit the number of WebGL contexts that are active at any given time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased to latest master Created 7 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/core/platform/graphics/gpu/DrawingBuffer.h
diff --git a/Source/core/platform/graphics/gpu/DrawingBuffer.h b/Source/core/platform/graphics/gpu/DrawingBuffer.h
index 5bc0a40d0ad977d0dc70a2320c0fc7357d77df94..f472fe996c5ba4d9ea3f6d839dc01fbdcc0d4d20 100644
--- a/Source/core/platform/graphics/gpu/DrawingBuffer.h
+++ b/Source/core/platform/graphics/gpu/DrawingBuffer.h
@@ -51,6 +51,15 @@ namespace WebCore {
class GraphicsContext3D;
class ImageData;
+// Abstract interface to allow basic context eviction management
+class ContextEvictionManager : public RefCounted<ContextEvictionManager> {
+public:
+ virtual ~ContextEvictionManager() {};
+
+ virtual void forciblyLoseOldestContext(const String& reason) = 0;
+ virtual IntSize oldestContextSize() = 0;
+};
+
// Manages a rendering target (framebuffer + attachment) for a canvas. Can publish its rendering
// results to a PlatformLayer for compositing.
class DrawingBuffer : public RefCounted<DrawingBuffer>, public WebKit::WebExternalTextureLayerClient {
@@ -65,7 +74,7 @@ public:
Discard
};
- static PassRefPtr<DrawingBuffer> create(GraphicsContext3D*, const IntSize&, PreserveDrawingBuffer);
+ static PassRefPtr<DrawingBuffer> create(GraphicsContext3D*, const IntSize&, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>);
~DrawingBuffer();
@@ -121,7 +130,7 @@ public:
private:
DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported,
- bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer);
+ bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>);
void initialize(const IntSize&);
@@ -152,6 +161,10 @@ private:
// Calculates the difference in pixels between the current buffer size and the proposed size.
int pixelDelta(const IntSize& size);
+ // Given the desired buffer size, provides the largest dimensions that will fit in the pixel budget
+ // Returns true if the buffer will only fit if the oldest WebGL context is forcibly lost
+ IntSize adjustSizeWithContextEviction(const IntSize&, bool& evictContext);
+
PreserveDrawingBuffer m_preserveDrawingBuffer;
bool m_scissorEnabled;
Platform3DObject m_texture2DBinding;
@@ -192,6 +205,8 @@ private:
// Mailboxes that were released by the compositor and can be used again by this DrawingBuffer.
Vector<RefPtr<MailboxInfo> > m_recycledMailboxes;
RefPtr<MailboxInfo> m_lastColorBuffer;
+
+ RefPtr<ContextEvictionManager> m_contextEvictionManager;
};
} // namespace WebCore
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.cpp ('k') | Source/core/platform/graphics/gpu/DrawingBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698