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

Unified Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 467353002: Fix the rasterization resolution of zoomed canvases with display list backing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: unified approach Created 6 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/GraphicsContext.cpp
diff --git a/Source/platform/graphics/GraphicsContext.cpp b/Source/platform/graphics/GraphicsContext.cpp
index 902e2b7c02c572b40fb3acff3692427265453676..29c25ae302356938c40646845f5c3cb04d398b05 100644
--- a/Source/platform/graphics/GraphicsContext.cpp
+++ b/Source/platform/graphics/GraphicsContext.cpp
@@ -50,6 +50,8 @@
#include "third_party/skia/include/effects/SkBlurMaskFilter.h"
#include "third_party/skia/include/effects/SkCornerPathEffect.h"
#include "third_party/skia/include/effects/SkLumaColorFilter.h"
+#include "third_party/skia/include/effects/SkMatrixImageFilter.h"
+#include "third_party/skia/include/effects/SkPictureImageFilter.h"
#include "third_party/skia/include/gpu/GrRenderTarget.h"
#include "third_party/skia/include/gpu/GrTexture.h"
#include "wtf/Assertions.h"
@@ -1111,15 +1113,25 @@ void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect
if (contextDisabled() || !picture)
return;
+ SkMatrix ctm = m_canvas->getTotalMatrix();
+ SkRect deviceDest;
+ ctm.mapRect(&deviceDest, dest);
+ SkRect sourceBounds = WebCoreFloatRectToSKRect(src);
+
+ RefPtr<SkPictureImageFilter> pictureFilter = adoptRef(SkPictureImageFilter::Create(picture.get(), sourceBounds));
+ SkMatrix layerScale;
+ layerScale.setScale(deviceDest.width() / src.width(), deviceDest.height() / src.height());
+ RefPtr<SkMatrixImageFilter> matrixFilter = adoptRef(SkMatrixImageFilter::Create(layerScale, SkPaint::kLow_FilterLevel, pictureFilter.get()));
Stephen White 2014/08/13 21:26:50 Perf note: using a matrix filter will incur one ex
SkPaint picturePaint;
picturePaint.setXfermode(WebCoreCompositeToSkiaComposite(op, blendMode).get());
- SkRect skBounds = WebCoreFloatRectToSKRect(dest);
- saveLayer(&skBounds, &picturePaint);
- SkMatrix pictureTransform;
- pictureTransform.setRectToRect(WebCoreFloatRectToSKRect(src), skBounds, SkMatrix::kFill_ScaleToFit);
- m_canvas->concat(pictureTransform);
- picture->draw(m_canvas);
- restoreLayer();
+ picturePaint.setImageFilter(matrixFilter.get());
+ SkRect layerBounds = SkRect::MakeWH(max(deviceDest.width(), sourceBounds.width()), max(deviceDest.height(), sourceBounds.height()));
+ m_canvas->save();
+ m_canvas->resetMatrix();
+ m_canvas->translate(deviceDest.x(), deviceDest.y());
+ m_canvas->saveLayer(&layerBounds, &picturePaint);
+ m_canvas->restore();
+ m_canvas->restore();
}
void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698