aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-02 15:24:01 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-02 15:24:01 +0000
commitbe2048a371813259c46fc2260d53ccadc4ea8133 (patch)
treef2bcae6e8f6ef8ed57f9e02f597b625e3fe84870 /src/pdf
parent8295dc1474db279df08d816b2115e807c681fad5 (diff)
[PDF] Fix fallout from r1217.
The width and height we pass to SkDevice must be postive. Shader can no longer use negative coordinates (without transform). Shader unflip matrix should use same values as passed to SkPDFDevice (height). Most Shader dictionary entries should be scalars and not ints. Review URL: http://codereview.appspot.com/4454047 git-svn-id: http://skia.googlecode.com/svn/trunk@1219 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pdf')
-rw-r--r--src/pdf/SkPDFDevice.cpp2
-rw-r--r--src/pdf/SkPDFShader.cpp31
2 files changed, 18 insertions, 15 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index ef06c60bb4..0e476a2b83 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -135,7 +135,7 @@ static inline SkBitmap makeContentBitmap(const SkISize& contentSize,
SkISize size = SkSize::Make(drawingSize.fX, drawingSize.fY).toRound();
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kNo_Config, size.fWidth, size.fHeight);
+ bitmap.setConfig(SkBitmap::kNo_Config, abs(size.fWidth), abs(size.fHeight));
return bitmap;
}
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index 2538c0db12..6845e09833 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -496,12 +496,14 @@ void SkPDFShader::doImageShader() {
transformBBox(finalMatrix, &surfaceBBox);
SkMatrix unflip;
- unflip.setTranslate(0, surfaceBBox.fBottom);
+ unflip.setTranslate(0, SkScalarRound(surfaceBBox.height()));
unflip.preScale(1, -1);
- SkISize size = SkISize::Make(surfaceBBox.width(), surfaceBBox.height());
+ SkISize size = SkISize::Make(SkScalarRound(surfaceBBox.width()),
+ SkScalarRound(surfaceBBox.height()));
SkPDFDevice pattern(size, size, unflip);
SkCanvas canvas(&pattern);
- canvas.clipRect(surfaceBBox, SkRegion::kReplace_Op);
+ canvas.translate(-surfaceBBox.fLeft, -surfaceBBox.fTop);
+ finalMatrix.preTranslate(surfaceBBox.fLeft, surfaceBBox.fTop);
const SkBitmap* image = &fState.get()->fImage;
int width = image->width();
@@ -511,7 +513,8 @@ void SkPDFShader::doImageShader() {
tileModes[1] = fState.get()->fImageTileModes[1];
canvas.drawBitmap(*image, 0, 0);
- SkRect patternBBox = SkRect::MakeWH(width, height);
+ SkRect patternBBox = SkRect::MakeXYWH(-surfaceBBox.fLeft, -surfaceBBox.fTop,
+ width, height);
// Tiling is implied. First we handle mirroring.
if (tileModes[0] == SkShader::kMirror_TileMode) {
@@ -589,7 +592,7 @@ void SkPDFShader::doImageShader() {
leftMatrix.postTranslate(0, 2 * height);
canvas.drawBitmapMatrix(left, leftMatrix);
}
- patternBBox.fLeft = surfaceBBox.fLeft;
+ patternBBox.fLeft = 0;
}
if (surfaceBBox.fRight > width) {
@@ -607,7 +610,7 @@ void SkPDFShader::doImageShader() {
rightMatrix.postTranslate(0, 2 * height);
canvas.drawBitmapMatrix(right, rightMatrix);
}
- patternBBox.fRight = surfaceBBox.fRight;
+ patternBBox.fRight = surfaceBBox.width();
}
}
@@ -627,7 +630,7 @@ void SkPDFShader::doImageShader() {
topMatrix.postTranslate(2 * width, 0);
canvas.drawBitmapMatrix(top, topMatrix);
}
- patternBBox.fTop = surfaceBBox.fTop;
+ patternBBox.fTop = 0;
}
if (surfaceBBox.fBottom > height) {
@@ -645,17 +648,17 @@ void SkPDFShader::doImageShader() {
bottomMatrix.postTranslate(2 * width, 0);
canvas.drawBitmapMatrix(bottom, bottomMatrix);
}
- patternBBox.fBottom = surfaceBBox.fBottom;
+ patternBBox.fBottom = surfaceBBox.height();
}
}
SkRefPtr<SkPDFArray> patternBBoxArray = new SkPDFArray;
patternBBoxArray->unref(); // SkRefPtr and new both took a reference.
patternBBoxArray->reserve(4);
- patternBBoxArray->append(new SkPDFInt(patternBBox.fLeft))->unref();
- patternBBoxArray->append(new SkPDFInt(patternBBox.fTop))->unref();
- patternBBoxArray->append(new SkPDFInt(patternBBox.fRight))->unref();
- patternBBoxArray->append(new SkPDFInt(patternBBox.fBottom))->unref();
+ patternBBoxArray->append(new SkPDFScalar(patternBBox.fLeft))->unref();
+ patternBBoxArray->append(new SkPDFScalar(patternBBox.fTop))->unref();
+ patternBBoxArray->append(new SkPDFScalar(patternBBox.fRight))->unref();
+ patternBBoxArray->append(new SkPDFScalar(patternBBox.fBottom))->unref();
// Put the canvas into the pattern stream (fContent).
SkRefPtr<SkStream> content = pattern.content();
@@ -669,8 +672,8 @@ void SkPDFShader::doImageShader() {
fContent->insert("PaintType", new SkPDFInt(1))->unref();
fContent->insert("TilingType", new SkPDFInt(1))->unref();
fContent->insert("BBox", patternBBoxArray.get());
- fContent->insert("XStep", new SkPDFInt(patternBBox.width()))->unref();
- fContent->insert("YStep", new SkPDFInt(patternBBox.height()))->unref();
+ fContent->insert("XStep", new SkPDFScalar(patternBBox.width()))->unref();
+ fContent->insert("YStep", new SkPDFScalar(patternBBox.height()))->unref();
fContent->insert("Resources", pattern.getResourceDict().get());
fContent->insert("Matrix", SkPDFUtils::MatrixToArray(finalMatrix))->unref();