2013-08-21 16:31:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2013-08-14 18:26:20 +00:00
|
|
|
#include "SkPdfGraphicsState.h"
|
2013-07-23 17:43:18 +00:00
|
|
|
|
2013-07-28 18:34:14 +00:00
|
|
|
#include "SkDashPathEffect.h"
|
|
|
|
|
|
|
|
void SkPdfGraphicsState::applyGraphicsState(SkPaint* paint, bool stroking) {
|
|
|
|
if (stroking) {
|
|
|
|
fStroking.applyGraphicsState(paint);
|
|
|
|
} else {
|
|
|
|
fNonStroking.applyGraphicsState(paint);
|
|
|
|
}
|
|
|
|
|
2013-10-10 20:58:22 +00:00
|
|
|
// TODO(edisonn): Perf, we should load this option from pdfContext->options,
|
2013-07-28 18:34:14 +00:00
|
|
|
// or pdfContext->addPaintOptions(&paint);
|
|
|
|
paint->setAntiAlias(true);
|
|
|
|
|
|
|
|
// TODO(edisonn): miter, ...
|
|
|
|
if (stroking) {
|
|
|
|
paint->setStrokeWidth(SkDoubleToScalar(fLineWidth));
|
2013-10-11 18:26:45 +00:00
|
|
|
// TODO(edisonn): perf, avoid allocs of the intervals
|
2013-07-31 18:22:36 +00:00
|
|
|
if (fDashArrayLength > 0) {
|
2014-02-20 20:40:19 +00:00
|
|
|
paint->setPathEffect(SkDashPathEffect::Create(fDashArray,
|
|
|
|
fDashArrayLength,
|
|
|
|
fDashPhase))->unref();
|
2013-07-28 18:34:14 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-31 18:22:36 +00:00
|
|
|
|
|
|
|
// TODO(edisonn): NYI multiple blend modes
|
|
|
|
if (fBlendModesLength == 1 && fBlendModes[0] != SkXfermode::kSrc_Mode) {
|
|
|
|
paint->setXfermodeMode(fBlendModes[0]);
|
|
|
|
}
|
2013-08-01 20:06:42 +00:00
|
|
|
|
|
|
|
//paint->setStrokeMiter(SkDoubleToScalar(fMiterLimit));
|
|
|
|
// TODO(edisonn): impl cap and join
|
2013-07-28 18:34:14 +00:00
|
|
|
}
|