Commit 16fb00d1 authored by junov@chromium.org's avatar junov@chromium.org

Fix the rasterization resolution of zoomed canvases with display list backing

The patch makes use of an intermediate render buffer at an alternate
resolution for rasterizing scaled canvases in a spec compliant way.

BUG=392600
TEST=layout tests with zoomed canvases (there's lots) with --enabled display-list-2d-canvas

Review URL: https://codereview.chromium.org/467353002

git-svn-id: svn://svn.chromium.org/blink/trunk@180215 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2a69a6cd
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
#include "third_party/skia/include/effects/SkBlurMaskFilter.h" #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
#include "third_party/skia/include/effects/SkCornerPathEffect.h" #include "third_party/skia/include/effects/SkCornerPathEffect.h"
#include "third_party/skia/include/effects/SkLumaColorFilter.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/GrRenderTarget.h"
#include "third_party/skia/include/gpu/GrTexture.h" #include "third_party/skia/include/gpu/GrTexture.h"
#include "wtf/Assertions.h" #include "wtf/Assertions.h"
...@@ -1109,15 +1111,25 @@ void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect ...@@ -1109,15 +1111,25 @@ void GraphicsContext::drawPicture(PassRefPtr<SkPicture> picture, const FloatRect
if (contextDisabled() || !picture) if (contextDisabled() || !picture)
return; 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()));
SkPaint picturePaint; SkPaint picturePaint;
picturePaint.setXfermode(WebCoreCompositeToSkiaComposite(op, blendMode).get()); picturePaint.setXfermode(WebCoreCompositeToSkiaComposite(op, blendMode).get());
SkRect skBounds = WebCoreFloatRectToSKRect(dest); picturePaint.setImageFilter(matrixFilter.get());
saveLayer(&skBounds, &picturePaint); SkRect layerBounds = SkRect::MakeWH(max(deviceDest.width(), sourceBounds.width()), max(deviceDest.height(), sourceBounds.height()));
SkMatrix pictureTransform; m_canvas->save();
pictureTransform.setRectToRect(WebCoreFloatRectToSKRect(src), skBounds, SkMatrix::kFill_ScaleToFit); m_canvas->resetMatrix();
m_canvas->concat(pictureTransform); m_canvas->translate(deviceDest.x(), deviceDest.y());
picture->draw(m_canvas); m_canvas->saveLayer(&layerBounds, &picturePaint);
restoreLayer(); m_canvas->restore();
m_canvas->restore();
} }
void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y) void GraphicsContext::writePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment