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

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 1035513003: SkPDF: skpdfdocument and skpdfpage use skpdfdevice in a const way (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 9 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 | « src/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFDocument.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 72e91358761d50cd3c64454bad93c8d960566b12..87555a8111ed622661a20a7dd13d3a08a7897ea7 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -705,7 +705,6 @@ SkPDFDevice::SkPDFDevice(SkISize pageSize,
, fContentSize(pageSize)
, fExistingClipRegion(SkIRect::MakeSize(pageSize))
, fAnnotations(NULL)
- , fResourceDict(NULL)
, fLastContentEntry(NULL)
, fLastMarginContentEntry(NULL)
, fDrawingArea(kContent_DrawingArea)
@@ -735,7 +734,6 @@ SkPDFDevice::~SkPDFDevice() {
void SkPDFDevice::init() {
fAnnotations = NULL;
- fResourceDict = NULL;
fContentEntries.free();
fLastContentEntry = NULL;
fMarginContentEntries.free();
@@ -752,7 +750,6 @@ void SkPDFDevice::cleanUp(bool clearFontUsage) {
fFontResources.unrefAll();
fShaderResources.unrefAll();
SkSafeUnref(fAnnotations);
- SkSafeUnref(fResourceDict);
fNamedDestinations.deleteAll();
if (clearFontUsage) {
@@ -1249,44 +1246,41 @@ void SkPDFDevice::setDrawingArea(DrawingArea drawingArea) {
fDrawingArea = drawingArea;
}
-SkPDFResourceDict* SkPDFDevice::getResourceDict() {
- if (NULL == fResourceDict) {
- fResourceDict = SkNEW(SkPDFResourceDict);
-
- if (fGraphicStateResources.count()) {
- for (int i = 0; i < fGraphicStateResources.count(); i++) {
- fResourceDict->insertResourceAsReference(
- SkPDFResourceDict::kExtGState_ResourceType,
- i, fGraphicStateResources[i]);
- }
+SkPDFResourceDict* SkPDFDevice::createResourceDict() const {
+ SkAutoTUnref<SkPDFResourceDict> resourceDict(SkNEW(SkPDFResourceDict));
+ if (fGraphicStateResources.count()) {
+ for (int i = 0; i < fGraphicStateResources.count(); i++) {
+ resourceDict->insertResourceAsReference(
+ SkPDFResourceDict::kExtGState_ResourceType,
+ i, fGraphicStateResources[i]);
}
+ }
- if (fXObjectResources.count()) {
- for (int i = 0; i < fXObjectResources.count(); i++) {
- fResourceDict->insertResourceAsReference(
- SkPDFResourceDict::kXObject_ResourceType,
- i, fXObjectResources[i]);
- }
+ if (fXObjectResources.count()) {
+ for (int i = 0; i < fXObjectResources.count(); i++) {
+ resourceDict->insertResourceAsReference(
+ SkPDFResourceDict::kXObject_ResourceType,
+ i, fXObjectResources[i]);
}
+ }
- if (fFontResources.count()) {
- for (int i = 0; i < fFontResources.count(); i++) {
- fResourceDict->insertResourceAsReference(
- SkPDFResourceDict::kFont_ResourceType,
- i, fFontResources[i]);
- }
+ if (fFontResources.count()) {
+ for (int i = 0; i < fFontResources.count(); i++) {
+ resourceDict->insertResourceAsReference(
+ SkPDFResourceDict::kFont_ResourceType,
+ i, fFontResources[i]);
}
+ }
- if (fShaderResources.count()) {
- SkAutoTUnref<SkPDFDict> patterns(new SkPDFDict());
- for (int i = 0; i < fShaderResources.count(); i++) {
- fResourceDict->insertResourceAsReference(
- SkPDFResourceDict::kPattern_ResourceType,
- i, fShaderResources[i]);
- }
+ if (fShaderResources.count()) {
+ SkAutoTUnref<SkPDFDict> patterns(new SkPDFDict());
+ for (int i = 0; i < fShaderResources.count(); i++) {
+ resourceDict->insertResourceAsReference(
+ SkPDFResourceDict::kPattern_ResourceType,
+ i, fShaderResources[i]);
}
}
- return fResourceDict;
+ return resourceDict.detach();
}
const SkTDArray<SkPDFFont*>& SkPDFDevice::getFontResources() const {
@@ -1539,7 +1533,7 @@ void SkPDFDevice::defineNamedDestination(SkData* nameData, const SkPoint& point,
SkNEW_ARGS(NamedDestination, (nameData, translatedPoint)));
}
-void SkPDFDevice::appendDestinations(SkPDFDict* dict, SkPDFObject* page) {
+void SkPDFDevice::appendDestinations(SkPDFDict* dict, SkPDFObject* page) const {
int nDest = fNamedDestinations.count();
for (int i = 0; i < nDest; i++) {
NamedDestination* dest = fNamedDestinations[i];
« no previous file with comments | « src/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698