1cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com/* 2cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * Copyright 2013 Google Inc. 3cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * 4cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * Use of this source code is governed by a BSD-style license that can be 5cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * found in the LICENSE file. 6cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com */ 7cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com 83aa355527a3b91d3e12b8bee49e5637d00a736caedisonn@google.com#include "SkPdfGraphicsState.h" 92ccc3afa474f9485c39c2e863252ddaa3f35724bedisonn@google.com 10a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com#include "SkDashPathEffect.h" 11a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com 12a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.comvoid SkPdfGraphicsState::applyGraphicsState(SkPaint* paint, bool stroking) { 13a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com if (stroking) { 14a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com fStroking.applyGraphicsState(paint); 15a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com } else { 16a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com fNonStroking.applyGraphicsState(paint); 17a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com } 18a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com 19e50d9a1fcd9c4298079ff54f9a40c9708d30f8c6edisonn@google.com // TODO(edisonn): Perf, we should load this option from pdfContext->options, 20a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com // or pdfContext->addPaintOptions(&paint); 21a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com paint->setAntiAlias(true); 22a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com 23a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com // TODO(edisonn): miter, ... 24a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com if (stroking) { 25a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com paint->setStrokeWidth(SkDoubleToScalar(fLineWidth)); 26d03c2c732e2e914f8429cfc8b077a7b9b853dd8eedisonn@google.com // TODO(edisonn): perf, avoid allocs of the intervals 27f111a4b6855277bba8dac84cce7ccfa1b3f25d7cedisonn@google.com if (fDashArrayLength > 0) { 280a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org paint->setPathEffect(SkDashPathEffect::Create(fDashArray, 290a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org fDashArrayLength, 300a2bf90dccba3bde188e0386a7f0c60e6dde1ae9commit-bot@chromium.org fDashPhase))->unref(); 31a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com } 32a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com } 33f111a4b6855277bba8dac84cce7ccfa1b3f25d7cedisonn@google.com 34f111a4b6855277bba8dac84cce7ccfa1b3f25d7cedisonn@google.com // TODO(edisonn): NYI multiple blend modes 35f111a4b6855277bba8dac84cce7ccfa1b3f25d7cedisonn@google.com if (fBlendModesLength == 1 && fBlendModes[0] != SkXfermode::kSrc_Mode) { 36f111a4b6855277bba8dac84cce7ccfa1b3f25d7cedisonn@google.com paint->setXfermodeMode(fBlendModes[0]); 37f111a4b6855277bba8dac84cce7ccfa1b3f25d7cedisonn@google.com } 389a43c18740d3251b4d52703a0247719a0aef6474edisonn@google.com 399a43c18740d3251b4d52703a0247719a0aef6474edisonn@google.com //paint->setStrokeMiter(SkDoubleToScalar(fMiterLimit)); 409a43c18740d3251b4d52703a0247719a0aef6474edisonn@google.com // TODO(edisonn): impl cap and join 41a0cefa18fc25cca4264be04ce30c0c9692487a02edisonn@google.com} 42