diff options
author | Zach Pfeffer <zach.pfeffer@linaro.org> | 2011-12-20 03:04:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@betelgeuse.canonical.com> | 2011-12-20 03:04:09 +0000 |
commit | 07c37402cacdb8dfcea23a590249efe1ad8ffe7c (patch) | |
tree | 89a7977c578d72aaab8883e96c85910c46b6314d | |
parent | 5a62d68c952f8abcf8642bad2f9c044aeb1e1b8c (diff) | |
parent | a1da54a537a8ffb6ef8a4e215177610a086f6d97 (diff) | |
download | base-linaro_android_4.0.1.tar.gz |
Merge "Revert "Revert "frameworks/base: Fix various aliasing violations""" into linaro_android_4.0.1linaro_android_4.0.1
-rw-r--r-- | core/jni/Android.mk | 1 | ||||
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 9 | ||||
-rw-r--r-- | libs/hwui/ShapeCache.h | 34 | ||||
-rw-r--r-- | libs/hwui/TextDropShadowCache.h | 4 |
4 files changed, 26 insertions, 22 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 59a03e7833c5..aa9c8e23ffb7 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -4,6 +4,7 @@ include $(CLEAR_VARS) LOCAL_CFLAGS += -DHAVE_CONFIG_H -DKHTML_NO_EXCEPTIONS -DGKWQ_NO_JAVA LOCAL_CFLAGS += -DNO_SUPPORT_JS_BINDING -DQT_NO_WHEELEVENT -DKHTML_NO_XBL LOCAL_CFLAGS += -U__APPLE__ +LOCAL_CFLAGS += -fno-strict-aliasing ifeq ($(TARGET_ARCH), arm) LOCAL_CFLAGS += -DPACKED="__attribute__ ((packed))" diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index a077cbc55f34..08d31de2ed5c 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -692,12 +692,15 @@ void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) { } const float skewX = paint->getTextSkewX(); - uint32_t italicStyle = *(uint32_t*) &skewX; + uint32_t italicStyle; + memcpy(&italicStyle, &skewX, sizeof(italicStyle)); const float scaleXFloat = paint->getTextScaleX(); - uint32_t scaleX = *(uint32_t*) &scaleXFloat; + uint32_t scaleX; + memcpy(&scaleX, &scaleXFloat, sizeof(scaleX)); SkPaint::Style style = paint->getStyle(); const float strokeWidthFloat = paint->getStrokeWidth(); - uint32_t strokeWidth = *(uint32_t*) &strokeWidthFloat; + uint32_t strokeWidth; + memcpy(&strokeWidth, &strokeWidthFloat, sizeof(strokeWidth)); mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle, scaleX, style, strokeWidth); diff --git a/libs/hwui/ShapeCache.h b/libs/hwui/ShapeCache.h index 0660b690a1cd..0b37828f8dee 100644 --- a/libs/hwui/ShapeCache.h +++ b/libs/hwui/ShapeCache.h @@ -90,9 +90,9 @@ struct ShapeCacheEntry { cap = SkPaint::kDefault_Cap; style = SkPaint::kFill_Style; float v = 4.0f; - miter = *(uint32_t*) &v; + memcpy(&miter, &v, sizeof(miter)); v = 1.0f; - strokeWidth = *(uint32_t*) &v; + memcpy(&strokeWidth, &v, sizeof(strokeWidth)); pathEffect = NULL; } @@ -101,9 +101,9 @@ struct ShapeCacheEntry { join = paint->getStrokeJoin(); cap = paint->getStrokeCap(); float v = paint->getStrokeMiter(); - miter = *(uint32_t*) &v; + memcpy(&miter, &v, sizeof(miter)); v = paint->getStrokeWidth(); - strokeWidth = *(uint32_t*) &v; + memcpy(&strokeWidth, &v, sizeof(strokeWidth)); style = paint->getStyle(); pathEffect = paint->getPathEffect(); } @@ -148,10 +148,10 @@ protected: struct RoundRectShapeCacheEntry: public ShapeCacheEntry { RoundRectShapeCacheEntry(float width, float height, float rx, float ry, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeRoundRect, paint) { - mWidth = *(uint32_t*) &width; - mHeight = *(uint32_t*) &height; - mRx = *(uint32_t*) ℞ - mRy = *(uint32_t*) &ry; + memcpy(&mWidth, &width, sizeof(mWidth)); + memcpy(&mHeight, &height, sizeof(mHeight)); + memcpy(&mRx, &rx, sizeof(mRx)); + memcpy(&mRy, &ry, sizeof(mRy)); } RoundRectShapeCacheEntry(): ShapeCacheEntry() { @@ -185,7 +185,7 @@ private: struct CircleShapeCacheEntry: public ShapeCacheEntry { CircleShapeCacheEntry(float radius, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeCircle, paint) { - mRadius = *(uint32_t*) &radius; + memcpy(&mRadius, &radius, sizeof(mRadius)); } CircleShapeCacheEntry(): ShapeCacheEntry() { @@ -207,8 +207,8 @@ private: struct OvalShapeCacheEntry: public ShapeCacheEntry { OvalShapeCacheEntry(float width, float height, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeOval, paint) { - mWidth = *(uint32_t*) &width; - mHeight = *(uint32_t*) &height; + memcpy(&mWidth, &width, sizeof(mWidth)); + memcpy(&mHeight, &height, sizeof(mHeight)); } OvalShapeCacheEntry(): ShapeCacheEntry() { @@ -233,8 +233,8 @@ private: struct RectShapeCacheEntry: public ShapeCacheEntry { RectShapeCacheEntry(float width, float height, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeRect, paint) { - mWidth = *(uint32_t*) &width; - mHeight = *(uint32_t*) &height; + memcpy(&mWidth, &width, sizeof(mWidth)); + memcpy(&mHeight, &height, sizeof(mHeight)); } RectShapeCacheEntry(): ShapeCacheEntry() { @@ -260,10 +260,10 @@ struct ArcShapeCacheEntry: public ShapeCacheEntry { ArcShapeCacheEntry(float width, float height, float startAngle, float sweepAngle, bool useCenter, SkPaint* paint): ShapeCacheEntry(ShapeCacheEntry::kShapeArc, paint) { - mWidth = *(uint32_t*) &width; - mHeight = *(uint32_t*) &height; - mStartAngle = *(uint32_t*) &startAngle; - mSweepAngle = *(uint32_t*) &sweepAngle; + memcpy(&mWidth, &width, sizeof(mWidth)); + memcpy(&mHeight, &height, sizeof(mHeight)); + memcpy(&mStartAngle, &startAngle, sizeof(mStartAngle)); + memcpy(&mSweepAngle, &sweepAngle, sizeof(mSweepAngle)); mUseCenter = useCenter ? 1 : 0; } diff --git a/libs/hwui/TextDropShadowCache.h b/libs/hwui/TextDropShadowCache.h index e2bdde1eca89..35eb4cc9f571 100644 --- a/libs/hwui/TextDropShadowCache.h +++ b/libs/hwui/TextDropShadowCache.h @@ -49,10 +49,10 @@ struct ShadowText { } const float skewX = paint->getTextSkewX(); - italicStyle = *(uint32_t*) &skewX; + memcpy(&italicStyle, &skewX, sizeof(italicStyle)); const float scaleXFloat = paint->getTextScaleX(); - scaleX = *(uint32_t*) &scaleXFloat; + memcpy(&scaleX, &scaleXFloat, sizeof(scaleX)); } ~ShadowText() { |