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

Unified Diff: src/pdf/SkPDFShader.cpp

Issue 19509005: If we fail to contruct the Pdf Image Shader, mark the object as busted, and dn't try to remove it f… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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
===================================================================
--- src/pdf/SkPDFShader.cpp (revision 10235)
+++ src/pdf/SkPDFShader.cpp (working copy)
@@ -444,11 +444,13 @@
public:
explicit SkPDFImageShader(SkPDFShader::State* state);
virtual ~SkPDFImageShader() {
- RemoveShader(this);
- fResources.unrefAll();
+ if (!fFailedConstructor) {
+ RemoveShader(this);
+ fResources.unrefAll();
+ }
}
- virtual bool isValid() { return size() > 0; }
+ virtual bool isValid() { return !fFailedConstructor && size() > 0; }
void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects,
SkTSet<SkPDFObject*>* newResourceObjects) {
@@ -460,6 +462,7 @@
private:
SkTSet<SkPDFObject*> fResources;
SkAutoTDelete<const SkPDFShader::State> fState;
+ bool fFailedConstructor;
vandebo (ex-Chrome) 2013/07/23 15:09:50 I don't think you need this field. Just adding th
edisonn 2013/07/23 15:34:18 Done.
};
SkPDFShader::SkPDFShader() {}
@@ -511,6 +514,9 @@
result = functionShader;
}
if (!valid) {
+ // Release the lock, otherwise we end up calling RemoveShader that locks again,
vandebo (ex-Chrome) 2013/07/23 15:09:50 nit: please wrap at 80 cols; the rest of the file
edisonn 2013/07/23 15:34:18 Done.
+ // and we end up with a freeze.
+ lock.release();
delete result;
return NULL;
}
@@ -659,7 +665,8 @@
insert("Shading", pdfShader.get());
}
-SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state) {
+SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) : fState(state)
+ , fFailedConstructor(false) {
fState.get()->fImage.lockPixels();
SkMatrix finalMatrix = fState.get()->fCanvasTransform;
@@ -667,6 +674,7 @@
SkRect surfaceBBox;
surfaceBBox.set(fState.get()->fBBox);
if (!transformBBox(finalMatrix, &surfaceBBox)) {
+ fFailedConstructor = true;
return;
}
« 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