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

Unified Diff: src/gpu/GrPath.cpp

Issue 1473973003: Obtain conic weights for GrPath cache keys from SkPathRef Base URL: https://skia.googlesource.com/skia.git@path-cache-fix-conic-weights
Patch Set: remove runtime consistency checks of internal values Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPath.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrPath.cpp
diff --git a/src/gpu/GrPath.cpp b/src/gpu/GrPath.cpp
index 71c13af30656e21ed3181549b08a43c7987dd2e3..aa406aaa605d5b77e9c33b91d658c64d9f746801 100644
--- a/src/gpu/GrPath.cpp
+++ b/src/gpu/GrPath.cpp
@@ -58,13 +58,14 @@ inline static bool compute_key_for_oval_path(const SkPath& path, const GrStrokeI
// Encodes the full path data to the unique key for very small, volatile paths. This is typically
// hit when clipping stencils the clip stack. Intention is that this handles rects too, since
// SkPath::isRect seems to do non-trivial amount of work.
-inline static bool compute_key_for_simple_path(const SkPath& path, const GrStrokeInfo& stroke,
- GrUniqueKey* key) {
+inline static bool compute_key_for_simple_path(const SkPath& path, const SkPathRef* pathRef,
+ const GrStrokeInfo& stroke, GrUniqueKey* key) {
if (!path.isVolatile()) {
return false;
}
- // The check below should take care of negative values casted positive.
+
const int verbCnt = path.countVerbs();
+ SkASSERT(verbCnt >= 0);
if (verbCnt > kSimpleVolatilePathVerbLimit) {
return false;
}
@@ -74,23 +75,10 @@ inline static bool compute_key_for_simple_path(const SkPath& path, const GrStrok
"big_simple_volatile_path_verb_limit_may_cause_overflow");
const int pointCnt = path.countPoints();
- if (pointCnt < 0) {
- SkASSERT(false);
- return false;
- }
- SkSTArray<16, SkScalar, true> conicWeights(16);
- if ((path.getSegmentMasks() & SkPath::kConic_SegmentMask) != 0) {
- SkPath::RawIter iter(path);
- SkPath::Verb verb;
- SkPoint points[4];
- while ((verb = iter.next(points)) != SkPath::kDone_Verb) {
- if (verb == SkPath::kConic_Verb) {
- conicWeights.push_back(iter.conicWeight());
- }
- }
- }
+ SkASSERT(pointCnt >= 0);
- const int conicWeightCnt = conicWeights.count();
+ const int conicWeightCnt = pathRef ? pathRef->countWeights() : 0;
+ SkASSERT(conicWeightCnt >= 0);
// Construct counts that align as uint32_t counts.
#define ARRAY_DATA32_COUNT(array_type, count) \
@@ -126,7 +114,7 @@ inline static bool compute_key_for_simple_path(const SkPath& path, const GrStrok
// Unambiguous fragment 1 establishes unambiguous fragment 2, since the length of the message
// has been established.
- builder[i++] = SkToU32(verbCnt); // The path limit is compile-asserted above, so the cast is ok.
+ builder[i++] = SkToU32(verbCnt); // The verb limit is asserted above, so the cast is ok.
// Fill the last uint32_t with 0 first, since the last uint8_ts of the uint32_t may be
// uninitialized. This does not produce ambiguous verb data, since we have serialized the exact
@@ -149,7 +137,7 @@ inline static bool compute_key_for_simple_path(const SkPath& path, const GrStrok
(conicWeightCnt * sizeof(SkScalar) / sizeof(uint32_t)))) {
builder[i + conicWeightData32Cnt - 1] = 0;
}
- memcpy(&builder[i], conicWeights.begin(), conicWeightCnt * sizeof(SkScalar));
+ memcpy(&builder[i], pathRef->conicWeights(), conicWeightCnt * sizeof(SkScalar));
SkDEBUGCODE(i += conicWeightData32Cnt);
}
SkASSERT(i == baseData32Cnt);
@@ -186,7 +174,7 @@ void GrPath::ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUnique
return;
}
- if (compute_key_for_simple_path(path, stroke, key)) {
+ if (compute_key_for_simple_path(path, path.fPathRef, stroke, key)) {
*outIsVolatile = false;
return;
}
« no previous file with comments | « include/core/SkPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698