Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Side by Side Diff: src/gpu/GrStrokeInfo.h

Issue 311183002: Push dash checks into GrContext. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Changes from reviewers comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
robertphillips 2014/06/05 18:28:01 // GrStrokeInfo encapsulates ... ?
egdaniel 2014/06/05 19:07:24 Will add description
14 class GrStrokeInfo {
15 public:
16 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
17 fStroke(style), fDashInfo(), fDashType(SkPathEffect::kNone_DashType) {}
18
19 GrStrokeInfo(const GrStrokeInfo& src, bool includeDash = true) : fStroke(src .fStroke) {
20 if (includeDash) {
robertphillips 2014/06/05 18:28:01 We don't usually put "this->" in this context (acc
21 this->fDashInfo = src.fDashInfo;
22 this->fDashType = src.fDashType;
23 } else {
24 this->fDashType = SkPathEffect::kNone_DashType;
25 }
26 }
27
28 explicit GrStrokeInfo(const SkPaint& paint) :
robertphillips 2014/06/05 18:28:01 same here (r.e. default ctor).
29 fStroke(paint), fDashInfo(), fDashType(SkPathEffect::kNone_DashType) {}
30
31 const SkStrokeRec& getStrokeRec() const { return fStroke; }
32
33 SkStrokeRec* getStrokeRecPtr() { return &fStroke; }
34
35 void setFillStyle() { fStroke.setFillStyle(); }
36
37 // This should be used in the same fashion as asADash is used from a path ef fect.
38 // First call it once with no interval pointer, call isDashed to see if the stroke is dashed,
39 // call dashCount to get num of dash intervals, create an array of that size ,
40 // and then recall setDashInfo with a pointer to the array. Returns true if the path effect
41 // 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
42 bool setDashInfo(SkPathEffect* pe, SkScalar* intervals = NULL) {
robertphillips 2014/06/05 18:28:01 NULL != pe ?
43 if (pe && !fStroke.isFillStyle()) {
robertphillips 2014/06/05 18:28:02 NULL !=
44 if (intervals) {
45 fDashInfo.fIntervals = intervals;
46 }
47 fDashType = pe->asADash(&fDashInfo);
48 return true;
49 }
50 return false;
51 }
52
53 bool isDashed() const {
54 return (!fStroke.isFillStyle() && SkPathEffect::kDash_DashType == fDashT ype);
55 }
56
57 int32_t dashCount() const {
58 return fDashInfo.fCount;
59 }
60
61 const SkPathEffect::DashInfo& getDashInfo() const { return fDashInfo; }
62
63 private:
robertphillips 2014/06/05 18:28:02 line these guys up?
64 SkStrokeRec fStroke;
65 SkPathEffect::DashInfo fDashInfo;
66 SkPathEffect::DashType fDashType;
67 };
68
69 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698