Add SK_BEGIN_REQUIRE_DENSE / SK_END_REQUIRE_DENSE.

Use in on a few examples of things we hash.

BUG=skia:

Review URL: https://codereview.chromium.org/1468483002
This commit is contained in:
mtklein 2015-11-24 05:35:58 -08:00 committed by Commit bot
parent d14c39eff2
commit b68ce74bd1
4 changed files with 19 additions and 3 deletions

View File

@ -22,6 +22,7 @@ class SkString;
using either reset() - to construct an identity matrix, or one of the set
functions (e.g. setTranslate, setRotate, etc.).
*/
SK_BEGIN_REQUIRE_DENSE
class SK_API SkMatrix {
public:
static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar sx, SkScalar sy) {
@ -826,5 +827,6 @@ private:
friend class SkPerspIter;
};
SK_END_REQUIRE_DENSE
#endif

View File

@ -12,6 +12,7 @@
class SkPath;
SK_BEGIN_REQUIRE_DENSE
class SkStrokeRec {
public:
enum InitStyle {
@ -125,5 +126,6 @@ private:
uint32_t fJoin : 15; // SkPaint::Join
uint32_t fStrokeAndFill : 1; // bool
};
SK_END_REQUIRE_DENSE
#endif

View File

@ -287,6 +287,16 @@ static inline bool SkIsU16(long x) {
template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N];
#define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array)))
// Can be used to bracket data types that must be dense, e.g. hash keys.
#if defined(__clang__) // This should work on GCC too, but GCC diagnostic pop didn't seem to work!
#define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic error \"-Wpadded\"")
#define SK_END_REQUIRE_DENSE _Pragma("GCC diagnostic pop")
#else
#define SK_BEGIN_REQUIRE_DENSE
#define SK_END_REQUIRE_DENSE
#endif
#define SkAlign2(x) (((x) + 1) >> 1 << 1)
#define SkIsAlign2(x) (0 == ((x) & 1))

View File

@ -22,6 +22,7 @@ class SkGlyphCache;
#define kMaxGlyphWidth (1<<13)
SK_BEGIN_REQUIRE_DENSE
class SkGlyph {
enum {
kSubBits = 2,
@ -182,5 +183,6 @@ class SkGlyph {
#endif
uint32_t fID;
};
SK_END_REQUIRE_DENSE
#endif