aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-28 21:37:20 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-28 21:37:20 +0000
commitda6c569334b5971e55dc95cb9bf85853d068e999 (patch)
treecd7d8d2cccf05de3603110b489c4b865233eb012 /src
parent23579275c7f544763d074d90563c4b1e567ab041 (diff)
[PDF] Fix PDF code to not crash on SkComposeShader.
Review URL: https://codereview.appspot.com/6354053 git-svn-id: http://skia.googlecode.com/svn/trunk@4400 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/pdf/SkPDFDevice.cpp11
-rw-r--r--src/pdf/SkPDFShader.cpp8
2 files changed, 10 insertions, 9 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 85917284db..68c210d2bc 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1401,6 +1401,8 @@ void SkPDFDevice::populateGraphicStateEntryFromPaint(
entry->fMatrix = matrix;
entry->fClipStack = clipStack;
entry->fClipRegion = clipRegion;
+ entry->fColor = SkColorSetA(paint.getColor(), 0xFF);
+ entry->fShaderIndex = -1;
// PDF treats a shader as a color, so we only set one or the other.
SkRefPtr<SkPDFObject> pdfShader;
@@ -1439,11 +1441,6 @@ void SkPDFDevice::populateGraphicStateEntryFromPaint(
} else {
// A color shader is treated as an invalid shader so we don't have
// to set a shader just for a color.
- entry->fShaderIndex = -1;
- entry->fColor = 0;
- color = 0;
-
- // Check for a color shader.
SkShader::GradientInfo gradientInfo;
SkColor gradientColor;
gradientInfo.fColors = &gradientColor;
@@ -1455,10 +1452,6 @@ void SkPDFDevice::populateGraphicStateEntryFromPaint(
color = gradientColor;
}
}
- } else {
- entry->fShaderIndex = -1;
- entry->fColor = SkColorSetA(paint.getColor(), 0xFF);
- color = paint.getColor();
}
SkRefPtr<SkPDFGraphicState> newGraphicState;
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index fc9f8c0204..22175cce89 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -362,6 +362,14 @@ SkPDFObject* SkPDFShader::GetPDFShader(const SkShader& shader,
SkPDFObject* result;
SkAutoMutexAcquire lock(CanonicalShadersMutex());
SkAutoTDelete<State> shaderState(new State(shader, matrix, surfaceBBox));
+ if (shaderState.get()->fType == SkShader::kNone_GradientType &&
+ shaderState.get()->fImage.isNull()) {
+ // TODO(vandebo) This drops SKComposeShader on the floor. We could
+ // handle compose shader by pulling things up to a layer, drawing with
+ // the first shader, applying the xfer mode and drawing again with the
+ // second shader, then applying the layer to the original drawing.
+ return NULL;
+ }
ShaderCanonicalEntry entry(NULL, shaderState.get());
int index = CanonicalShaders().find(entry);