blob: 11a5d2c4fe75913987499fc0e2d4b21c448a6855 [file] [log] [blame]
edisonn@google.comb857a0c2013-06-25 20:45:40 +00001#ifndef __DEFINED__SkPdfUtils
2#define __DEFINED__SkPdfUtils
3
edisonn@google.com3aa35552013-08-14 18:26:20 +00004#include "SkMatrix.h"
5#include "SkRect.h"
edisonn@google.com33f11b62013-08-14 21:35:27 +00006#include "SkPdfConfig.h"
edisonn@google.com063d7072013-08-16 15:05:08 +00007#include "SkString.h"
edisonn@google.comb857a0c2013-06-25 20:45:40 +00008
edisonn@google.comb857a0c2013-06-25 20:45:40 +00009class SkPdfArray;
edisonn@google.com3aa35552013-08-14 18:26:20 +000010class SkPdfContext;
11class SkCanvas;
12class SkPdfNativeObject;
13
14// TODO(edisonn): temporary code, to report how much of the PDF we actually think we rendered.
15enum 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
26struct 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.comb857a0c2013-06-25 20:45:40 +000045
edisonn@google.com063d7072013-08-16 15:05:08 +000046// TODO(edisonn): hack to make code generation simpler. Alternatively we can update the
47// generate_code.py not to rely on != operator
48bool operator !=(const SkString& first, const char* second);
49
edisonn@google.comb857a0c2013-06-25 20:45:40 +000050SkMatrix SkMatrixFromPdfArray(SkPdfArray* pdfArray);
51
edisonn@google.com3aa35552013-08-14 18:26:20 +000052SkPdfResult 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
59void SkTraceMatrix(const SkMatrix& matrix, const char* sz);
60void SkTraceRect(const SkRect& rect, const char* sz);
61#else
62#define SkTraceMatrix(a,b)
63#define SkTraceRect(a,b)
64#endif
edisonn@google.comb857a0c2013-06-25 20:45:40 +000065
edisonn@google.comb857a0c2013-06-25 20:45:40 +000066#endif // __DEFINED__SkPdfUtils