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

Unified Diff: Source/modules/canvas2d/CanvasRenderingContext2D.cpp

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: rebase 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/modules/canvas2d/CanvasRenderingContext2D.cpp
diff --git a/Source/modules/canvas2d/CanvasRenderingContext2D.cpp b/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
index 9ef93f60d2cecfd23f54e35b9125f1dd76786506..407e536624bb9c7a08b68c9594e8ed8510a2a5aa 100644
--- a/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
+++ b/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
@@ -1377,7 +1377,8 @@ void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource,
RefPtr<Image> image;
SourceImageStatus sourceImageStatus = InvalidSourceImageStatus;
if (!imageSource->isVideoElement()) {
- image = imageSource->getSourceImageForCanvas(&sourceImageStatus);
+ AccelerationHint hint = canvas()->buffer()->isAccelerated() ? PreferAcceleration : PreferNoAcceleration;
+ image = imageSource->getSourceImageForCanvas(&sourceImageStatus, hint);
if (sourceImageStatus == UndecodableSourceImageStatus)
exceptionState.throwDOMException(InvalidStateError, "The HTMLImageElement provided is in the 'broken' state.");
if (!image || !image->width() || !image->height())
@@ -1485,7 +1486,7 @@ CanvasPattern* CanvasRenderingContext2D::createPattern(const CanvasImageSourceUn
SourceImageStatus status;
CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource);
- RefPtr<Image> imageForRendering = imageSourceInternal->getSourceImageForCanvas(&status);
+ RefPtr<Image> imageForRendering = imageSourceInternal->getSourceImageForCanvas(&status, PreferNoAcceleration);
switch (status) {
case NormalSourceImageStatus:
@@ -1775,6 +1776,10 @@ void CanvasRenderingContext2D::schedulePruneLocalFontCacheIfNeeded()
void CanvasRenderingContext2D::didProcessTask()
{
+ // The rendering surface needs to be prepared now because it will be too late
+ // to create a layer once we are in the paint invalidation phase.
+ canvas()->prepareSurfaceForPaintingIfNeeded();
+
pruneLocalFontCache(canvas()->document().canvasFontCache()->maxFonts());
m_pruneLocalFontCacheScheduled = false;
Platform::current()->currentThread()->removeTaskObserver(this);

Powered by Google App Engine
This is Rietveld 408576698