edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame] | 1 | #ifndef __DEFINED__SkPdfUtils |
| 2 | #define __DEFINED__SkPdfUtils |
| 3 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 4 | #include "SkMatrix.h" |
| 5 | #include "SkRect.h" |
edisonn@google.com | 33f11b6 | 2013-08-14 21:35:27 +0000 | [diff] [blame] | 6 | #include "SkPdfConfig.h" |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 7 | #include "SkString.h" |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame] | 8 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame] | 9 | class SkPdfArray; |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 10 | class SkPdfContext; |
| 11 | class SkCanvas; |
| 12 | class SkPdfNativeObject; |
| 13 | |
| 14 | // TODO(edisonn): temporary code, to report how much of the PDF we actually think we rendered. |
| 15 | enum SkPdfResult { |
| 16 | kOK_SkPdfResult, |
| 17 | kPartial_SkPdfResult, |
| 18 | kNYI_SkPdfResult, |
| 19 | kIgnoreError_SkPdfResult, |
| 20 | kError_SkPdfResult, |
| 21 | kUnsupported_SkPdfResult, |
| 22 | |
| 23 | kCount_SkPdfResult |
| 24 | }; |
| 25 | |
| 26 | struct NotOwnedString { |
| 27 | const unsigned char* fBuffer; |
| 28 | size_t fBytes; |
| 29 | |
| 30 | static void init(NotOwnedString* str) { |
| 31 | str->fBuffer = NULL; |
| 32 | str->fBytes = 0; |
| 33 | } |
| 34 | |
| 35 | static void init(NotOwnedString* str, const char* sz) { |
| 36 | str->fBuffer = (const unsigned char*)sz; |
| 37 | str->fBytes = strlen(sz); |
| 38 | } |
| 39 | |
| 40 | bool equals(const char* sz) { |
| 41 | return strncmp((const char*)fBuffer, sz, fBytes) == 0 && fBytes == strlen(sz); |
| 42 | |
| 43 | } |
| 44 | }; |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame] | 45 | |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 46 | // TODO(edisonn): hack to make code generation simpler. Alternatively we can update the |
| 47 | // generate_code.py not to rely on != operator |
| 48 | bool operator !=(const SkString& first, const char* second); |
| 49 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame] | 50 | SkMatrix SkMatrixFromPdfArray(SkPdfArray* pdfArray); |
| 51 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 52 | SkPdfResult doType3Char(SkPdfContext* pdfContext, SkCanvas* canvas, const SkPdfNativeObject* skobj, SkRect bBox, SkMatrix matrix, double textSize); |
| 53 | |
| 54 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 | // |
| 56 | // TRACE functions |
| 57 | // |
| 58 | #ifdef PDF_TRACE |
| 59 | void SkTraceMatrix(const SkMatrix& matrix, const char* sz); |
| 60 | void SkTraceRect(const SkRect& rect, const char* sz); |
| 61 | #else |
| 62 | #define SkTraceMatrix(a,b) |
| 63 | #define SkTraceRect(a,b) |
| 64 | #endif |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame] | 65 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame] | 66 | #endif // __DEFINED__SkPdfUtils |