Skip to content

Commit 0a386ff

Browse files
author
Romain Guy
committed
Text shadow alpha handling incorrect
DO NOT MERGE External bug: http://code.google.com/p/android/issues/detail?id=34879 This is a regression from ICS. This CL also fixes a bug where a View's alpha would be applied twice. Change-Id: I13a1546228f44d4c169259414b6fa103a6e4a0fa
1 parent 0f8e402 commit 0a386ff

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

libs/hwui/OpenGLRenderer.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,6 @@ void OpenGLRenderer::setupDrawColor(int color) {
11491149

11501150
void OpenGLRenderer::setupDrawColor(int color, int alpha) {
11511151
mColorA = alpha / 255.0f;
1152-
mColorA *= mSnapshot->alpha;
11531152
// Second divide of a by 255 is an optimization, allowing us to simply multiply
11541153
// the rgb values by a instead of also dividing by 255
11551154
const float a = mColorA / 255.0f;
@@ -1181,15 +1180,6 @@ void OpenGLRenderer::setupDrawColor(float r, float g, float b, float a) {
11811180
mSetShaderColor = mDescription.setColor(r, g, b, a);
11821181
}
11831182

1184-
void OpenGLRenderer::setupDrawAlpha8Color(float r, float g, float b, float a) {
1185-
mColorA = a;
1186-
mColorR = r;
1187-
mColorG = g;
1188-
mColorB = b;
1189-
mColorSet = true;
1190-
mSetShaderColor = mDescription.setAlpha8Color(r, g, b, a);
1191-
}
1192-
11931183
void OpenGLRenderer::setupDrawShader() {
11941184
if (mShader) {
11951185
mShader->describe(mDescription, mCaches.extensions);
@@ -1771,7 +1761,7 @@ void OpenGLRenderer::drawAARect(float left, float top, float right, float bottom
17711761
setupDraw();
17721762
setupDrawNoTexture();
17731763
setupDrawAALine();
1774-
setupDrawColor(color);
1764+
setupDrawColor(color, ((color >> 24) & 0xFF) * mSnapshot->alpha);
17751765
setupDrawColorFilter();
17761766
setupDrawShader();
17771767
setupDrawBlending(true, mode);
@@ -2267,7 +2257,7 @@ status_t OpenGLRenderer::drawRect(float left, float top, float right, float bott
22672257
status_t OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count,
22682258
const float* positions, SkPaint* paint) {
22692259
if (text == NULL || count == 0 || mSnapshot->isIgnored() ||
2270-
(paint->getAlpha() == 0 && paint->getXfermode() == NULL)) {
2260+
(paint->getAlpha() * mSnapshot->alpha == 0 && paint->getXfermode() == NULL)) {
22712261
return DrawGlInfo::kStatusDone;
22722262
}
22732263

@@ -2340,7 +2330,7 @@ status_t OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count
23402330
status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
23412331
float x, float y, SkPaint* paint, float length) {
23422332
if (text == NULL || count == 0 || mSnapshot->isIgnored() ||
2343-
(paint->getAlpha() == 0 && paint->getXfermode() == NULL)) {
2333+
(paint->getAlpha() * mSnapshot->alpha == 0 && paint->getXfermode() == NULL)) {
23442334
return DrawGlInfo::kStatusDone;
23452335
}
23462336

@@ -2393,7 +2383,7 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
23932383
const float sx = oldX - shadow->left + mShadowDx;
23942384
const float sy = oldY - shadow->top + mShadowDy;
23952385

2396-
const int shadowAlpha = ((mShadowColor >> 24) & 0xFF);
2386+
const int shadowAlpha = ((mShadowColor >> 24) & 0xFF) * mSnapshot->alpha;
23972387
int shadowColor = mShadowColor;
23982388
if (mShader) {
23992389
shadowColor = 0xffffffff;
@@ -2792,7 +2782,7 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot
27922782

27932783
setupDraw();
27942784
setupDrawNoTexture();
2795-
setupDrawColor(color);
2785+
setupDrawColor(color, ((color >> 24) & 0xFF) * mSnapshot->alpha);
27962786
setupDrawShader();
27972787
setupDrawColorFilter();
27982788
setupDrawBlending(mode);

libs/hwui/OpenGLRenderer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ class OpenGLRenderer {
537537
void setupDrawColor(int color, int alpha);
538538
void setupDrawColor(float r, float g, float b, float a);
539539
void setupDrawAlpha8Color(int color, int alpha);
540-
void setupDrawAlpha8Color(float r, float g, float b, float a);
541540
void setupDrawShader();
542541
void setupDrawColorFilter();
543542
void setupDrawBlending(SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,

0 commit comments

Comments
 (0)