summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2012-11-15 22:33:00 +0100
committerAmit Pundir <amit.pundir@linaro.org>2013-02-13 17:08:26 +0530
commitd41547c19cb1638cc2f5933c34338e74a69bfb93 (patch)
tree6cf157e83deae40b0fbf7c7fb753599ccbc76312
parent2c42dd4659b30bebd5873af99809ff47df6455bf (diff)
downloadbase-d41547c19cb1638cc2f5933c34338e74a69bfb93.tar.gz
frameworks/base: Fix compile errors
Fix ISO C++11 incompatibility in TextLayoutCache and aliasing violation in FontRenderer Change-Id: I19a9560737005e72f706c12c0ccfdcd0c7765b06 Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r--core/jni/android/graphics/TextLayoutCache.cpp10
-rw-r--r--libs/hwui/FontRenderer.cpp6
2 files changed, 8 insertions, 8 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index add0f320ebee..316675acd895 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -144,7 +144,7 @@ sp<TextLayoutValue> TextLayoutCache::getValue(const SkPaint* paint,
"This indicates that the cache already has an entry with the "
"same key but it should not since we checked earlier!"
" - start = %d, count = %d, contextCount = %d - Text = '%s'",
- start, count, contextCount, String8(key.getText() + start, count).string());
+ start, count, contextCount, String8(reinterpret_cast<const char16_t*>(key.getText() + start), count).string());
if (mDebugEnabled) {
nsecs_t totalTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime;
@@ -155,7 +155,7 @@ sp<TextLayoutValue> TextLayoutCache::getValue(const SkPaint* paint,
value.get(), start, count, contextCount, size, mMaxSize - mSize,
value->getElapsedTime() * 0.000001f,
(totalTime - value->getElapsedTime()) * 0.000001f,
- String8(key.getText() + start, count).string());
+ String8(reinterpret_cast<const char16_t*>(key.getText() + start), count).string());
}
} else {
if (mDebugEnabled) {
@@ -165,7 +165,7 @@ sp<TextLayoutValue> TextLayoutCache::getValue(const SkPaint* paint,
" - Compute time %0.6f ms - Text = '%s'",
start, count, contextCount, size, mMaxSize - mSize,
value->getElapsedTime() * 0.000001f,
- String8(key.getText() + start, count).string());
+ String8(reinterpret_cast<const char16_t*>(key.getText() + start), count).string());
}
}
} else {
@@ -185,7 +185,7 @@ sp<TextLayoutValue> TextLayoutCache::getValue(const SkPaint* paint,
value->getElapsedTime() * 0.000001f,
elapsedTimeThruCacheGet * 0.000001f,
deltaPercent,
- String8(key.getText() + start, count).string());
+ String8(reinterpret_cast<const char16_t*>(key.getText() + start), count).string());
}
if (mCacheHitCount % DEFAULT_DUMP_STATS_CACHE_HIT_INTERVAL == 0) {
dumpCacheStats();
@@ -231,7 +231,7 @@ TextLayoutCacheKey::TextLayoutCacheKey(const SkPaint* paint, const UChar* text,
size_t start, size_t count, size_t contextCount, int dirFlags) :
start(start), count(count), contextCount(contextCount),
dirFlags(dirFlags) {
- textCopy.setTo(text, contextCount);
+ textCopy.setTo(reinterpret_cast<const char16_t*>(text), contextCount);
typeface = paint->getTypeface();
textSize = paint->getTextSize();
textSkewX = paint->getTextSkewX();
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 0e33c516f7ee..febeb5d72c7d 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -557,12 +557,12 @@ void FontRenderer::precache(SkPaint* paint, const char* text, int numGlyphs) {
flags |= Font::kFakeBold;
}
const float skewX = paint->getTextSkewX();
- uint32_t italicStyle = *(uint32_t*) &skewX;
+ uint32_t italicStyle; memcpy(&italicStyle, &skewX, sizeof(float)); // = *(uint32_t*) &skewX;
const float scaleXFloat = paint->getTextScaleX();
- uint32_t scaleX = *(uint32_t*) &scaleXFloat;
+ uint32_t scaleX; memcpy(&scaleX, &scaleXFloat, sizeof(float)); // = *(uint32_t*) &scaleXFloat;
SkPaint::Style style = paint->getStyle();
const float strokeWidthFloat = paint->getStrokeWidth();
- uint32_t strokeWidth = *(uint32_t*) &strokeWidthFloat;
+ uint32_t strokeWidth; memcpy(&strokeWidth, &strokeWidthFloat, sizeof(float)); // = *(uint32_t*) &strokeWidthFloat;
float fontSize = paint->getTextSize();
Font* font = Font::create(this, SkTypeface::UniqueID(paint->getTypeface()),
fontSize, flags, italicStyle, scaleX, style, strokeWidth);