OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkPdfGraphicsState.h" | 8 #include "SkPdfGraphicsState.h" |
9 #include "SkPdfNativeTokenizer.h" | |
10 | 9 |
11 #include "SkDashPathEffect.h" | 10 #include "SkDashPathEffect.h" |
| 11 #include "SkPdfNativeTokenizer.h" |
12 | 12 |
13 SkPdfContext::SkPdfContext(SkPdfNativeDoc* doc) | 13 SkPdfContext::SkPdfContext(SkPdfNativeDoc* doc) |
14 : fPdfDoc(doc) | 14 : fPdfDoc(doc) |
15 , fTmpPageAllocator(new SkPdfAllocator()) { | 15 , fTmpPageAllocator(new SkPdfAllocator()) { |
16 } | 16 } |
17 | 17 |
18 SkPdfContext::~SkPdfContext() { | 18 SkPdfContext::~SkPdfContext() { |
19 delete fTmpPageAllocator; | 19 delete fTmpPageAllocator; |
20 } | 20 } |
21 | 21 |
22 void SkPdfGraphicsState::applyGraphicsState(SkPaint* paint, bool stroking) { | 22 void SkPdfGraphicsState::applyGraphicsState(SkPaint* paint, bool stroking) { |
23 if (stroking) { | 23 if (stroking) { |
24 fStroking.applyGraphicsState(paint); | 24 fStroking.applyGraphicsState(paint); |
25 } else { | 25 } else { |
26 fNonStroking.applyGraphicsState(paint); | 26 fNonStroking.applyGraphicsState(paint); |
27 } | 27 } |
28 | 28 |
29 // TODO(edisonn): get this from pdfContext->options, | 29 // TODO(edisonn): Perf, we should load this option from pdfContext->options, |
30 // or pdfContext->addPaintOptions(&paint); | 30 // or pdfContext->addPaintOptions(&paint); |
31 paint->setAntiAlias(true); | 31 paint->setAntiAlias(true); |
32 | 32 |
33 // TODO(edisonn): miter, ... | 33 // TODO(edisonn): miter, ... |
34 if (stroking) { | 34 if (stroking) { |
35 paint->setStrokeWidth(SkDoubleToScalar(fLineWidth)); | 35 paint->setStrokeWidth(SkDoubleToScalar(fLineWidth)); |
36 // TODO(edisonn): perf, two sets of allocs, create SkDashPathEffect cons
tr that takes ownership | 36 // TODO(edisonn): perf, avoid allocs allocs |
37 // of the intervals | 37 // of the intervals |
38 if (fDashArrayLength > 0) { | 38 if (fDashArrayLength > 0) { |
39 paint->setPathEffect(new SkDashPathEffect(fDashArray, fDashArrayLeng
th, fDashPhase))->unref(); | 39 paint->setPathEffect(new SkDashPathEffect(fDashArray, |
| 40 fDashArrayLength, |
| 41 fDashPhase))->unref(); |
40 } | 42 } |
41 } | 43 } |
42 | 44 |
43 // TODO(edisonn): NYI multiple blend modes | 45 // TODO(edisonn): NYI multiple blend modes |
44 if (fBlendModesLength == 1 && fBlendModes[0] != SkXfermode::kSrc_Mode) { | 46 if (fBlendModesLength == 1 && fBlendModes[0] != SkXfermode::kSrc_Mode) { |
45 paint->setXfermodeMode(fBlendModes[0]); | 47 paint->setXfermodeMode(fBlendModes[0]); |
46 } | 48 } |
47 | 49 |
48 //paint->setStrokeMiter(SkDoubleToScalar(fMiterLimit)); | 50 //paint->setStrokeMiter(SkDoubleToScalar(fMiterLimit)); |
49 // TODO(edisonn): impl cap and join | 51 // TODO(edisonn): impl cap and join |
50 } | 52 } |
OLD | NEW |