From db8c9a6a4d9bf8c39f834b25611926caf21380f6 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Wed, 21 Mar 2012 18:54:18 -0700 Subject: Optimization of alpha with DisplayList properties Some views (such as ImageView and TextView) handle non-opaque alpha values directly. This was originally an optimization, but we can handle it faster in many cases without this optimization when DisplayList properties are enabled. Basically, if a view has non-overlapping rendering, we set the alpha value directly on the renderer (the equivalent of setting it on the Paint object) and draw each primitive with that alpha value. Doing it this way avoids re-creating DisplayLists while getting the same speedup that onSetAlpha() used to get pre-DisplayList properties. Change-Id: I0f7827f075d3b35093a882d4adbb300a1063c288 --- libs/hwui/OpenGLRenderer.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libs/hwui/OpenGLRenderer.cpp') diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 115787c87ebc..ec9b56b4ca2d 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1101,6 +1101,7 @@ void OpenGLRenderer::setupDrawColor(int color) { void OpenGLRenderer::setupDrawColor(int color, int alpha) { mColorA = alpha / 255.0f; + mColorA *= mSnapshot->alpha; // Second divide of a by 255 is an optimization, allowing us to simply multiply // the rgb values by a instead of also dividing by 255 const float a = mColorA / 255.0f; @@ -2800,6 +2801,7 @@ void OpenGLRenderer::getAlphaAndMode(SkPaint* paint, int* alpha, SkXfermode::Mod *mode = SkXfermode::kSrcOver_Mode; *alpha = 255; } + *alpha *= mSnapshot->alpha; } SkXfermode::Mode OpenGLRenderer::getXfermode(SkXfermode* mode) { -- cgit v1.2.3-59-g8ed1b