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

Unified Diff: experimental/PdfViewer/pdfparser/native/SkPdfObject.h

Issue 21738005: pdfviewer: add indexed rbg image support, enhanche caching(setData) for SkPdfObject (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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
Index: experimental/PdfViewer/pdfparser/native/SkPdfObject.h
===================================================================
--- experimental/PdfViewer/pdfparser/native/SkPdfObject.h (revision 10523)
+++ experimental/PdfViewer/pdfparser/native/SkPdfObject.h (working copy)
@@ -49,6 +49,12 @@
kUndefined_PdfObjectType, // per 1.4 spec, if the same key appear twice in the dictionary, the value is undefined
};
+ enum DataType {
+ kEmpty_Data,
+ kFont_Data,
+ kBitmap_Data,
+ };
+
private:
struct Reference {
unsigned int fId;
@@ -76,21 +82,33 @@
Reference fRef;
};
SkTDict<SkPdfObject*>* fMap;
+
+ // TODO(edisonn): rename data with cache
void* fData;
+ DataType fDataType;
public:
- SkPdfObject() : fObjectType(kInvalid_PdfObjectType), fMap(NULL), fData(NULL) {}
+ SkPdfObject() : fObjectType(kInvalid_PdfObjectType), fMap(NULL), fData(NULL), fDataType(kEmpty_Data) {}
- inline void* data() {
- return fData;
+
+ inline bool hasData(DataType type) {
+ return type == fDataType;
}
- inline void setData(void* data) {
+ inline void* data(DataType type) {
+ return type == fDataType ? fData : NULL;
+ }
+
+ inline void setData(void* data, DataType type) {
+ releaseData();
+ fDataType = type;
fData = data;
}
+ void releaseData();
+
// ~SkPdfObject() {
// //reset(); must be called manually!
// }
@@ -114,6 +132,7 @@
break;
}
fObjectType = kInvalid_PdfObjectType;
+ releaseData();
}
ObjectType type() { return fObjectType; }
@@ -604,6 +623,10 @@
return fObjectType == kString_PdfObjectType || fObjectType == kHexString_PdfObjectType;
}
+ bool isHexString() const {
+ return fObjectType == kHexString_PdfObjectType;
+ }
+
bool isMatrix() const {
return fObjectType == kArray_PdfObjectType && fArray->count() == 6; // NYI + and elems are numbers
}
@@ -867,7 +890,9 @@
case kHexString_PdfObjectType:
str.append("<");
- str.append((const char*)fStr.fBuffer, fStr.fBytes);
+ for (unsigned int i = 0 ; i < fStr.fBytes; i++) {
+ str.appendf("%02x", (unsigned int)fStr.fBuffer[i]);
+ }
str.append(">");
break;
@@ -908,9 +933,9 @@
const unsigned char* stream = NULL;
size_t length = 0;
if (GetFilteredStreamRef(&stream, &length)) {
- str.append("stream");
+ str.append("stream\n");
str.append((const char*)stream, length > 256 ? 256 : length);
- str.append("endstream");
+ str.append("\nendstream");
} else {
str.append("stream STREAM_ERROR endstream");
}

Powered by Google App Engine
This is Rietveld 408576698