aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-04-27 14:00:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-27 14:00:09 -0700
commita25b3371a7209105e6c05f7bbb53d19e2b14498b (patch)
tree31a434cf24d4f10506aae7e303f6dd0958d1103b /src
parent9a22f489e8722dd83c65f33fb886019d9f60e479 (diff)
SkPDF: clean up uses of deprecated calls in other SkPDF classes
Diffstat (limited to 'src')
-rw-r--r--src/pdf/SkPDFBitmap.cpp10
-rw-r--r--src/pdf/SkPDFFormXObject.cpp14
-rw-r--r--src/pdf/SkPDFGraphicState.cpp19
-rw-r--r--src/pdf/SkPDFShader.cpp22
-rw-r--r--src/pdf/SkPDFTypes.cpp4
-rw-r--r--src/pdf/SkPDFTypes.h1
6 files changed, 36 insertions, 34 deletions
diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp
index 3b0d38ce26..29b3bee748 100644
--- a/src/pdf/SkPDFBitmap.cpp
+++ b/src/pdf/SkPDFBitmap.cpp
@@ -322,7 +322,7 @@ static SkPDFArray* make_indexed_color_space(const SkColorTable* table) {
result->appendInt(0);
char shortTableArray[3] = {0, 0, 0};
SkString tableString(shortTableArray, SK_ARRAY_COUNT(shortTableArray));
- result->append(new SkPDFString(tableString))->unref();
+ result->appendString(tableString);
return result;
}
result->appendInt(table->count() - 1); // maximum color index.
@@ -338,7 +338,7 @@ static SkPDFArray* make_indexed_color_space(const SkColorTable* table) {
tablePtr += 3;
}
SkString tableString(tableArray, 3 * table->count());
- result->append(new SkPDFString(tableString))->unref();
+ result->appendString(tableString);
return result;
}
@@ -362,8 +362,8 @@ void PDFDefaultBitmap::emitObject(SkWStream* stream,
pdfDict.insertInt("Height", fBitmap.height());
if (fBitmap.colorType() == kIndex_8_SkColorType) {
SkASSERT(1 == pdf_color_component_count(fBitmap.colorType()));
- pdfDict.insert("ColorSpace", make_indexed_color_space(
- fBitmap.getColorTable()))->unref();
+ pdfDict.insertObject("ColorSpace",
+ make_indexed_color_space(fBitmap.getColorTable()));
} else if (1 == pdf_color_component_count(fBitmap.colorType())) {
pdfDict.insertName("ColorSpace", "DeviceGray");
} else {
@@ -371,7 +371,7 @@ void PDFDefaultBitmap::emitObject(SkWStream* stream,
}
pdfDict.insertInt("BitsPerComponent", 8);
if (fSMask) {
- pdfDict.insert("SMask", new SkPDFObjRef(fSMask))->unref();
+ pdfDict.insertObjRef("SMask", SkRef(fSMask.get()));
}
pdfDict.insertName("Filter", "FlateDecode");
pdfDict.insertInt("Length", asset->getLength());
diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp
index 3e765c078c..07f42facb3 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -37,7 +37,7 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
SkASSERT(false);
inverse.reset();
}
- insert("Matrix", SkPDFUtils::MatrixToArray(inverse))->unref();
+ this->insertObject("Matrix", SkPDFUtils::MatrixToArray(inverse));
}
}
@@ -58,10 +58,10 @@ SkPDFFormXObject::SkPDFFormXObject(SkStream* content, SkRect bbox,
*/
void SkPDFFormXObject::init(const char* colorSpace,
SkPDFDict* resourceDict, SkPDFArray* bbox) {
- insertName("Type", "XObject");
- insertName("Subtype", "Form");
- insert("Resources", resourceDict);
- insert("BBox", bbox);
+ this->insertName("Type", "XObject");
+ this->insertName("Subtype", "Form");
+ this->insertObject("Resources", SkRef(resourceDict));
+ this->insertObject("BBox", SkRef(bbox));
// Right now SkPDFFormXObject is only used for saveLayer, which implies
// isolated blending. Do this conditionally if that changes.
@@ -71,8 +71,8 @@ void SkPDFFormXObject::init(const char* colorSpace,
if (colorSpace != NULL) {
group->insertName("CS", colorSpace);
}
- group->insert("I", new SkPDFBool(true))->unref(); // Isolated.
- insert("Group", group.get());
+ group->insertBool("I", true); // Isolated.
+ this->insertObject("Group", group.detach());
}
SkPDFFormXObject::~SkPDFFormXObject() {}
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index 04eda5812a..d063c1505e 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -143,8 +143,8 @@ SkPDFObject* create_invert_function() {
SkPDFStream* invertFunction = SkNEW_ARGS(
SkPDFStream, (psInvertStream.get()));
invertFunction->insertInt("FunctionType", 4);
- invertFunction->insert("Domain", domainAndRange.get());
- invertFunction->insert("Range", domainAndRange.get());
+ invertFunction->insertObject("Domain", SkRef(domainAndRange.get()));
+ invertFunction->insertObject("Range", domainAndRange.detach());
return invertFunction;
}
@@ -168,13 +168,13 @@ SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
} else if (sMaskMode == kLuminosity_SMaskMode) {
sMaskDict->insertName("S", "Luminosity");
}
- sMaskDict->insert("G", new SkPDFObjRef(sMask))->unref();
+ sMaskDict->insertObjRef("G", SkRef(sMask));
if (invert) {
- sMaskDict->insert("TR", new SkPDFObjRef(invertFunction.get()))->unref();
+ sMaskDict->insertObjRef("TR", SkRef(invertFunction.get()));
}
SkPDFDict* result = new SkPDFDict("ExtGState");
- result->insert("SMask", sMaskDict.get());
+ result->insertObject("SMask", sMaskDict.detach());
return result;
}
@@ -201,9 +201,9 @@ void SkPDFGraphicState::emitObject(SkWStream* stream,
SkAutoTUnref<SkPDFDict> dict(SkNEW_ARGS(SkPDFDict, ("ExtGState")));
dict->insertName("Type", "ExtGState");
- SkAutoTUnref<SkPDFScalar> alpha(new SkPDFScalar(SkScalarDiv(fAlpha, 0xFF)));
- dict->insert("CA", alpha.get());
- dict->insert("ca", alpha.get());
+ SkScalar alpha = SkScalarDiv(fAlpha, 0xFF);
+ dict->insertScalar("CA", alpha);
+ dict->insertScalar("ca", alpha);
SkPaint::Cap strokeCap = (SkPaint::Cap)fStrokeCap;
SkPaint::Join strokeJoin = (SkPaint::Join)fStrokeJoin;
@@ -225,8 +225,7 @@ void SkPDFGraphicState::emitObject(SkWStream* stream,
dict->insertScalar("LW", fStrokeWidth);
dict->insertScalar("ML", fStrokeMiter);
- // SA = Auto stroke adjustment.
- dict->insert("SA", new SkPDFBool(true))->unref();
+ dict->insertBool("SA", true); // SA = Auto stroke adjustment.
dict->insertName("BM", as_blend_mode(xferMode));
dict->emitObject(stream, objNumMap, substitutes);
}
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index be9798f850..cf4188123a 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -601,12 +601,12 @@ static void populate_tiling_pattern_dict(SkPDFDict* pattern,
pattern->insertInt("PatternType", kTiling_PatternType);
pattern->insertInt("PaintType", kColoredTilingPattern_PaintType);
pattern->insertInt("TilingType", kConstantSpacing_TilingType);
- pattern->insert("BBox", SkPDFUtils::RectToArray(bbox))->unref();
+ pattern->insertObject("BBox", SkPDFUtils::RectToArray(bbox));
pattern->insertScalar("XStep", bbox.width());
pattern->insertScalar("YStep", bbox.height());
- pattern->insert("Resources", resources);
+ pattern->insertObject("Resources", SkRef(resources));
if (!matrix.isIdentity()) {
- pattern->insert("Matrix", SkPDFUtils::MatrixToArray(matrix))->unref();
+ pattern->insertObject("Matrix", SkPDFUtils::MatrixToArray(matrix));
}
}
@@ -755,8 +755,8 @@ static SkPDFStream* make_ps_function(const SkString& psCode,
SkData::NewWithCopy(psCode.c_str(), psCode.size()));
SkPDFStream* result = SkNEW_ARGS(SkPDFStream, (funcData.get()));
result->insertInt("FunctionType", 4);
- result->insert("Domain", domain);
- result->insert("Range", rangeObject.get());
+ result->insertObject("Domain", SkRef(domain));
+ result->insertObject("Range", SkRef(rangeObject.get()));
return result;
}
@@ -871,21 +871,19 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create(
SkAutoTUnref<SkPDFDict> pdfShader(new SkPDFDict);
pdfShader->insertInt("ShadingType", 1);
pdfShader->insertName("ColorSpace", "DeviceRGB");
- pdfShader->insert("Domain", domain.get());
+ pdfShader->insertObject("Domain", SkRef(domain.get()));
SkAutoTUnref<SkPDFStream> function(
make_ps_function(functionCode, domain.get()));
- pdfShader->insert("Function", new SkPDFObjRef(function))->unref();
-
- SkAutoTUnref<SkPDFArray> matrixArray(
- SkPDFUtils::MatrixToArray(finalMatrix));
+ pdfShader->insertObjRef("Function", function.detach());
SkPDFFunctionShader* pdfFunctionShader =
SkNEW_ARGS(SkPDFFunctionShader, (autoState->detach()));
pdfFunctionShader->insertInt("PatternType", 2);
- pdfFunctionShader->insert("Matrix", matrixArray.get());
- pdfFunctionShader->insert("Shading", pdfShader.get());
+ pdfFunctionShader->insertObject("Matrix",
+ SkPDFUtils::MatrixToArray(finalMatrix));
+ pdfFunctionShader->insertObject("Shading", pdfShader.detach());
canon->addFunctionShader(pdfFunctionShader);
return pdfFunctionShader;
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp
index 510b98b17f..11f4310944 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -518,6 +518,10 @@ SkPDFObject* SkPDFDict::insert(const char key[], SkPDFObject* value) {
return value;
}
+void SkPDFDict::insertBool(const char key[], bool value) {
+ this->set(SkPDFUnion::Name(key), SkPDFUnion::Bool(value));
+}
+
void SkPDFDict::insertInt(const char key[], int32_t value) {
this->set(SkPDFUnion::Name(key), SkPDFUnion::Int(value));
}
diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h
index f258e384e5..bc24dd5cf5 100644
--- a/src/pdf/SkPDFTypes.h
+++ b/src/pdf/SkPDFTypes.h
@@ -353,6 +353,7 @@ public:
* @param key The text of the key for this dictionary entry.
* @param value The value for this dictionary entry.
*/
+ void insertBool(const char key[], bool value);
void insertInt(const char key[], int32_t value);
void insertInt(const char key[], size_t value);
void insertScalar(const char key[], SkScalar value);