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

Unified Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp

Issue 2687073003: Make disabling 2d canvas GPU acceleration for getImageData less aggressive. (Closed)
Patch Set: Address comments Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/ImageBuffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
index 2e38b192ed37b338fecca618ef940f34a33e00fa..b1e788dadf5f83019e5716a571d01107c87b4678 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
@@ -99,6 +99,8 @@ ImageBuffer::ImageBuffer(std::unique_ptr<ImageBufferSurface> surface)
m_snapshotState(InitialSnapshotState),
m_surface(std::move(surface)),
m_client(0),
+ m_gpuReadbackInvokedInCurrentFrame(false),
+ m_gpuReadbackSuccessiveFrames(0),
m_gpuMemoryUsage(0) {
m_surface->setImageBuffer(this);
updateGPUMemoryUsage();
@@ -149,6 +151,22 @@ bool ImageBuffer::isSurfaceValid() const {
}
void ImageBuffer::finalizeFrame() {
+ if (isAccelerated() &&
+ ExpensiveCanvasHeuristicParameters::GPUReadbackForcesNoAcceleration &&
+ !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled()) {
+ if (m_gpuReadbackInvokedInCurrentFrame) {
+ m_gpuReadbackSuccessiveFrames++;
+ m_gpuReadbackInvokedInCurrentFrame = false;
+ } else {
+ m_gpuReadbackSuccessiveFrames = 0;
+ }
+
+ if (m_gpuReadbackSuccessiveFrames >=
+ ExpensiveCanvasHeuristicParameters::GPUReadbackMinSuccessiveFrames) {
+ disableAcceleration();
+ }
+ }
+
m_surface->finalizeFrame();
}
@@ -359,11 +377,6 @@ bool ImageBuffer::getImageData(Multiply multiplied,
DCHECK(canvas());
- if (ExpensiveCanvasHeuristicParameters::GetImageDataForcesNoAcceleration &&
- !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled()) {
- const_cast<ImageBuffer*>(this)->disableAcceleration();
- }
-
sk_sp<SkImage> snapshot = m_surface->newImageSnapshot(
PreferNoAcceleration, SnapshotReasonGetImageData);
if (!snapshot)
@@ -409,6 +422,7 @@ bool ImageBuffer::getImageData(Multiply multiplied,
snapshot->readPixels(info, result.data(), bytesPerPixel * rect.width(),
rect.x(), rect.y());
+ m_gpuReadbackInvokedInCurrentFrame = true;
if (useF16Workaround) {
uint32_t* pixel = (uint32_t*)result.data();
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/ImageBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698