summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/View.java2
-rw-r--r--libs/hwui/OpenGLRenderer.cpp58
-rw-r--r--libs/hwui/OpenGLRenderer.h7
-rw-r--r--libs/hwui/Snapshot.h9
-rw-r--r--tests/HwAccelerationTest/src/com/google/android/test/hwui/TextActivity.java2
5 files changed, 31 insertions, 47 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index a0e840d..f31a248 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1657,7 +1657,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
* Convenience value to check for float values that are close enough to zero to be considered
* zero.
*/
- private static float NONZERO_EPSILON = .001f;
+ private static final float NONZERO_EPSILON = .001f;
/**
* The degrees rotation around the vertical axis through the pivot point.
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 35e17bf..01e5a2a 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -219,22 +219,16 @@ int OpenGLRenderer::save(int flags) {
}
void OpenGLRenderer::restore() {
- if (mSaveCount > 1 && restoreSnapshot()) {
- setScissorFromClip();
+ if (mSaveCount > 1) {
+ restoreSnapshot();
}
}
void OpenGLRenderer::restoreToCount(int saveCount) {
if (saveCount < 1) saveCount = 1;
- bool restoreClip = false;
-
while (mSaveCount > saveCount) {
- restoreClip |= restoreSnapshot();
- }
-
- if (restoreClip) {
- setScissorFromClip();
+ restoreSnapshot();
}
}
@@ -267,12 +261,11 @@ bool OpenGLRenderer::restoreSnapshot() {
}
mSnapshot = previous;
- if (!skip) {
- return restoreClip;
- } else {
- bool restorePreviousClip = restoreSnapshot();
- return restoreClip || restorePreviousClip;
+ if (restoreClip) {
+ setScissorFromClip();
}
+
+ return restoreClip;
}
///////////////////////////////////////////////////////////////////////////////
@@ -339,21 +332,15 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,
snapshot->layer = layer;
snapshot->fbo = layer->fbo;
- // Creates a new snapshot to draw into the FBO
- saveSnapshot();
- mSaveCount--;
-
- mSnapshot->skip = true;
- mSnapshot->transform.loadTranslate(-left, -top, 0.0f);
- mSnapshot->setClip(0.0f, 0.0f, right - left, bottom - top);
- mSnapshot->viewport.set(0.0f, 0.0f, right - left, bottom - top);
- mSnapshot->height = bottom - top;
+ snapshot->transform.loadTranslate(-left, -top, 0.0f);
+ snapshot->setClip(0.0f, 0.0f, right - left, bottom - top);
+ snapshot->viewport.set(0.0f, 0.0f, right - left, bottom - top);
+ snapshot->height = bottom - top;
+ snapshot->flags |= Snapshot::kFlagDirtyOrtho;
+ snapshot->orthoMatrix.load(mOrthoMatrix);
setScissorFromClip();
- mSnapshot->flags = Snapshot::kFlagDirtyOrtho | Snapshot::kFlagClipSet;
- mSnapshot->orthoMatrix.load(mOrthoMatrix);
-
// Change the ortho projection
glViewport(0, 0, right - left, bottom - top);
// Don't flip the FBO, it will get flipped when drawing back to the framebuffer
@@ -594,6 +581,12 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
SkXfermode::Mode mode;
getAlphaAndMode(paint, &alpha, &mode);
+ uint32_t color = paint->getColor();
+ const GLfloat a = alpha / 255.0f;
+ const GLfloat r = a * ((color >> 16) & 0xFF) / 255.0f;
+ const GLfloat g = a * ((color >> 8) & 0xFF) / 255.0f;
+ const GLfloat b = a * ((color ) & 0xFF) / 255.0f;
+
mFontRenderer.setFont(paint, SkTypeface::UniqueID(paint->getTypeface()), paint->getTextSize());
if (mHasShadow) {
glActiveTexture(gTextureUnits[0]);
@@ -601,19 +594,13 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
count, mShadowRadius);
const AutoTexture autoCleanup(shadow);
- setupShadow(shadow, x, y, mode);
+ setupShadow(shadow, x, y, mode, a);
// Draw the mesh
glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount);
glDisableVertexAttribArray(mCurrentProgram->getAttrib("texCoords"));
}
- uint32_t color = paint->getColor();
- const GLfloat a = alpha / 255.0f;
- const GLfloat r = a * ((color >> 16) & 0xFF) / 255.0f;
- const GLfloat g = a * ((color >> 8) & 0xFF) / 255.0f;
- const GLfloat b = a * ((color ) & 0xFF) / 255.0f;
-
GLuint textureUnit = 0;
glActiveTexture(gTextureUnits[textureUnit]);
@@ -705,11 +692,12 @@ void OpenGLRenderer::setupShadow(float radius, float dx, float dy, int color) {
///////////////////////////////////////////////////////////////////////////////
void OpenGLRenderer::setupShadow(const ShadowTexture* texture, float x, float y,
- SkXfermode::Mode mode) {
+ SkXfermode::Mode mode, float alpha) {
const float sx = x - texture->left + mShadowDx;
const float sy = y - texture->top + mShadowDy;
- const GLfloat a = ((mShadowColor >> 24) & 0xFF) / 255.0f;
+ const int shadowAlpha = ((mShadowColor >> 24) & 0xFF);
+ const GLfloat a = shadowAlpha < 255 ? shadowAlpha / 255.0f : alpha;
const GLfloat r = a * ((mShadowColor >> 16) & 0xFF) / 255.0f;
const GLfloat g = a * ((mShadowColor >> 8) & 0xFF) / 255.0f;
const GLfloat b = a * ((mShadowColor ) & 0xFF) / 255.0f;
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 49143a5..5c0089f 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -120,8 +120,7 @@ private:
/**
* Restores the current snapshot; mSnapshot becomes mSnapshot->previous.
*
- * @return True if the clip should be also reapplied by calling
- * #setScissorFromClip().
+ * @return True if the clip was modified.
*/
bool restoreSnapshot();
@@ -232,8 +231,10 @@ private:
* @param x The x coordinate of the shadow
* @param y The y coordinate of the shadow
* @param mode The blending mode
+ * @param alpha The alpha value
*/
- void setupShadow(const ShadowTexture* texture, float x, float y, SkXfermode::Mode mode);
+ void setupShadow(const ShadowTexture* texture, float x, float y, SkXfermode::Mode mode,
+ float alpha);
/**
* Prepares the renderer to draw the specified Alpha8 texture as a rectangle.
diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index 77650a3..21b2bef 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -42,7 +42,7 @@ namespace uirenderer {
*/
class Snapshot: public LightRefBase<Snapshot> {
public:
- Snapshot(): skip(false), flags(0), previous(NULL), layer(NULL), fbo(0) { }
+ Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0) { }
/**
* Copies the specified snapshot. Only the transform and clip rectangle
@@ -54,7 +54,6 @@ public:
height(s->height),
transform(s->transform),
clipRect(s->clipRect),
- skip(false),
flags(0),
previous(s),
layer(NULL),
@@ -166,12 +165,6 @@ public:
Rect clipRect;
/**
- * This snapshot should be skipped. Snapshots marked as skipped are
- * created by the renderer and should be hidden from the user.
- */
- bool skip;
-
- /**
* Dirty flags.
*/
int flags;
diff --git a/tests/HwAccelerationTest/src/com/google/android/test/hwui/TextActivity.java b/tests/HwAccelerationTest/src/com/google/android/test/hwui/TextActivity.java
index 8af1b7b..f645446 100644
--- a/tests/HwAccelerationTest/src/com/google/android/test/hwui/TextActivity.java
+++ b/tests/HwAccelerationTest/src/com/google/android/test/hwui/TextActivity.java
@@ -73,7 +73,9 @@ public class TextActivity extends Activity {
mLargePaint.setShadowLayer(2.5f, 3.0f, 3.0f, 0xff000000);
canvas.drawText("Hello OpenGL renderer!", 100, 400, mLargePaint);
mLargePaint.setShadowLayer(3.0f, 3.0f, 3.0f, 0xff00ff00);
+ mLargePaint.setAlpha(100);
canvas.drawText("Hello OpenGL renderer!", 100, 500, mLargePaint);
+ mLargePaint.setAlpha(255);
mLargePaint.clearShadowLayer();
canvas.drawText("Hello OpenGL renderer!", 500, 40, mStrikePaint);