180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2011 Google Inc. 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkPDFUtils_DEFINED 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkPDFUtils_DEFINED 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkPaint.h" 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkPath.h" 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkMatrix; 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPath; 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPDFArray; 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct SkRect; 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkWStream; 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if 0 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define PRINT_NOT_IMPL(str) fprintf(stderr, str) 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define PRINT_NOT_IMPL(str) 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define NOT_IMPLEMENTED(condition, assert) \ 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru do { \ 300a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger if ((bool)(condition)) { \ 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru PRINT_NOT_IMPL("NOT_IMPLEMENTED: " #condition "\n"); \ 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkDEBUGCODE(SkASSERT(!assert);) \ 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } \ 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } while (0) 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPDFUtils { 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 3858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger static SkPDFArray* RectToArray(const SkRect& rect); 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static SkPDFArray* MatrixToArray(const SkMatrix& matrix); 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void AppendTransform(const SkMatrix& matrix, SkWStream* content); 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void MoveTo(SkScalar x, SkScalar y, SkWStream* content); 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void AppendLine(SkScalar x, SkScalar y, SkWStream* content); 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void AppendCubic(SkScalar ctl1X, SkScalar ctl1Y, 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkScalar ctl2X, SkScalar ctl2Y, 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkScalar dstX, SkScalar dstY, SkWStream* content); 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void AppendRectangle(const SkRect& rect, SkWStream* content); 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void EmitPath(const SkPath& path, SkPaint::Style paintStyle, 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkWStream* content); 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void ClosePath(SkWStream* content); 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void PaintPath(SkPaint::Style style, SkPath::FillType fill, 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkWStream* content); 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void StrokePath(SkWStream* content); 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void DrawFormXObject(int objectIndex, SkWStream* content); 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static void ApplyGraphicState(int objectIndex, SkWStream* content); 5658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger static void ApplyPattern(int objectIndex, SkWStream* content); 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 60