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