aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-13 20:45:46 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-13 20:45:46 +0000
commitb054990307b7338e599a12d9af10eb2058b94051 (patch)
tree4eb2241f48044c485959bb43a5d6ed808d12df87
parent32a0fb051fe865ebde4d875ab8d224c5a402cb22 (diff)
[PDF] If matrix inversion fails, use the identity matrix.
BUG=chrome:123078 Review URL: https://codereview.appspot.com/6007044 git-svn-id: http://skia.googlecode.com/svn/trunk@3676 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/pdf/SkPDFDevice.cpp9
-rw-r--r--src/pdf/SkPDFFormXObject.cpp5
-rw-r--r--src/pdf/SkPDFShader.cpp9
3 files changed, 15 insertions, 8 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index f3aaa5efae..7e85afdcde 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -490,7 +490,9 @@ static inline SkBitmap makeContentBitmap(const SkISize& contentSize,
SkMatrix inverse;
drawingSize.set(SkIntToScalar(contentSize.fWidth),
SkIntToScalar(contentSize.fHeight));
- initialTransform->invert(&inverse);
+ if (!initialTransform->invert(&inverse)) {
+ inverse.reset();
+ }
inverse.mapVectors(&drawingSize, 1);
SkISize size = SkSize::Make(drawingSize.fX, drawingSize.fY).toRound();
bitmap.setConfig(SkBitmap::kNo_Config, abs(size.fWidth),
@@ -600,8 +602,9 @@ void SkPDFDevice::internalDrawPaint(const SkPaint& paint,
SkMatrix totalTransform = fInitialTransform;
totalTransform.preConcat(contentEntry->fState.fMatrix);
SkMatrix inverse;
- inverse.reset();
- totalTransform.invert(&inverse);
+ if (!totalTransform.invert(&inverse)) {
+ inverse.reset();
+ }
inverse.mapRect(&bbox);
SkPDFUtils::AppendRectangle(bbox, &contentEntry->fContent);
diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp
index fb8a9159cf..f368834938 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -36,8 +36,9 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
// embedded in things like shaders and images.
if (!device->initialTransform().isIdentity()) {
SkMatrix inverse;
- inverse.reset();
- device->initialTransform().invert(&inverse);
+ if (!device->initialTransform().invert(&inverse)) {
+ inverse.reset();
+ }
insert("Matrix", SkPDFUtils::MatrixToArray(inverse))->unref();
}
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index 15acf67c72..3a559ba3d3 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -23,8 +23,9 @@
static void transformBBox(const SkMatrix& matrix, SkRect* bbox) {
SkMatrix inverse;
- inverse.reset();
- matrix.invert(&inverse);
+ if (!matrix.invert(&inverse)) {
+ inverse.reset();
+ }
inverse.mapRect(bbox);
}
@@ -488,7 +489,9 @@ SkPDFFunctionShader::SkPDFFunctionShader(SkPDFShader::State* state)
if (fState.get()->fType == SkShader::kRadial2_GradientType) {
SkShader::GradientInfo twoPointRadialInfo = *info;
SkMatrix inverseMapperMatrix;
- mapperMatrix.invert(&inverseMapperMatrix);
+ if (!mapperMatrix.invert(&inverseMapperMatrix)) {
+ inverseMapperMatrix.reset();
+ }
inverseMapperMatrix.mapPoints(twoPointRadialInfo.fPoint, 2);
twoPointRadialInfo.fRadius[0] =
inverseMapperMatrix.mapRadius(info->fRadius[0]);