Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef GrStrokeInfo_DEFINED | |
| 9 #define GrStrokeInfo_DEFINED | |
| 10 | |
| 11 #include "SkStrokeRec.h" | |
| 12 #include "SkPathEffect.h" | |
| 13 | |
| 14 /* | |
| 15 * GrStrokeInfo encapsulates the data objects that hold all the pertinent infoma tion | |
| 16 * regarding the stroke. The two objects are SkStrokeRec which holds information on fill style, | |
| 17 * width, miter, cap, and join. The second object is DashInfo. This holds inform ation about the | |
| 18 * dash like intervals, count, and phase. | |
| 19 */ | |
| 20 class GrStrokeInfo { | |
| 21 public: | |
| 22 GrStrokeInfo(SkStrokeRec::InitStyle style) : | |
| 23 fStroke(style), fDashType(SkPathEffect::kNone_DashType) {} | |
| 24 | |
| 25 GrStrokeInfo(const GrStrokeInfo& src, bool includeDash = true) : fStroke(src .fStroke) { | |
| 26 if (includeDash) { | |
| 27 fDashInfo = src.fDashInfo; | |
|
bsalomon
2014/06/05 20:43:32
Don't you have to copy the intervals here?
egdaniel
2014/06/05 21:12:09
Ah yes missed that. Fixed now
| |
| 28 fDashType = src.fDashType; | |
| 29 } else { | |
| 30 fDashType = SkPathEffect::kNone_DashType; | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 explicit GrStrokeInfo(const SkPaint& paint) : | |
| 35 fStroke(paint), fDashType(SkPathEffect::kNone_DashType) {} | |
|
bsalomon
2014/06/05 20:43:32
Do we use this ctor? It seems weird that paint has
egdaniel
2014/06/05 21:12:09
This is the main ctor. It is now set up to call se
| |
| 36 | |
| 37 const SkStrokeRec& getStrokeRec() const { return fStroke; } | |
| 38 | |
| 39 SkStrokeRec* getStrokeRecPtr() { return &fStroke; } | |
| 40 | |
| 41 void setFillStyle() { fStroke.setFillStyle(); } | |
| 42 | |
| 43 /* | |
| 44 * This functions takes in a patheffect and fills in fDashInfo with the vari ous dashing | |
| 45 * information if the path effect is a Dash type. Returns true if the path e ffect is a | |
| 46 * dashed effect and we are stroking, otherwise it retruns false. | |
| 47 */ | |
| 48 bool setDashInfo(const SkPathEffect* pe) { | |
| 49 if (NULL != pe && !fStroke.isFillStyle()) { | |
| 50 fDashInfo.fIntervals = NULL; | |
| 51 fDashType = pe->asADash(&fDashInfo); | |
| 52 if (SkPathEffect::kDash_DashType == fDashType) { | |
| 53 fIntervals.reset(fDashInfo.fCount); | |
| 54 fDashInfo.fIntervals = fIntervals.get(); | |
| 55 pe->asADash(&fDashInfo); | |
| 56 return true; | |
| 57 } | |
| 58 } | |
| 59 return false; | |
| 60 } | |
| 61 | |
| 62 bool isDashed() const { | |
| 63 return (!fStroke.isFillStyle() && SkPathEffect::kDash_DashType == fDashT ype); | |
| 64 } | |
| 65 | |
| 66 int32_t dashCount() const { | |
| 67 return fDashInfo.fCount; | |
| 68 } | |
| 69 | |
| 70 const SkPathEffect::DashInfo& getDashInfo() const { return fDashInfo; } | |
| 71 | |
| 72 private: | |
| 73 SkStrokeRec fStroke; | |
| 74 SkPathEffect::DashType fDashType; | |
| 75 SkPathEffect::DashInfo fDashInfo; | |
| 76 SkAutoSTArray<2, SkScalar> fIntervals; | |
|
bsalomon
2014/06/05 20:43:32
This can use true for the third MEM_COPY template
egdaniel
2014/06/05 21:12:09
Using AutoSTArray not STArray so there is no third
| |
| 77 }; | |
| 78 | |
| 79 #endif | |
| OLD | NEW |