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 @@
#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"
......@@ -1109,15 +1111,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()));
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)
......
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