blob: b18c727a311db609891d4ade0f0b9b8788a78e37 [file] [log] [blame]
edisonn@google.comcf2cfa12013-08-21 16:31:37 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkPdfUtils_DEFINED
9#define SkPdfUtils_DEFINED
edisonn@google.comb857a0c2013-06-25 20:45:40 +000010
edisonn@google.com3aa35552013-08-14 18:26:20 +000011#include "SkMatrix.h"
12#include "SkRect.h"
edisonn@google.com33f11b62013-08-14 21:35:27 +000013#include "SkPdfConfig.h"
edisonn@google.com063d7072013-08-16 15:05:08 +000014#include "SkString.h"
edisonn@google.comb857a0c2013-06-25 20:45:40 +000015
edisonn@google.comb857a0c2013-06-25 20:45:40 +000016class SkPdfArray;
edisonn@google.com3aa35552013-08-14 18:26:20 +000017class SkPdfContext;
18class SkCanvas;
19class SkPdfNativeObject;
20
21// TODO(edisonn): temporary code, to report how much of the PDF we actually think we rendered.
22enum SkPdfResult {
23 kOK_SkPdfResult,
24 kPartial_SkPdfResult,
25 kNYI_SkPdfResult,
26 kIgnoreError_SkPdfResult,
27 kError_SkPdfResult,
28 kUnsupported_SkPdfResult,
29
30 kCount_SkPdfResult
31};
32
33struct NotOwnedString {
34 const unsigned char* fBuffer;
35 size_t fBytes;
36
37 static void init(NotOwnedString* str) {
38 str->fBuffer = NULL;
39 str->fBytes = 0;
40 }
41
42 static void init(NotOwnedString* str, const char* sz) {
43 str->fBuffer = (const unsigned char*)sz;
44 str->fBytes = strlen(sz);
45 }
46
47 bool equals(const char* sz) {
48 return strncmp((const char*)fBuffer, sz, fBytes) == 0 && fBytes == strlen(sz);
49
50 }
51};
edisonn@google.comb857a0c2013-06-25 20:45:40 +000052
edisonn@google.com063d7072013-08-16 15:05:08 +000053// TODO(edisonn): hack to make code generation simpler. Alternatively we can update the
54// generate_code.py not to rely on != operator
55bool operator !=(const SkString& first, const char* second);
56
edisonn@google.comb857a0c2013-06-25 20:45:40 +000057SkMatrix SkMatrixFromPdfArray(SkPdfArray* pdfArray);
58
edisonn@google.com3aa35552013-08-14 18:26:20 +000059SkPdfResult doType3Char(SkPdfContext* pdfContext, SkCanvas* canvas, const SkPdfNativeObject* skobj, SkRect bBox, SkMatrix matrix, double textSize);
60
61////////////////////////////////////////////////////////////////////////////////////////////////////
62//
63// TRACE functions
64//
65#ifdef PDF_TRACE
66void SkTraceMatrix(const SkMatrix& matrix, const char* sz);
67void SkTraceRect(const SkRect& rect, const char* sz);
68#else
69#define SkTraceMatrix(a,b)
70#define SkTraceRect(a,b)
71#endif
edisonn@google.comb857a0c2013-06-25 20:45:40 +000072
edisonn@google.comcf2cfa12013-08-21 16:31:37 +000073#endif // SkPdfUtils_DEFINED