blob: 62a5120ae7dae6f5ed1ee8838b929c8c71ca87b6 [file] [log] [blame]
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +00001/*
2 * Copyright (C) 2011 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkPDFUtils_DEFINED
18#define SkPDFUtils_DEFINED
19
vandebo@chromium.orgf71b2102011-04-04 19:46:31 +000020#include "SkPath.h"
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000021
22class SkMatrix;
23class SkPath;
24class SkPDFArray;
25
vandebo@chromium.orgf71b2102011-04-04 19:46:31 +000026#if 0
27#define PRINT_NOT_IMPL(str) fprintf(stderr, str)
28#else
29#define PRINT_NOT_IMPL(str)
30#endif
31
32#define NOT_IMPLEMENTED(condition, assert) \
33 do { \
34 if (condition) { \
35 PRINT_NOT_IMPL("NOT_IMPLEMENTED: " #condition "\n"); \
36 SkDEBUGCODE(SkASSERT(!assert);) \
37 } \
38 } while(0)
39
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000040class SkPDFUtils {
41public:
42 static SkPDFArray* MatrixToArray(const SkMatrix& matrix);
vandebo@chromium.org75f97e42011-04-11 23:24:18 +000043 static void AppendTransform(const SkMatrix& matrix, SkWStream* content);
vandebo@chromium.orgcae5fba2011-03-28 19:03:50 +000044
45 static void MoveTo(SkScalar x, SkScalar y, SkWStream* content);
46 static void AppendLine(SkScalar x, SkScalar y, SkWStream* content);
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000047 static void AppendCubic(SkScalar ctl1X, SkScalar ctl1Y,
48 SkScalar ctl2X, SkScalar ctl2Y,
vandebo@chromium.orgcae5fba2011-03-28 19:03:50 +000049 SkScalar dstX, SkScalar dstY, SkWStream* content);
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000050 static void AppendRectangle(SkScalar x, SkScalar y, SkScalar w, SkScalar h,
vandebo@chromium.orgcae5fba2011-03-28 19:03:50 +000051 SkWStream* content);
52 static void EmitPath(const SkPath& path, SkWStream* content);
53 static void ClosePath(SkWStream* content);
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000054 static void PaintPath(SkPaint::Style style, SkPath::FillType fill,
vandebo@chromium.orgcae5fba2011-03-28 19:03:50 +000055 SkWStream* content);
56 static void StrokePath(SkWStream* content);
ctguil@chromium.orgf966fd32011-03-04 21:47:04 +000057};
58
59#endif