blob: b30821dcd926025062ad3a8c08d1df575a6e1330 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000010#ifndef SkPDFUtils_DEFINED
11#define SkPDFUtils_DEFINED
12
vandebo@chromium.org683001c2012-05-09 17:17:51 +000013#include "SkPaint.h"
vandebo@chromium.orgf71b2102011-04-04 19:46:31 +000014#include "SkPath.h"
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000015
16class SkMatrix;
17class SkPath;
18class SkPDFArray;
vandebo@chromium.org8989d312011-05-18 22:10:09 +000019struct SkRect;
djsollen@google.comc73dd5c2012-08-07 15:54:32 +000020class SkWStream;
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000021
vandebo@chromium.orgf71b2102011-04-04 19:46:31 +000022#if 0
23#define PRINT_NOT_IMPL(str) fprintf(stderr, str)
24#else
25#define PRINT_NOT_IMPL(str)
26#endif
27
28#define NOT_IMPLEMENTED(condition, assert) \
29 do { \
mtklein@google.com330313a2013-08-22 15:37:26 +000030 if ((bool)(condition)) { \
vandebo@chromium.orgf71b2102011-04-04 19:46:31 +000031 PRINT_NOT_IMPL("NOT_IMPLEMENTED: " #condition "\n"); \
32 SkDEBUGCODE(SkASSERT(!assert);) \
33 } \
ctguil@chromium.orga5c72342011-08-15 23:55:03 +000034 } while (0)
vandebo@chromium.orgf71b2102011-04-04 19:46:31 +000035
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000036class SkPDFUtils {
37public:
commit-bot@chromium.org93a2e212013-07-23 23:16:03 +000038 static SkPDFArray* RectToArray(const SkRect& rect);
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000039 static SkPDFArray* MatrixToArray(const SkMatrix& matrix);
vandebo@chromium.org75f97e42011-04-11 23:24:18 +000040 static void AppendTransform(const SkMatrix& matrix, SkWStream* content);
vandebo@chromium.orgcae5fba2011-03-28 19:03:50 +000041
42 static void MoveTo(SkScalar x, SkScalar y, SkWStream* content);
43 static void AppendLine(SkScalar x, SkScalar y, SkWStream* content);
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000044 static void AppendCubic(SkScalar ctl1X, SkScalar ctl1Y,
45 SkScalar ctl2X, SkScalar ctl2Y,
vandebo@chromium.orgcae5fba2011-03-28 19:03:50 +000046 SkScalar dstX, SkScalar dstY, SkWStream* content);
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +000047 static void AppendRectangle(const SkRect& rect, SkWStream* content);
vandebo@chromium.org683001c2012-05-09 17:17:51 +000048 static void EmitPath(const SkPath& path, SkPaint::Style paintStyle,
49 SkWStream* content);
vandebo@chromium.orgcae5fba2011-03-28 19:03:50 +000050 static void ClosePath(SkWStream* content);
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000051 static void PaintPath(SkPaint::Style style, SkPath::FillType fill,
vandebo@chromium.orgcae5fba2011-03-28 19:03:50 +000052 SkWStream* content);
53 static void StrokePath(SkWStream* content);
vandebo@chromium.org6112c212011-05-13 03:50:38 +000054 static void DrawFormXObject(int objectIndex, SkWStream* content);
55 static void ApplyGraphicState(int objectIndex, SkWStream* content);
commit-bot@chromium.org93a2e212013-07-23 23:16:03 +000056 static void ApplyPattern(int objectIndex, SkWStream* content);
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000057};
58
59#endif