aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-05-10 05:57:27 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-10 05:57:27 -0700
commit33595bdf4b64a745f6340338d307e806e96c587f (patch)
treee6a4e7abd27df7aa3fdc764d67ec9e3b4cf86868 /src/gpu/effects
parent82595b6fa4733e1525f357bdcac22db058790550 (diff)
Replace GrStrokeInfo with GrStyle.
A side effect is that arbitrary path effects can no be pushed deeper into the Ganesh flow for paths. They may be applied by path renderers. GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1957363002 Review-Url: https://codereview.chromium.org/1957363002
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp37
-rw-r--r--src/gpu/effects/GrDashingEffect.h6
2 files changed, 19 insertions, 24 deletions
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index f1e8016eb9..8a38ebe573 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -16,7 +16,7 @@
#include "GrDefaultGeoProcFactory.h"
#include "GrInvariantOutput.h"
#include "GrProcessor.h"
-#include "GrStrokeInfo.h"
+#include "GrStyle.h"
#include "SkGr.h"
#include "batches/GrVertexBatch.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -29,7 +29,7 @@
///////////////////////////////////////////////////////////////////////////////
// Returns whether or not the gpu can fast path the dash line effect.
-bool GrDashingEffect::CanDrawDashLine(const SkPoint pts[2], const GrStrokeInfo& strokeInfo,
+bool GrDashingEffect::CanDrawDashLine(const SkPoint pts[2], const GrStyle& style,
const SkMatrix& viewMatrix) {
// Pts must be either horizontal or vertical in src space
if (pts[0].fX != pts[1].fX && pts[0].fY != pts[1].fY) {
@@ -42,16 +42,16 @@ bool GrDashingEffect::CanDrawDashLine(const SkPoint pts[2], const GrStrokeInfo&
return false;
}
- if (!strokeInfo.isDashed() || 2 != strokeInfo.getDashCount()) {
+ if (!style.isDashed() || 2 != style.dashIntervalCnt()) {
return false;
}
- const SkScalar* intervals = strokeInfo.getDashIntervals();
+ const SkScalar* intervals = style.dashIntervals();
if (0 == intervals[0] && 0 == intervals[1]) {
return false;
}
- SkPaint::Cap cap = strokeInfo.getCap();
+ SkPaint::Cap cap = style.strokeRec().getCap();
// Current we do don't handle Round or Square cap dashes
if (SkPaint::kRound_Cap == cap && intervals[0] != 0.f) {
return false;
@@ -690,14 +690,15 @@ private:
};
static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const SkPoint pts[2],
- bool useAA, const GrStrokeInfo& strokeInfo, bool msaaRT) {
- const SkScalar* intervals = strokeInfo.getDashIntervals();
- SkScalar phase = strokeInfo.getDashPhase();
+ bool useAA, const GrStyle& style, bool msaaRT) {
+ SkASSERT(GrDashingEffect::CanDrawDashLine(pts, style, viewMatrix));
+ const SkScalar* intervals = style.dashIntervals();
+ SkScalar phase = style.dashPhase();
- SkPaint::Cap cap = strokeInfo.getCap();
+ SkPaint::Cap cap = style.strokeRec().getCap();
DashBatch::Geometry geometry;
- geometry.fSrcStrokeWidth = strokeInfo.getWidth();
+ geometry.fSrcStrokeWidth = style.strokeRec().getWidth();
// the phase should be normalized to be [0, sum of all intervals)
SkASSERT(phase >= 0 && phase < intervals[0] + intervals[1]);
@@ -747,8 +748,8 @@ GrDrawBatch* GrDashingEffect::CreateDashLineBatch(GrColor color,
const SkPoint pts[2],
bool useAA,
bool msaaIsEnabled,
- const GrStrokeInfo& strokeInfo) {
- return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaIsEnabled);
+ const GrStyle& style) {
+ return create_batch(color, viewMatrix, pts, useAA, style, msaaIsEnabled);
}
//////////////////////////////////////////////////////////////////////////////
@@ -1289,17 +1290,11 @@ DRAW_BATCH_TEST_DEFINE(DashBatch) {
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SkIntToScalar(1));
p.setStrokeCap(cap);
+ p.setPathEffect(GrTest::TestDashPathEffect::Make(intervals, 2, phase));
- GrStrokeInfo strokeInfo(p);
+ GrStyle style(p);
- SkPathEffect::DashInfo info;
- info.fIntervals = intervals;
- info.fCount = 2;
- info.fPhase = phase;
- SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
- SkASSERT(success);
-
- return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
+ return create_batch(color, viewMatrix, pts, useAA, style, msaaRT);
}
#endif
diff --git a/src/gpu/effects/GrDashingEffect.h b/src/gpu/effects/GrDashingEffect.h
index d67a63eb4b..8899820114 100644
--- a/src/gpu/effects/GrDashingEffect.h
+++ b/src/gpu/effects/GrDashingEffect.h
@@ -14,7 +14,7 @@
class GrClip;
class GrDrawBatch;
-class GrStrokeInfo;
+class GrStyle;
namespace GrDashingEffect {
GrDrawBatch* CreateDashLineBatch(GrColor,
@@ -22,8 +22,8 @@ namespace GrDashingEffect {
const SkPoint pts[2],
bool useAA,
bool msaaIsEnabled,
- const GrStrokeInfo& strokeInfo);
- bool CanDrawDashLine(const SkPoint pts[2], const GrStrokeInfo& strokeInfo,
+ const GrStyle& style);
+ bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style,
const SkMatrix& viewMatrix);
}