summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2011-11-28 16:06:52 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-28 16:06:52 -0800
commit46685db957cc01cef4ba198aafe44d99fe31f62c (patch)
tree0a04fceefb38ca16d539c917fa3a8143b213da17
parentda822367886d68f997153c7edd5368f3dfb6d58d (diff)
parentff98fa5a847f66e591287154c634ef7895a9549c (diff)
downloadframeworks_base-46685db957cc01cef4ba198aafe44d99fe31f62c.zip
frameworks_base-46685db957cc01cef4ba198aafe44d99fe31f62c.tar.gz
frameworks_base-46685db957cc01cef4ba198aafe44d99fe31f62c.tar.bz2
Merge "Fix crash in existing applications Bug #5659476" into ics-mr1
-rw-r--r--core/java/android/view/GLES20Canvas.java17
-rw-r--r--libs/hwui/FontRenderer.cpp12
2 files changed, 25 insertions, 4 deletions
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index d948ec2..4ca299f 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -737,8 +737,21 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
final int nativePaint = paint == null ? 0 : paint.mNativePaint;
- nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, src.left, src.top, src.right,
- src.bottom, dst.left, dst.top, dst.right, dst.bottom, nativePaint);
+
+ float left, top, right, bottom;
+ if (src == null) {
+ left = top = 0;
+ right = bitmap.getWidth();
+ bottom = bitmap.getHeight();
+ } else {
+ left = src.left;
+ right = src.right;
+ top = src.top;
+ bottom = src.bottom;
+ }
+
+ nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, right, bottom,
+ dst.left, dst.top, dst.right, dst.bottom, nativePaint);
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index a077cbc..158f785 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -163,7 +163,6 @@ void Font::render(SkPaint* paint, const char* text, uint32_t start, uint32_t len
render(paint, text, start, len, numGlyphs, x, y, FRAMEBUFFER, NULL,
0, 0, NULL);
}
-
}
void Font::measure(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
@@ -615,7 +614,8 @@ void FontRenderer::issueDrawCommand() {
void FontRenderer::appendMeshQuad(float x1, float y1, float z1, float u1, float v1, float x2,
float y2, float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3,
float x4, float y4, float z4, float u4, float v4) {
- if (x1 > mClip->right || y1 < mClip->top || x2 < mClip->left || y4 > mClip->bottom) {
+ if (mClip &&
+ (x1 > mClip->right || y1 < mClip->top || x2 < mClip->left || y4 > mClip->bottom)) {
return;
}
@@ -723,11 +723,16 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch
return image;
}
+ mClip = NULL;
+ mBounds = NULL;
+
Rect bounds;
mCurrentFont->measure(paint, text, startIndex, len, numGlyphs, &bounds);
+
uint32_t paddedWidth = (uint32_t) (bounds.right - bounds.left) + 2 * radius;
uint32_t paddedHeight = (uint32_t) (bounds.top - bounds.bottom) + 2 * radius;
uint8_t* dataBuffer = new uint8_t[paddedWidth * paddedHeight];
+
for (uint32_t i = 0; i < paddedWidth * paddedHeight; i++) {
dataBuffer[i] = 0;
}
@@ -765,8 +770,11 @@ bool FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text
mDrawn = false;
mBounds = bounds;
mClip = clip;
+
mCurrentFont->render(paint, text, startIndex, len, numGlyphs, x, y);
+
mBounds = NULL;
+ mClip = NULL;
if (mCurrentQuadIndex != 0) {
issueDrawCommand();