Chromium Code Reviews| Index: src/gpu/GrStrokeInfo.h |
| diff --git a/src/gpu/GrStrokeInfo.h b/src/gpu/GrStrokeInfo.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..03e9a234d773443bc84a2b536c563e9887147464 |
| --- /dev/null |
| +++ b/src/gpu/GrStrokeInfo.h |
| @@ -0,0 +1,69 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef GrStrokeInfo_DEFINED |
| +#define GrStrokeInfo_DEFINED |
| + |
| +#include "SkStrokeRec.h" |
| +#include "SkPathEffect.h" |
| + |
|
robertphillips
2014/06/05 18:28:01
// GrStrokeInfo encapsulates ... ?
egdaniel
2014/06/05 19:07:24
Will add description
|
| +class GrStrokeInfo { |
| +public: |
| + GrStrokeInfo(SkStrokeRec::InitStyle style) : |
|
robertphillips
2014/06/05 18:28:01
We usually don't put default ctors in the initiali
egdaniel
2014/06/05 19:07:24
removed
|
| + fStroke(style), fDashInfo(), fDashType(SkPathEffect::kNone_DashType) {} |
| + |
| + GrStrokeInfo(const GrStrokeInfo& src, bool includeDash = true) : fStroke(src.fStroke) { |
| + if (includeDash) { |
|
robertphillips
2014/06/05 18:28:01
We don't usually put "this->" in this context (acc
|
| + this->fDashInfo = src.fDashInfo; |
| + this->fDashType = src.fDashType; |
| + } else { |
| + this->fDashType = SkPathEffect::kNone_DashType; |
| + } |
| + } |
| + |
| + explicit GrStrokeInfo(const SkPaint& paint) : |
|
robertphillips
2014/06/05 18:28:01
same here (r.e. default ctor).
|
| + fStroke(paint), fDashInfo(), fDashType(SkPathEffect::kNone_DashType) {} |
| + |
| + const SkStrokeRec& getStrokeRec() const { return fStroke; } |
| + |
| + SkStrokeRec* getStrokeRecPtr() { return &fStroke; } |
| + |
| + void setFillStyle() { fStroke.setFillStyle(); } |
| + |
| + // This should be used in the same fashion as asADash is used from a path effect. |
| + // First call it once with no interval pointer, call isDashed to see if the stroke is dashed, |
| + // call dashCount to get num of dash intervals, create an array of that size, |
| + // and then recall setDashInfo with a pointer to the array. Returns true if the path effect |
| + // is a dashed effect and we are stroking, otherwise it retruns false. |
|
robertphillips
2014/06/05 18:28:01
Can 'pe' be const ?
egdaniel
2014/06/05 19:07:24
yes
|
| + bool setDashInfo(SkPathEffect* pe, SkScalar* intervals = NULL) { |
|
robertphillips
2014/06/05 18:28:01
NULL != pe ?
|
| + if (pe && !fStroke.isFillStyle()) { |
|
robertphillips
2014/06/05 18:28:02
NULL !=
|
| + if (intervals) { |
| + fDashInfo.fIntervals = intervals; |
| + } |
| + fDashType = pe->asADash(&fDashInfo); |
| + return true; |
| + } |
| + return false; |
| + } |
| + |
| + bool isDashed() const { |
| + return (!fStroke.isFillStyle() && SkPathEffect::kDash_DashType == fDashType); |
| + } |
| + |
| + int32_t dashCount() const { |
| + return fDashInfo.fCount; |
| + } |
| + |
| + const SkPathEffect::DashInfo& getDashInfo() const { return fDashInfo; } |
| + |
| +private: |
|
robertphillips
2014/06/05 18:28:02
line these guys up?
|
| + SkStrokeRec fStroke; |
| + SkPathEffect::DashInfo fDashInfo; |
| + SkPathEffect::DashType fDashType; |
| +}; |
| + |
| +#endif |