[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
This commit is contained in:
parent
421d6443fb
commit
06f7f4051e
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user