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

Unified Diff: src/gpu/GrStrokeInfo.h

Issue 1116123003: Improve caching of dashed paths in GrStencilAndCoverPathRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@dashing-nvpr-01
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.cpp ('k') | src/gpu/GrStrokeInfo.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrStrokeInfo.h
diff --git a/src/gpu/GrStrokeInfo.h b/src/gpu/GrStrokeInfo.h
index 5ba3cfe91dbb8fe8672ff61329ce4619d0bbccce..1cc2dfe11bd2abe34ac92363bfa5a98c7f8f7c3d 100644
--- a/src/gpu/GrStrokeInfo.h
+++ b/src/gpu/GrStrokeInfo.h
@@ -11,6 +11,8 @@
#include "SkStrokeRec.h"
#include "SkPathEffect.h"
+class GrUniqueKey;
+
/*
* GrStrokeInfo encapsulates all the pertinent infomation regarding the stroke. The SkStrokeRec
* which holds information on fill style, width, miter, cap, and join. It also holds information
@@ -60,6 +62,21 @@ public:
return *this;
}
+ bool hasEqualEffect(const GrStrokeInfo& other) const {
+ if (this->isDashed() != other.isDashed()) {
+ return false;
+ }
+ if (this->isDashed()) {
+ if (fDashPhase != other.fDashPhase ||
+ fIntervals.count() != other.fIntervals.count() ||
+ memcmp(fIntervals.get(), other.fIntervals.get(),
+ fIntervals.count() * sizeof(SkScalar)) != 0) {
+ return false;
+ }
+ }
+ return this->INHERITED::hasEqualEffect(other);
+ }
+
/*
* This functions takes in a patheffect and updates the dashing information if the path effect
* is a Dash type. Returns true if the path effect is a dashed effect and we are stroking,
@@ -127,8 +144,31 @@ public:
*/
bool applyDashToPath(SkPath* dst, GrStrokeInfo* dstStrokeInfo, const SkPath& src) const;
+ /**
+ * Computes the length of the data that will be written by asUniqueKeyFragment() function.
+ */
+ int computeUniqueKeyFragmentData32Cnt() const {
+ const int kSkScalarData32Cnt = sizeof(SkScalar) / sizeof(uint32_t);
+ // SkStrokeRec data: 32 bits for style+join+cap and 2 scalars for miter and width.
+ int strokeKeyData32Cnt = 1 + 2 * kSkScalarData32Cnt;
+
+ if (this->isDashed()) {
+ // One scalar for dash phase and one for each dash value.
+ strokeKeyData32Cnt += (1 + this->getDashCount()) * kSkScalarData32Cnt;
+ }
+ return strokeKeyData32Cnt;
+ }
+
+ /**
+ * Writes the object contents as uint32_t data, to be used with GrUniqueKey.
+ * Note: the data written does not encode the length, so care must be taken to ensure
+ * that the full unique key data is encoded properly. For example, GrStrokeInfo
+ * fragment can be placed last in the sequence, at fixed index.
+ */
+ void asUniqueKeyFragment(uint32_t*) const;
+
private:
- // Prevent accidental usage, not implemented for GrStrokeInfos.
+ // Prevent accidental usage, should use GrStrokeInfo::hasEqualEffect.
bool hasEqualEffect(const SkStrokeRec& other) const;
void init(const SkPaint& paint) {
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.cpp ('k') | src/gpu/GrStrokeInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698