aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/svg
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2015-08-25 12:05:55 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-25 12:05:55 -0700
commitafd7c749724ccceb88761c52c196ba371be5fb1c (patch)
treeda1a738adc327f84a289bb61f5ebdcaa65cf4e27 /include/svg
parent0fe04a240b4346f42199ff657c97126913ba3e74 (diff)
Remove SK_OFFSETOF from SkTypes, clean up offsetof usage.
The motivation for this was to remove SK_OFFSETOF from SkTypes, but this CL is mostly about cleaning up our use of offsetof generally. SK_OFFSETOF is removed to SkTypes and added to the two places it is actually used (for the non standard behavior of finding the offset of fields in types which are not standard layout). Older versions of gcc required POD for offsetof to be used without warning. Newer versions require the more relaxed standard layout. Now that we no longer build on older versions of gcc, remove the old warning suppressions. PODMatrix is renamed to AggregateMatrix. SkMatrix is already POD (trivial and standard layout). The PODMatrix name implies that the POD-ness is needed for the offsetof, but it is actually the aggregate attribute which is needed for compile time constant initialization. This makes it more obvious that this can be revisited after we can rely on constexpr constructors. This also adds skstd::declval since this allows removal of existing awkward code which casts a constant to a pointer to find the size of a field. TBR=reed@google.com No API change, only removes unused macro. Review URL: https://codereview.chromium.org/1309523003
Diffstat (limited to 'include/svg')
-rw-r--r--include/svg/parser/SkSVGAttribute.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/svg/parser/SkSVGAttribute.h b/include/svg/parser/SkSVGAttribute.h
index 940ca5a951..5ba2916b74 100644
--- a/include/svg/parser/SkSVGAttribute.h
+++ b/include/svg/parser/SkSVGAttribute.h
@@ -20,7 +20,8 @@ struct SkSVGAttribute {
};
#ifndef SK_OFFSETOF
-#define SK_OFFSETOF(a, b) (((size_t) (&(((a*) 1)->b)))-1)
+ // This is offsetof for types which are not standard layout.
+ #define SK_OFFSETOF(type, field) (size_t)((char*)&(((type*)1024)->field) - (char*)1024)
#endif
#ifdef SK_DEBUG