edisonn@google.com | cf2cfa1 | 2013-08-21 16:31:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 8 | #include "SkPdfGraphicsState.h" |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 9 | |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 10 | #include "SkDashPathEffect.h" |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 11 | |
| 12 | void SkPdfGraphicsState::applyGraphicsState(SkPaint* paint, bool stroking) { |
| 13 | if (stroking) { |
| 14 | fStroking.applyGraphicsState(paint); |
| 15 | } else { |
| 16 | fNonStroking.applyGraphicsState(paint); |
| 17 | } |
| 18 | |
edisonn@google.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 19 | // TODO(edisonn): Perf, we should load this option from pdfContext->options, |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 20 | // or pdfContext->addPaintOptions(&paint); |
| 21 | paint->setAntiAlias(true); |
| 22 | |
| 23 | // TODO(edisonn): miter, ... |
| 24 | if (stroking) { |
| 25 | paint->setStrokeWidth(SkDoubleToScalar(fLineWidth)); |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 26 | // TODO(edisonn): perf, avoid allocs of the intervals |
edisonn@google.com | f111a4b | 2013-07-31 18:22:36 +0000 | [diff] [blame] | 27 | if (fDashArrayLength > 0) { |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame^] | 28 | paint->setPathEffect(SkDashPathEffect::Create(fDashArray, |
| 29 | fDashArrayLength, |
| 30 | fDashPhase))->unref(); |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 31 | } |
| 32 | } |
edisonn@google.com | f111a4b | 2013-07-31 18:22:36 +0000 | [diff] [blame] | 33 | |
| 34 | // TODO(edisonn): NYI multiple blend modes |
| 35 | if (fBlendModesLength == 1 && fBlendModes[0] != SkXfermode::kSrc_Mode) { |
| 36 | paint->setXfermodeMode(fBlendModes[0]); |
| 37 | } |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 38 | |
| 39 | //paint->setStrokeMiter(SkDoubleToScalar(fMiterLimit)); |
| 40 | // TODO(edisonn): impl cap and join |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 41 | } |