aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrStyle.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-04-26 06:53:45 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-26 06:53:45 -0700
commit824e58fc6df8fc149d9675f577f7deeaba698b09 (patch)
treef01622bf727f6f7dcff4fcaa95d09c8f083a6eeb /src/gpu/GrStyle.cpp
parent83af0a63b1d91c7cd4306c4bcdfb60f99b5cbb46 (diff)
Add initial implementation of GrShape and GrStyle classes and tests
The initial intent is to use GrShape to simplify the mask blur code paths. However, I also want to use this to explore a more unified drawing code flow for different geometry types. The goal is to have a single representation for geometries+styling that attempts to always keep the geometry in the simplest form (e.g. preferring rrects to paths). It also allows for converting styling information into modified geometry and for computing consistent keys. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1822723003 Committed: https://skia.googlesource.com/skia/+/c885dacfe4625af8b0e2e5c6e8a8ae8dc2d620a8 Review URL: https://codereview.chromium.org/1822723003
Diffstat (limited to 'src/gpu/GrStyle.cpp')
-rw-r--r--src/gpu/GrStyle.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gpu/GrStyle.cpp b/src/gpu/GrStyle.cpp
new file mode 100644
index 0000000000..40a148bb4a
--- /dev/null
+++ b/src/gpu/GrStyle.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrStyle.h"
+
+void GrStyle::initPathEffect(SkPathEffect* pe) {
+ if (!pe) {
+ fDashInfo.fType = SkPathEffect::kNone_DashType;
+ return;
+ }
+ SkPathEffect::DashInfo info;
+ if (SkPathEffect::kDash_DashType == pe->asADash(&info)) {
+ if (fStrokeRec.getStyle() == SkStrokeRec::kFill_Style) {
+ fPathEffect.reset(nullptr);
+ } else {
+ fPathEffect.reset(SkSafeRef(pe));
+ fDashInfo.fType = SkPathEffect::kDash_DashType;
+ fDashInfo.fIntervals.reset(info.fCount);
+ fDashInfo.fPhase = info.fPhase;
+ info.fIntervals = fDashInfo.fIntervals.get();
+ pe->asADash(&info);
+ return;
+ }
+ } else {
+ fPathEffect.reset(SkSafeRef(pe));
+ }
+ fDashInfo.fType = SkPathEffect::kNone_DashType;
+ fDashInfo.fIntervals.reset(0);
+}