summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2011-12-14 15:51:42 +0059
committerBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2012-03-29 09:41:10 +0200
commitd10b4d273da63f7c629c7e915905f4cbe9b67fee (patch)
tree724df1bfcf9e9f70c9bbde8a223410afee089677
parentd0b018db6373c3c30d7ba2fe93237917b2168798 (diff)
downloadbase-d10b4d273da63f7c629c7e915905f4cbe9b67fee.tar.gz
frameworks/base: Fix various aliasing violations
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r--core/jni/Android.mk1
-rw-r--r--libs/hwui/FontRenderer.cpp9
-rw-r--r--libs/hwui/ShapeCache.h34
-rw-r--r--libs/hwui/TextDropShadowCache.h4
4 files changed, 26 insertions, 22 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 71c5d2662292..d14253d3b616 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 158f78503689..49c25f673fa7 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*) &rx;
- 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() {