blob: dc320a581c89193b7cc1884d64fc5222c187a6fe [file] [log] [blame]
edisonn@google.com2ccc3af2013-07-23 17:43:18 +00001#include "SkPdfBasics.h"
2#include "SkPdfNativeTokenizer.h"
3
edisonn@google.coma0cefa12013-07-28 18:34:14 +00004#include "SkDashPathEffect.h"
5
edisonn@google.com2ccc3af2013-07-23 17:43:18 +00006PdfContext::PdfContext(SkNativeParsedPDF* doc)
7 : fPdfDoc(doc)
8 , fTmpPageAllocator(new SkPdfAllocator()) {
9}
10
11PdfContext::~PdfContext() {
12 delete fTmpPageAllocator;
13}
edisonn@google.coma0cefa12013-07-28 18:34:14 +000014
15void SkPdfGraphicsState::applyGraphicsState(SkPaint* paint, bool stroking) {
16 if (stroking) {
17 fStroking.applyGraphicsState(paint);
18 } else {
19 fNonStroking.applyGraphicsState(paint);
20 }
21
22 // TODO(edisonn): get this from pdfContext->options,
23 // or pdfContext->addPaintOptions(&paint);
24 paint->setAntiAlias(true);
25
26 // TODO(edisonn): miter, ...
27 if (stroking) {
28 paint->setStrokeWidth(SkDoubleToScalar(fLineWidth));
29 // TODO(edisonn): perf, two sets of allocs, create SkDashPathEffect constr that takes ownership
30 // of the intervals
31 if (fDashArrayLength > 0 && fDashPhase > 0) {
32 paint->setPathEffect(new SkDashPathEffect(fDashArray, fDashArrayLength, fDashPhase))->unref();
33 }
34 }
35}