OLD | NEW |
1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
3 | 3 |
4 #include <stdint.h> | 4 #include <stdint.h> |
5 #include <string.h> | 5 #include <string.h> |
6 #include <string> | 6 #include "SkString.h" |
7 #include "SkTDArray.h" | 7 #include "SkTDArray.h" |
8 #include "SkTDict.h" | 8 #include "SkTDict.h" |
9 #include "SkRect.h" | 9 #include "SkRect.h" |
10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
11 #include "SkString.h" | 11 #include "SkString.h" |
12 | 12 |
13 #include "SkPdfNYI.h" | 13 #include "SkPdfNYI.h" |
14 #include "SkPdfConfig.h" | 14 #include "SkPdfConfig.h" |
15 #include "SkPdfUtils.h" | 15 #include "SkPdfUtils.h" |
16 | 16 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 kUndefined_PdfObjectType, // per 1.4 spec, if the same key appear twic
e in the dictionary, the value is undefined | 52 kUndefined_PdfObjectType, // per 1.4 spec, if the same key appear twic
e in the dictionary, the value is undefined |
53 }; | 53 }; |
54 | 54 |
55 enum DataType { | 55 enum DataType { |
56 kEmpty_Data, | 56 kEmpty_Data, |
57 kFont_Data, | 57 kFont_Data, |
58 kBitmap_Data, | 58 kBitmap_Data, |
59 }; | 59 }; |
60 | 60 |
61 private: | 61 private: |
| 62 // TODO(edisonn): assert reset operations while in rendering! |
| 63 uint32_t fInRendering : 1; |
| 64 uint32_t fUnused : 31; |
| 65 |
| 66 |
62 struct Reference { | 67 struct Reference { |
63 unsigned int fId; | 68 unsigned int fId; |
64 unsigned int fGen; | 69 unsigned int fGen; |
65 }; | 70 }; |
66 | 71 |
67 // TODO(edisonn): add stream start, stream end, where stream is weither the
file | 72 // TODO(edisonn): add stream start, stream end, where stream is weither the
file |
68 // or decoded/filtered pdf stream | 73 // or decoded/filtered pdf stream |
69 | 74 |
70 // TODO(edisonn): add warning/report per object | 75 // TODO(edisonn): add warning/report per object |
71 // TODO(edisonn): add flag fUsed, to be used once the parsing is complete, | 76 // TODO(edisonn): add flag fUsed, to be used once the parsing is complete, |
(...skipping 14 matching lines...) Expand all Loading... |
86 }; | 91 }; |
87 SkTDict<SkPdfNativeObject*>* fMap; | 92 SkTDict<SkPdfNativeObject*>* fMap; |
88 | 93 |
89 // TODO(edisonn): rename data with cache | 94 // TODO(edisonn): rename data with cache |
90 void* fData; | 95 void* fData; |
91 DataType fDataType; | 96 DataType fDataType; |
92 | 97 |
93 | 98 |
94 public: | 99 public: |
95 | 100 |
96 SkPdfNativeObject() : fObjectType(kInvalid_PdfObjectType), fMap(NULL), fData
(NULL), fDataType(kEmpty_Data) {} | 101 SkPdfNativeObject() : fInRendering(0), fObjectType(kInvalid_PdfObjectType),
fMap(NULL), fData(NULL), fDataType(kEmpty_Data) {} |
97 | 102 |
| 103 bool inRendering() const { return fInRendering != 0; } |
| 104 void startRendering() {fInRendering = 1;} |
| 105 void doneRendering() {fInRendering = 0;} |
98 | 106 |
99 inline bool hasData(DataType type) { | 107 inline bool hasData(DataType type) { |
100 return type == fDataType; | 108 return type == fDataType; |
101 } | 109 } |
102 | 110 |
103 inline void* data(DataType type) { | 111 inline void* data(DataType type) { |
104 return type == fDataType ? fData : NULL; | 112 return type == fDataType ? fData : NULL; |
105 } | 113 } |
106 | 114 |
107 inline void setData(void* data, DataType type) { | 115 inline void setData(void* data, DataType type) { |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 | 723 |
716 default: | 724 default: |
717 // TODO(edisonn): report/warning | 725 // TODO(edisonn): report/warning |
718 return NotOwnedString(); | 726 return NotOwnedString(); |
719 } | 727 } |
720 } | 728 } |
721 | 729 |
722 // TODO(edisonn): nameValue2 and stringValue2 are used to make code generati
on easy, | 730 // TODO(edisonn): nameValue2 and stringValue2 are used to make code generati
on easy, |
723 // but it is not a performat way to do it, since it will create an extra cop
y | 731 // but it is not a performat way to do it, since it will create an extra cop
y |
724 // remove these functions and make code generated faster | 732 // remove these functions and make code generated faster |
725 inline std::string nameValue2() const { | 733 inline SkString nameValue2() const { |
726 SkASSERT(fObjectType == kName_PdfObjectType); | 734 SkASSERT(fObjectType == kName_PdfObjectType); |
727 | 735 |
728 if (fObjectType != kName_PdfObjectType) { | 736 if (fObjectType != kName_PdfObjectType) { |
729 // TODO(edisonn): log err | 737 // TODO(edisonn): log err |
730 return ""; | 738 return SkString(); |
731 } | 739 } |
732 return std::string((const char*)fStr.fBuffer, fStr.fBytes); | 740 return SkString((const char*)fStr.fBuffer, fStr.fBytes); |
733 } | 741 } |
734 | 742 |
735 inline std::string stringValue2() const { | 743 inline SkString stringValue2() const { |
736 SkASSERT(fObjectType == kString_PdfObjectType || fObjectType == kHexStri
ng_PdfObjectType); | 744 SkASSERT(fObjectType == kString_PdfObjectType || fObjectType == kHexStri
ng_PdfObjectType); |
737 | 745 |
738 if (fObjectType != kString_PdfObjectType && fObjectType != kHexString_Pd
fObjectType) { | 746 if (fObjectType != kString_PdfObjectType && fObjectType != kHexString_Pd
fObjectType) { |
739 // TODO(edisonn): log err | 747 // TODO(edisonn): log err |
740 return ""; | 748 return SkString(); |
741 } | 749 } |
742 return std::string((const char*)fStr.fBuffer, fStr.fBytes); | 750 return SkString((const char*)fStr.fBuffer, fStr.fBytes); |
743 } | 751 } |
744 | 752 |
745 inline bool boolValue() const { | 753 inline bool boolValue() const { |
746 SkASSERT(fObjectType == kBoolean_PdfObjectType); | 754 SkASSERT(fObjectType == kBoolean_PdfObjectType); |
747 | 755 |
748 if (fObjectType != kBoolean_PdfObjectType) { | 756 if (fObjectType != kBoolean_PdfObjectType) { |
749 // TODO(edisonn): log err | 757 // TODO(edisonn): log err |
750 return false; | 758 return false; |
751 } | 759 } |
752 return fBooleanValue; | 760 return fBooleanValue; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 SkPdfName() : SkPdfNativeObject() { | 1031 SkPdfName() : SkPdfNativeObject() { |
1024 SkPdfNativeObject::makeName((const unsigned char*)"", this); | 1032 SkPdfNativeObject::makeName((const unsigned char*)"", this); |
1025 } | 1033 } |
1026 public: | 1034 public: |
1027 SkPdfName(char* name) : SkPdfNativeObject() { | 1035 SkPdfName(char* name) : SkPdfNativeObject() { |
1028 this->makeName((const unsigned char*)name, this); | 1036 this->makeName((const unsigned char*)name, this); |
1029 } | 1037 } |
1030 }; | 1038 }; |
1031 | 1039 |
1032 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 1040 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
OLD | NEW |