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

Unified Diff: include/core/SkStrokeRec.h

Issue 1465773003: Pack and align SkStrokeRec to 4-byte boundary. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: One more comment Created 5 years, 1 month 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 | « no previous file | src/core/SkStrokeRec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkStrokeRec.h
diff --git a/include/core/SkStrokeRec.h b/include/core/SkStrokeRec.h
index 50810f7324c67904cb47309470ebb0b561633e4d..e92cb7ca883aab61113e25dd50359748272a35a6 100644
--- a/include/core/SkStrokeRec.h
+++ b/include/core/SkStrokeRec.h
@@ -35,8 +35,8 @@ public:
Style getStyle() const;
SkScalar getWidth() const { return fWidth; }
SkScalar getMiter() const { return fMiterLimit; }
- SkPaint::Cap getCap() const { return fCap; }
- SkPaint::Join getJoin() const { return fJoin; }
+ SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; }
+ SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; }
bool isHairlineStyle() const {
return kHairline_Style == this->getStyle();
@@ -115,9 +115,15 @@ private:
SkScalar fResScale;
SkScalar fWidth;
SkScalar fMiterLimit;
- SkPaint::Cap fCap;
- SkPaint::Join fJoin;
- bool fStrokeAndFill;
+ // The following three members are packed together into a single u32.
+ // This is to avoid unnecessary padding and ensure binary equality for
+ // hashing (because the padded areas might contain garbage values).
+ //
+ // fCap and fJoin are larger than needed to avoid having to initialize
+ // any pad values
+ uint32_t fCap : 16; // SkPaint::Cap
+ uint32_t fJoin : 15; // SkPaint::Join
+ uint32_t fStrokeAndFill : 1; // bool
};
#endif
« no previous file with comments | « no previous file | src/core/SkStrokeRec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698