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

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

Issue 1372463002: Re-land: Make 2D canvas smarter about chosing whether or not to use GPU acceleration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed assert 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: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h
index fe94e77c5fa886895fc6d84eb6ab6d76da4d2fe1..a670d65bc08ab24726bcd5979cca39b32e78e022 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h
@@ -53,7 +53,13 @@ class SharedContextRateLimiter;
class PLATFORM_EXPORT Canvas2DLayerBridge : public WebExternalTextureLayerClient, public WebThread::TaskObserver, public RefCounted<Canvas2DLayerBridge> {
WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
public:
- static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, int msaaSampleCount);
+ enum AccelerationMode {
+ DisableAcceleration,
+ EnableAcceleration,
+ ForceAccelerationForTesting,
+ };
+
+ static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, int msaaSampleCount, OpacityMode, AccelerationMode);
~Canvas2DLayerBridge() override;
@@ -71,7 +77,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*);
@@ -79,14 +85,15 @@ public:
bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, int x, int y);
void flush();
void flushGpu();
+ void prepareSurfaceForPaintingIfNeeded();
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);
WebGraphicsContext3D* context();
void startRecording();
void skipQueuedDrawCommands();
@@ -97,6 +104,9 @@ private:
void willProcessTask() override;
void didProcessTask() override;
+ SkSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration);
+ bool shouldAccelerate(AccelerationHint) const;
+
OwnPtr<SkPictureRecorder> m_recorder;
RefPtr<SkSurface> m_surface;
int m_initialSurfaceSaveCount;
@@ -135,6 +145,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