edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 1 | #include "SkPdfBasics.h" |
| 2 | #include "SkPdfNativeTokenizer.h" |
| 3 | |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 4 | #include "SkDashPathEffect.h" |
| 5 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 6 | PdfContext::PdfContext(SkNativeParsedPDF* doc) |
| 7 | : fPdfDoc(doc) |
| 8 | , fTmpPageAllocator(new SkPdfAllocator()) { |
| 9 | } |
| 10 | |
| 11 | PdfContext::~PdfContext() { |
| 12 | delete fTmpPageAllocator; |
| 13 | } |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 14 | |
| 15 | void 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 |
edisonn@google.com | f111a4b | 2013-07-31 18:22:36 +0000 | [diff] [blame] | 31 | if (fDashArrayLength > 0) { |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 32 | paint->setPathEffect(new SkDashPathEffect(fDashArray, fDashArrayLength, fDashPhase))->unref(); |
| 33 | } |
| 34 | } |
edisonn@google.com | f111a4b | 2013-07-31 18:22:36 +0000 | [diff] [blame] | 35 | |
| 36 | // TODO(edisonn): NYI multiple blend modes |
| 37 | if (fBlendModesLength == 1 && fBlendModes[0] != SkXfermode::kSrc_Mode) { |
| 38 | paint->setXfermodeMode(fBlendModes[0]); |
| 39 | } |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 40 | } |