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

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

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/modules/canvas2d/CanvasRenderingContext2D.cpp
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
index 87c61553bbf6441278890508e9e323db66d2a90e..80725ec9c8524d81133457d73205e20cc4c4457e 100644
--- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
@@ -1376,7 +1376,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())
@@ -1484,7 +1485,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:
@@ -1774,6 +1775,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);
@@ -1998,9 +2003,9 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
// The slop built in to this mask rect matches the heuristic used in FontCGWin.cpp for GDI text.
TextRunPaintInfo textRunPaintInfo(textRun);
textRunPaintInfo.bounds = FloatRect(location.x() - fontMetrics.height() / 2,
- location.y() - fontMetrics.ascent() - fontMetrics.lineGap(),
- width + fontMetrics.height(),
- fontMetrics.lineSpacing());
+ location.y() - fontMetrics.ascent() - fontMetrics.lineGap(),
+ width + fontMetrics.height(),
+ fontMetrics.lineSpacing());
if (paintType == CanvasRenderingContext2DState::StrokePaintType)
inflateStrokeRect(textRunPaintInfo.bounds);

Powered by Google App Engine
This is Rietveld 408576698