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

Unified Diff: src/pdf/SkPDFShader.cpp

Issue 901303003: [PDF] Fix shader fallback mapping when clipped (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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: src/pdf/SkPDFShader.cpp
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index 20df873cbd14b7ba60a7a252cab2d499cf3518e9..54528ce38b245ab16dd7ae158bd2989d26a465e5 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -1219,6 +1219,15 @@ SkPDFShader::State::State(const SkShader& shader, const SkMatrix& canvasTransfor
// * shade the whole area
// * use the result as a bitmap shader
+ // bbox is in device space. While that's exactly what we want for sizing our bitmap,
+ // we need to map it into shader space for adjustments (to match
+ // SkPDFImageShader::Create's behavior).
+ SkRect shaderRect = SkRect::Make(bbox);
robertphillips 2015/02/12 21:12:59 inverse_transform_bbox ?
f(malita) 2015/02/12 21:28:33 Done.
+ if (!inverseTransformBBox(canvasTransform, &shaderRect)) {
+ fImage.reset();
+ return;
+ }
+
// Clamp the bitmap size to about 1M pixels
static const SkScalar kMaxBitmapArea = 1024 * 1024;
SkScalar bitmapArea = rasterScale * bbox.width() * rasterScale * bbox.height();
@@ -1228,8 +1237,8 @@ SkPDFShader::State::State(const SkShader& shader, const SkMatrix& canvasTransfor
SkISize size = SkISize::Make(SkScalarRoundToInt(rasterScale * bbox.width()),
SkScalarRoundToInt(rasterScale * bbox.height()));
- SkSize scale = SkSize::Make(SkIntToScalar(size.width()) / SkIntToScalar(bbox.width()),
- SkIntToScalar(size.height()) / SkIntToScalar(bbox.height()));
+ SkSize scale = SkSize::Make(SkIntToScalar(size.width()) / shaderRect.width(),
+ SkIntToScalar(size.height()) / shaderRect.height());
fImage.allocN32Pixels(size.width(), size.height());
fImage.eraseColor(SK_ColorTRANSPARENT);
@@ -1239,10 +1248,10 @@ SkPDFShader::State::State(const SkShader& shader, const SkMatrix& canvasTransfor
SkCanvas canvas(fImage);
canvas.scale(scale.width(), scale.height());
- canvas.translate(-SkIntToScalar(bbox.x()), -SkIntToScalar(bbox.y()));
+ canvas.translate(-shaderRect.x(), -shaderRect.y());
canvas.drawPaint(p);
- fShaderTransform.setTranslate(SkIntToScalar(bbox.x()), SkIntToScalar(bbox.y()));
+ fShaderTransform.setTranslate(shaderRect.x(), shaderRect.y());
fShaderTransform.preScale(1 / scale.width(), 1 / scale.height());
} else {
SkASSERT(matrix.isIdentity());
« 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