diff options
author | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-07-20 18:39:20 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-07-20 18:39:20 +0000 |
commit | 06f7f4051eeb299cb15b308edabd17344c183a36 (patch) | |
tree | df1812cf2f5672455db2677c55e8c5446e0bb03a /src | |
parent | 421d6443fbd3a913dfa32b6492c4a2969bc6314b (diff) |
[PDF] Use insert and append helpers for POD data.
BUG=251
Review URL: http://codereview.appspot.com/4815044
git-svn-id: http://skia.googlecode.com/svn/trunk@1912 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/pdf/SkPDFFormXObject.cpp | 6 | ||||
-rw-r--r-- | src/pdf/SkPDFImage.cpp | 20 | ||||
-rw-r--r-- | src/pdf/SkPDFTypes.cpp | 2 |
3 files changed, 14 insertions, 14 deletions
diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp index a8a3290e22..0a75d2a25e 100644 --- a/src/pdf/SkPDFFormXObject.cpp +++ b/src/pdf/SkPDFFormXObject.cpp @@ -33,8 +33,8 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { content->unref(); // SkRefPtr and content() both took a reference. setData(content.get()); - insert("Type", new SkPDFName("XObject"))->unref(); - insert("Subtype", new SkPDFName("Form"))->unref(); + insertName("Type", "XObject"); + insertName("Subtype", "Form"); insert("BBox", device->getMediaBox().get()); insert("Resources", device->getResourceDict().get()); @@ -52,7 +52,7 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { // isolated blending. Do this conditionally if that changes. SkRefPtr<SkPDFDict> group = new SkPDFDict("Group"); group->unref(); // SkRefPtr and new both took a reference. - group->insert("S", new SkPDFName("Transparency"))->unref(); + group->insertName("S", "Transparency"); group->insert("I", new SkPDFBool(true))->unref(); // Isolated. insert("Group", group.get()); } diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp index ebbcd11a97..159cbc49b2 100644 --- a/src/pdf/SkPDFImage.cpp +++ b/src/pdf/SkPDFImage.cpp @@ -222,9 +222,9 @@ void extractImageData(const SkBitmap& bitmap, const SkIRect& srcRect, SkPDFArray* makeIndexedColorSpace(SkColorTable* table) { SkPDFArray* result = new SkPDFArray(); result->reserve(4); - result->append(new SkPDFName("Indexed"))->unref(); - result->append(new SkPDFName("DeviceRGB"))->unref();; - result->append(new SkPDFInt(table->count() - 1))->unref(); + result->appendName("Indexed"); + result->appendName("DeviceRGB"); + result->appendInt(table->count() - 1); // Potentially, this could be represented in fewer bytes with a stream. // Max size as a string is 1.5k. @@ -293,8 +293,8 @@ SkPDFImage::SkPDFImage(SkStream* imageData, const SkBitmap& bitmap, bool alphaOnly = (config == SkBitmap::kA1_Config || config == SkBitmap::kA8_Config); - insert("Type", new SkPDFName("XObject"))->unref(); - insert("Subtype", new SkPDFName("Image"))->unref(); + insertName("Type", "XObject"); + insertName("Subtype", "Image"); if (!doingAlpha && alphaOnly) { // For alpha only images, we stretch a single pixel of black for @@ -304,19 +304,19 @@ SkPDFImage::SkPDFImage(SkStream* imageData, const SkBitmap& bitmap, insert("Width", one.get()); insert("Height", one.get()); } else { - insert("Width", new SkPDFInt(srcRect.width()))->unref(); - insert("Height", new SkPDFInt(srcRect.height()))->unref(); + insertInt("Width", srcRect.width()); + insertInt("Height", srcRect.height()); } // if (!image mask) { if (doingAlpha || alphaOnly) { - insert("ColorSpace", new SkPDFName("DeviceGray"))->unref(); + insertName("ColorSpace", "DeviceGray"); } else if (config == SkBitmap::kIndex8_Config || config == SkBitmap::kRLE_Index8_Config) { insert("ColorSpace", makeIndexedColorSpace(bitmap.getColorTable()))->unref(); } else { - insert("ColorSpace", new SkPDFName("DeviceRGB"))->unref(); + insertName("ColorSpace", "DeviceRGB"); } // } @@ -325,7 +325,7 @@ SkPDFImage::SkPDFImage(SkStream* imageData, const SkBitmap& bitmap, bitsPerComp = 4; else if (doingAlpha && config == SkBitmap::kA1_Config) bitsPerComp = 1; - insert("BitsPerComponent", new SkPDFInt(bitsPerComp))->unref(); + insertInt("BitsPerComponent", bitsPerComp); if (config == SkBitmap::kRGB_565_Config) { SkRefPtr<SkPDFInt> zeroVal = new SkPDFInt(0); diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp index a026d6927b..eb0e20429c 100644 --- a/src/pdf/SkPDFTypes.cpp +++ b/src/pdf/SkPDFTypes.cpp @@ -379,7 +379,7 @@ void SkPDFArray::appendName(const char name[]) { SkPDFDict::SkPDFDict() {} SkPDFDict::SkPDFDict(const char type[]) { - insert("Type", new SkPDFName(type))->unref(); + insertName("Type", type); } SkPDFDict::~SkPDFDict() { |