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 | 9 |
10 #include "SkDashPathEffect.h" | 10 #include "SkDashPathEffect.h" |
11 | 11 |
12 void SkPdfGraphicsState::applyGraphicsState(SkPaint* paint, bool stroking) { | 12 void SkPdfGraphicsState::applyGraphicsState(SkPaint* paint, bool stroking) { |
13 if (stroking) { | 13 if (stroking) { |
14 fStroking.applyGraphicsState(paint); | 14 fStroking.applyGraphicsState(paint); |
15 } else { | 15 } else { |
16 fNonStroking.applyGraphicsState(paint); | 16 fNonStroking.applyGraphicsState(paint); |
17 } | 17 } |
18 | 18 |
19 // TODO(edisonn): Perf, we should load this option from pdfContext->options, | 19 // TODO(edisonn): Perf, we should load this option from pdfContext->options, |
20 // or pdfContext->addPaintOptions(&paint); | 20 // or pdfContext->addPaintOptions(&paint); |
21 paint->setAntiAlias(true); | 21 paint->setAntiAlias(true); |
22 | 22 |
23 // TODO(edisonn): miter, ... | 23 // TODO(edisonn): miter, ... |
24 if (stroking) { | 24 if (stroking) { |
25 paint->setStrokeWidth(SkDoubleToScalar(fLineWidth)); | 25 paint->setStrokeWidth(SkDoubleToScalar(fLineWidth)); |
26 // TODO(edisonn): perf, avoid allocs of the intervals | 26 // TODO(edisonn): perf, avoid allocs of the intervals |
27 if (fDashArrayLength > 0) { | 27 if (fDashArrayLength > 0) { |
28 paint->setPathEffect(new SkDashPathEffect(fDashArray, | 28 paint->setPathEffect(SkDashPathEffect::Create(fDashArray, |
29 fDashArrayLength, | 29 fDashArrayLength, |
30 fDashPhase))->unref(); | 30 fDashPhase))->unref(); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 // TODO(edisonn): NYI multiple blend modes | 34 // TODO(edisonn): NYI multiple blend modes |
35 if (fBlendModesLength == 1 && fBlendModes[0] != SkXfermode::kSrc_Mode) { | 35 if (fBlendModesLength == 1 && fBlendModes[0] != SkXfermode::kSrc_Mode) { |
36 paint->setXfermodeMode(fBlendModes[0]); | 36 paint->setXfermodeMode(fBlendModes[0]); |
37 } | 37 } |
38 | 38 |
39 //paint->setStrokeMiter(SkDoubleToScalar(fMiterLimit)); | 39 //paint->setStrokeMiter(SkDoubleToScalar(fMiterLimit)); |
40 // TODO(edisonn): impl cap and join | 40 // TODO(edisonn): impl cap and join |
41 } | 41 } |
OLD | NEW |