[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
This commit is contained in:
parent
32a0fb051f
commit
b054990307
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user