29 fSimplified = that.fSimplified;
31 fInheritedKey.
reset(that.fInheritedKey.
count());
33 sizeof(uint32_t) * fInheritedKey.
count());
34 if (that.fInheritedPathForListeners.
isValid()) {
35 fInheritedPathForListeners.
set(*that.fInheritedPathForListeners);
37 fInheritedPathForListeners.
reset();
45 return originalIsInverted;
47 return !originalIsInverted;
65 if (original.fInheritedPathForListeners.
isValid()) {
66 result.fInheritedPathForListeners.set(*original.fInheritedPathForListeners);
69 result.fShape = original.fShape;
70 result.fGenID = original.fGenID;
71 result.fShape.setInverted(newIsInverted);
104 const int verbCnt = path.countVerbs();
108 const int pointCnt = path.countPoints();
111 static_assert(
sizeof(
SkPoint) == 2 *
sizeof(uint32_t));
112 static_assert(
sizeof(
SkScalar) ==
sizeof(uint32_t));
115 return 1 + (
SkAlign4(verbCnt) >> 2) + 2 * pointCnt + conicWeightCnt;
120 uint32_t*
key = origKey;
122 const int verbCnt = path.countVerbs();
123 const int pointCnt = path.countPoints();
129 int verbKeySize =
SkAlign4(verbCnt);
131 uint8_t* pad =
reinterpret_cast<uint8_t*
>(
key)+ verbCnt;
132 memset(pad, 0xDE, verbKeySize - verbCnt);
133 key += verbKeySize >> 2;
136 static_assert(
sizeof(
SkPoint) == 2 *
sizeof(uint32_t));
139 static_assert(
sizeof(
SkScalar) ==
sizeof(uint32_t));
145 if (fInheritedKey.
count()) {
146 return fInheritedKey.
count();
150 switch(fShape.
type()) {
152 static_assert(0 ==
sizeof(
SkPoint) %
sizeof(uint32_t));
156 static_assert(0 ==
sizeof(
SkRect) %
sizeof(uint32_t));
164 static_assert(0 ==
sizeof(
SkArc) %
sizeof(uint32_t));
168 static_assert(0 ==
sizeof(
GrLineSegment) %
sizeof(uint32_t));
176 if (dataKeySize >= 0) {
177 count += dataKeySize;
192 if (fInheritedKey.
count()) {
193 memcpy(
key, fInheritedKey.
get(),
sizeof(uint32_t) * fInheritedKey.
count());
207 switch(fShape.
type()) {
214 if (dataKeySize >= 0) {
227 key +=
sizeof(
SkRect) /
sizeof(uint32_t);
235 memcpy(
key, &fShape.
arc(),
sizeof(
SkRect) + 2 *
sizeof(
float));
236 key += (
sizeof(
SkArc) /
sizeof(uint32_t) - 1);
263 int parentCnt = parent.fInheritedKey.
count();
264 bool useParentGeoKey = !parentCnt;
265 if (useParentGeoKey) {
273 uint32_t styleKeyFlags = 0;
277 if (parent.
asLine(
nullptr,
nullptr)) {
287 fInheritedKey.
reset(parentCnt + styleCnt);
288 if (useParentGeoKey) {
293 memcpy(fInheritedKey.
get(), parent.fInheritedKey.
get(),
294 parentCnt *
sizeof(uint32_t));
302const SkPath* GrStyledShape::originalPathForListeners()
const {
303 if (fInheritedPathForListeners.
isValid()) {
304 return fInheritedPathForListeners.
get();
306 return &fShape.
path();
312 if (
const auto* lp = this->originalPathForListeners()) {
318 SkScalar sweepAngleDegrees,
bool useCenter,
330 : fShape(that.fShape)
332 , fGenID(that.fGenID)
333 , fSimplified(that.fSimplified) {
334 fInheritedKey.
reset(that.fInheritedKey.
count());
336 sizeof(uint32_t) * fInheritedKey.
count());
337 if (that.fInheritedPathForListeners.
isValid()) {
338 fInheritedPathForListeners.
set(*that.fInheritedPathForListeners);
362 const SkPath* srcForPathEffect;
363 if (parent.fShape.
isPath()) {
364 srcForPathEffect = &parent.fShape.
path();
366 srcForPathEffect = tmpPath.
init();
374 tmpParent.
init(*srcForPathEffect,
GrStyle(strokeRec,
nullptr));
394 tmpParent->asPath(tmpPath.
get());
397 if (tmpParent->style().applies()) {
400 }
else if (tmpParent->style().isSimpleFill()) {
403 SkASSERT(tmpParent.
get()->style().isSimpleHairline());
407 parentForKey = tmpParent.
get();
409 fStyle =
GrStyle(strokeRec,
nullptr);
412 const SkPath* srcForParentStyle;
413 if (parent.fShape.
isPath()) {
414 srcForParentStyle = &parent.fShape.
path();
416 srcForParentStyle = tmpPath.
init();
423 *srcForParentStyle,
scale));
427 if (parent.fInheritedPathForListeners.
isValid()) {
428 fInheritedPathForListeners.
set(*parent.fInheritedPathForListeners);
430 fInheritedPathForListeners.
set(parent.fShape.
path());
433 this->setInheritedKey(*parentForKey,
apply,
scale);
437 bool* inverted)
const {
470 static const unsigned kMapping[] = {1, 0, 3, 2};
473 rectStart = kMapping[rectStart];
482 rectStart = 3 - rectStart;
490 *
start = 2 * rectStart;
496 *rrect = fShape.
rrect();
564 for (
int i = 1; i < 4; ++i) {
574 return allEq || allGoE1;
581 : fShape(shape), fInverted(!style.isDashed() && fShape->inverted()) {}
597 unsigned simplifyFlags = 0;
611 fClosed = fShape.
simplify(simplifyFlags);
612 fSimplified = oldType != fShape.
type();
631 fInheritedKey.
reset(0);
635 fInheritedPathForListeners.
reset();
637 this->simplifyStroke();
641void GrStyledShape::simplifyStroke() {
675 bool styleSimplified =
false;
679 bool dropDash =
false;
702 styleSimplified =
true;
715 fStyle =
GrStyle(rec,
nullptr);
716 styleSimplified =
true;
742 fStyle =
GrStyle(rec,
nullptr);
743 styleSimplified =
true;
783 fSimplified |= styleSimplified;
787 if (
rect.isEmpty()) {
SkStrokeRec::Style fStyle
static bool inversion(Vertex *prev, Vertex *next, Edge *origEdge, const Comparator &c)
static bool is_inverted(bool originalIsInverted, GrStyledShape::FillInversion inversion)
static int path_key_from_data_size(const SkPath &path)
static void write_path_key_from_data(const SkPath &path, uint32_t *origKey)
static constexpr T SkAlign4(T x)
#define SkAssertResult(cond)
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
static bool apply(Pass *pass, SkRecord *record)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
static bool is_inverted(const SkRect &r)
static constexpr bool SkToBool(const T &x)
AutoRestoreInverseness(GrShape *shape, const GrStyle &style)
~AutoRestoreInverseness()
uint32_t stateKey() const
void setRRect(const SkRRect &rrect)
void setPath(const SkPath &path)
SkPathDirection dir() const
static constexpr SkPathDirection kDefaultDir
static constexpr SkPathFillType kDefaultFillType
void setInverted(bool inverted)
void setArc(const SkArc &arc)
unsigned startIndex() const
static constexpr unsigned kDefaultStart
void setRect(const SkRect &rect)
bool simplify(unsigned flags=kAll_Flags)
void adjustBounds(SkRect *dst, const SkRect &src) const
const SkScalar * dashIntervals() const
@ kPathEffectAndStrokeRec
bool applyToPath(SkPath *dst, SkStrokeRec::InitStyle *fillOrHairline, const SkPath &src, SkScalar scale) const
SkPathEffect * pathEffect() const
bool hasPathEffect() const
static void WriteKey(uint32_t *, const GrStyle &, Apply, SkScalar scale, uint32_t flags=0)
static const GrStyle & SimpleFill()
bool hasNonDashPathEffect() const
int dashIntervalCnt() const
bool applyPathEffectToPath(SkPath *dst, SkStrokeRec *remainingStoke, const SkPath &src, SkScalar scale) const
bool isSimpleFill() const
void resetToInitStyle(SkStrokeRec::InitStyle fillOrHairline)
static int KeySize(const GrStyle &, Apply, uint32_t flags=0)
const SkStrokeRec & strokeRec() const
bool knownToBeClosed() const
void asPath(SkPath *out) const
void writeUnstyledKey(uint32_t *key) const
int unstyledKeySize() const
bool asLine(SkPoint pts[2], bool *inverted) const
const GrStyle & style() const
static GrStyledShape MakeArc(const SkRect &oval, SkScalar startAngleDegrees, SkScalar sweepAngleDegrees, bool useCenter, const GrStyle &style, DoSimplify=DoSimplify::kYes)
SkRect styledBounds() const
bool asNestedRects(SkRect rects[2]) const
void addGenIDChangeListener(sk_sp< SkIDChangeListener >) const
static constexpr int kMaxKeyFromDataVerbCnt
static GrStyledShape MakeFilled(const GrStyledShape &original, FillInversion=FillInversion::kPreserve)
GrStyledShape & operator=(const GrStyledShape &that)
bool asRRect(SkRRect *rrect, SkPathDirection *dir, unsigned *start, bool *inverted) const
@ kButt_Cap
no stroke extension
@ kDefault_Join
equivalent to kMiter_Join
@ kMiter_Join
extends to miter limit
@ kBevel_Join
connects outside edges
static bool IsNestedFillRects(const SkPath &, SkRect rect[2], SkPathDirection dirs[2]=nullptr)
static const uint8_t * VerbData(const SkPath &path)
static void AddGenIDChangeListener(const SkPath &path, sk_sp< SkIDChangeListener > listener)
static const SkScalar * ConicWeightData(const SkPath &path)
static const SkPoint * PointData(const SkPath &path)
static int ConicWeightCnt(const SkPath &path)
bool isInverseFillType() const
uint32_t getGenerationID() const
SkPathFillType getFillType() const
void setFillType(SkPathFillType ft)
static SkRRect MakeOval(const SkRect &oval)
static SkRRect MakeRect(const SkRect &r)
size_t writeToMemory(void *buffer) const
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
static constexpr size_t kSizeInMemory
void setStrokeStyle(SkScalar width, bool strokeAndFill=false)
bool isHairlineStyle() const
SkScalar getWidth() const
void setStrokeParams(SkPaint::Cap cap, SkPaint::Join join, SkScalar miterLimit)
SkPaint::Join getJoin() const
SkPaint::Cap getCap() const
SkScalar getResScale() const
SkScalar getMiter() const
T * init(Args &&... args)
sk_sp< SkBlender > blender SkRect rect
SkRect makeSorted() const
static constexpr SkRect MakeEmpty()
SkScalar fBottom
larger y-axis bounds
SkScalar fLeft
smaller x-axis bounds
void outset(float dx, float dy)
const float * asScalars() const
SkScalar fRight
larger x-axis bounds
SkScalar fTop
smaller y-axis bounds