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

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

Issue 1307143005: Make 2D canvas smarter about chosing whether or not to use GPU acceleration (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixing some logic Created 5 years, 3 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/Canvas2DLayerBridge.h
diff --git a/Source/platform/graphics/Canvas2DLayerBridge.h b/Source/platform/graphics/Canvas2DLayerBridge.h
index 62bfef350138f3a8e8134671f46950b8c1471358..174366b12a4c9fe504dd79af875dcef43b8215d9 100644
--- a/Source/platform/graphics/Canvas2DLayerBridge.h
+++ b/Source/platform/graphics/Canvas2DLayerBridge.h
@@ -51,7 +51,13 @@ class WebGraphicsContext3DProvider;
class PLATFORM_EXPORT Canvas2DLayerBridge : public WebExternalTextureLayerClient, public RefCounted<Canvas2DLayerBridge> {
WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
public:
- static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, int msaaSampleCount);
+ enum AccelerationMode {
+ DisableAcceleration,
+ EnableAcceleration,
+ ForceAcceleration,
Stephen White 2015/09/15 20:43:58 Please rename ForceAcceleration -> ForceAccelerati
+ };
+
+ static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, int msaaSampleCount, OpacityMode, AccelerationMode);
~Canvas2DLayerBridge() override;
@@ -69,7 +75,7 @@ public:
bool checkSurfaceValid();
bool restoreSurface();
WebLayer* layer() const;
- bool isAccelerated() const { return true; }
+ bool isAccelerated() const;
void setFilterQuality(SkFilterQuality);
void setIsHidden(bool);
void setImageBuffer(ImageBuffer*);
@@ -77,21 +83,23 @@ public:
bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, int x, int y);
void flush();
void flushGpu();
-
+ void prepareSurfaceForPaintingIfNeeded();
void limitPendingFrames();
bool isHidden() { return m_isHidden; }
void beginDestruction();
- PassRefPtr<SkImage> newImageSnapshot();
+ PassRefPtr<SkImage> newImageSnapshot(AccelerationHint);
private:
- Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider>, PassRefPtr<SkSurface>, int, OpacityMode);
+ Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider>, const IntSize&, int msaaSampleCount, OpacityMode, AccelerationMode);
void setRateLimitingEnabled(bool);
WebGraphicsContext3D* context();
void startRecording();
void skipQueuedDrawCommands();
void flushRecordingOnly();
+ SkSurface* surface(AccelerationHint = PreferAcceleration);
Stephen White 2015/09/15 20:43:58 <bikeshed> Prefer a name that indicates that this
+ bool shouldAccelerate(AccelerationHint) const;
OwnPtr<SkPictureRecorder> m_recorder;
RefPtr<SkSurface> m_surface;
@@ -131,6 +139,7 @@ private:
Deque<MailboxInfo, MaxActiveMailboxes> m_mailboxes;
GLenum m_lastFilter;
+ AccelerationMode m_accelerationMode;
OpacityMode m_opacityMode;
IntSize m_size;
int m_recordingPixelCount;

Powered by Google App Engine
This is Rietveld 408576698