Loading core/java/android/view/ViewConfiguration.java +14 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,20 @@ import android.util.SparseArray; * Contains methods to standard constants used in the UI for timeouts, sizes, and distances. */ public class ViewConfiguration { /** * Expected bit depth of the display panel. * * @hide */ public static final float PANEL_BIT_DEPTH = 24; /** * Minimum alpha required for a view to draw. * * @hide */ public static final float ALPHA_THRESHOLD = 0.5f / PANEL_BIT_DEPTH; /** * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in * pixels Loading core/java/android/view/ViewGroup.java +6 −4 Original line number Diff line number Diff line Loading @@ -2186,6 +2186,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager return more; } float alpha = child.getAlpha(); // Bail out early if the view does not need to be drawn if (alpha <= ViewConfiguration.ALPHA_THRESHOLD) return more; child.computeScroll(); final int sx = child.mScrollX; Loading Loading @@ -2217,8 +2221,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } } float alpha = child.getAlpha(); if (transformToApply != null || alpha < 1.0f || !child.hasIdentityMatrix()) { int transX = 0; int transY = 0; Loading libs/hwui/OpenGLRenderer.cpp +24 −2 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ namespace uirenderer { #define RAD_TO_DEG (180.0f / 3.14159265f) #define MIN_ANGLE 0.001f // TODO: This should be set in properties #define ALPHA_THRESHOLD (0x7f / PANEL_BIT_DEPTH) /////////////////////////////////////////////////////////////////////////////// // Globals /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -294,7 +297,9 @@ int OpenGLRenderer::saveLayer(float left, float top, float right, float bottom, mode = SkXfermode::kSrcOver_Mode; } if (!mSnapshot->previous->invisible) { createLayer(mSnapshot, left, top, right, bottom, alpha, mode, flags, previousFbo); } return count; } Loading Loading @@ -380,6 +385,14 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, if (bounds.isEmpty() || bounds.getWidth() > mMaxTextureSize || bounds.getHeight() > mMaxTextureSize) { snapshot->invisible = true; } else { // TODO: Should take the mode into account snapshot->invisible = snapshot->previous->invisible || alpha <= ALPHA_THRESHOLD; } // Bail out if we won't draw in this snapshot if (snapshot->invisible) { return false; } Loading Loading @@ -536,7 +549,7 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) { } void OpenGLRenderer::clearLayerRegions() { if (mLayers.size() == 0) return; if (mLayers.size() == 0 || mSnapshot->invisible) return; for (uint32_t i = 0; i < mLayers.size(); i++) { Rect* bounds = mLayers.itemAt(i); Loading Loading @@ -598,6 +611,10 @@ const Rect& OpenGLRenderer::getClipBounds() { } bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) { if (mSnapshot->invisible) { return true; } Rect r(left, top, right, bottom); mSnapshot->transform->mapRect(r); return !mSnapshot->clipRect->intersects(r); Loading Loading @@ -703,6 +720,8 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int } void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { if (mSnapshot->invisible) return; int alpha; SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); Loading Loading @@ -802,6 +821,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, if (text == NULL || count == 0 || (paint->getAlpha() == 0 && paint->getXfermode() == NULL)) { return; } if (mSnapshot->invisible) return; paint->setAntiAlias(true); Loading Loading @@ -866,6 +886,8 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, } void OpenGLRenderer::drawPath(SkPath* path, SkPaint* paint) { if (mSnapshot->invisible) return; GLuint textureUnit = 0; glActiveTexture(gTextureUnits[textureUnit]); Loading libs/hwui/ProgramCache.h +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ namespace uirenderer { #endif // TODO: This should be set in properties #define PANEL_BIT_DEPTH 18 #define PANEL_BIT_DEPTH 20 #define COLOR_COMPONENT_THRESHOLD (1.0f - (0.5f / PANEL_BIT_DEPTH)) #define COLOR_COMPONENT_INV_THRESHOLD (0.5f / PANEL_BIT_DEPTH) Loading libs/hwui/Snapshot.h +9 −3 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ namespace uirenderer { */ class Snapshot: public LightRefBase<Snapshot> { public: Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0) { Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0), invisible(false) { transform = &mTransformRoot; clipRect = &mClipRectRoot; } Loading @@ -53,8 +53,8 @@ public: * the previous snapshot. */ Snapshot(const sp<Snapshot>& s, int saveFlags): flags(0), previous(s), layer(NULL), fbo(s->fbo), viewport(s->viewport), height(s->height) { flags(0), previous(s), layer(NULL), fbo(s->fbo), invisible(s->invisible), viewport(s->viewport), height(s->height) { if (saveFlags & SkCanvas::kMatrix_SaveFlag) { mTransformRoot.load(*s->transform); transform = &mTransformRoot; Loading Loading @@ -211,6 +211,12 @@ public: */ GLuint fbo; /** * Indicates that this snapshot is invisible and nothing should be drawn * inside it. */ bool invisible; /** * Current viewport. */ Loading Loading
core/java/android/view/ViewConfiguration.java +14 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,20 @@ import android.util.SparseArray; * Contains methods to standard constants used in the UI for timeouts, sizes, and distances. */ public class ViewConfiguration { /** * Expected bit depth of the display panel. * * @hide */ public static final float PANEL_BIT_DEPTH = 24; /** * Minimum alpha required for a view to draw. * * @hide */ public static final float ALPHA_THRESHOLD = 0.5f / PANEL_BIT_DEPTH; /** * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in * pixels Loading
core/java/android/view/ViewGroup.java +6 −4 Original line number Diff line number Diff line Loading @@ -2186,6 +2186,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager return more; } float alpha = child.getAlpha(); // Bail out early if the view does not need to be drawn if (alpha <= ViewConfiguration.ALPHA_THRESHOLD) return more; child.computeScroll(); final int sx = child.mScrollX; Loading Loading @@ -2217,8 +2221,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } } float alpha = child.getAlpha(); if (transformToApply != null || alpha < 1.0f || !child.hasIdentityMatrix()) { int transX = 0; int transY = 0; Loading
libs/hwui/OpenGLRenderer.cpp +24 −2 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ namespace uirenderer { #define RAD_TO_DEG (180.0f / 3.14159265f) #define MIN_ANGLE 0.001f // TODO: This should be set in properties #define ALPHA_THRESHOLD (0x7f / PANEL_BIT_DEPTH) /////////////////////////////////////////////////////////////////////////////// // Globals /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -294,7 +297,9 @@ int OpenGLRenderer::saveLayer(float left, float top, float right, float bottom, mode = SkXfermode::kSrcOver_Mode; } if (!mSnapshot->previous->invisible) { createLayer(mSnapshot, left, top, right, bottom, alpha, mode, flags, previousFbo); } return count; } Loading Loading @@ -380,6 +385,14 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, if (bounds.isEmpty() || bounds.getWidth() > mMaxTextureSize || bounds.getHeight() > mMaxTextureSize) { snapshot->invisible = true; } else { // TODO: Should take the mode into account snapshot->invisible = snapshot->previous->invisible || alpha <= ALPHA_THRESHOLD; } // Bail out if we won't draw in this snapshot if (snapshot->invisible) { return false; } Loading Loading @@ -536,7 +549,7 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) { } void OpenGLRenderer::clearLayerRegions() { if (mLayers.size() == 0) return; if (mLayers.size() == 0 || mSnapshot->invisible) return; for (uint32_t i = 0; i < mLayers.size(); i++) { Rect* bounds = mLayers.itemAt(i); Loading Loading @@ -598,6 +611,10 @@ const Rect& OpenGLRenderer::getClipBounds() { } bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) { if (mSnapshot->invisible) { return true; } Rect r(left, top, right, bottom); mSnapshot->transform->mapRect(r); return !mSnapshot->clipRect->intersects(r); Loading Loading @@ -703,6 +720,8 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int } void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { if (mSnapshot->invisible) return; int alpha; SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); Loading Loading @@ -802,6 +821,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, if (text == NULL || count == 0 || (paint->getAlpha() == 0 && paint->getXfermode() == NULL)) { return; } if (mSnapshot->invisible) return; paint->setAntiAlias(true); Loading Loading @@ -866,6 +886,8 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, } void OpenGLRenderer::drawPath(SkPath* path, SkPaint* paint) { if (mSnapshot->invisible) return; GLuint textureUnit = 0; glActiveTexture(gTextureUnits[textureUnit]); Loading
libs/hwui/ProgramCache.h +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ namespace uirenderer { #endif // TODO: This should be set in properties #define PANEL_BIT_DEPTH 18 #define PANEL_BIT_DEPTH 20 #define COLOR_COMPONENT_THRESHOLD (1.0f - (0.5f / PANEL_BIT_DEPTH)) #define COLOR_COMPONENT_INV_THRESHOLD (0.5f / PANEL_BIT_DEPTH) Loading
libs/hwui/Snapshot.h +9 −3 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ namespace uirenderer { */ class Snapshot: public LightRefBase<Snapshot> { public: Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0) { Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0), invisible(false) { transform = &mTransformRoot; clipRect = &mClipRectRoot; } Loading @@ -53,8 +53,8 @@ public: * the previous snapshot. */ Snapshot(const sp<Snapshot>& s, int saveFlags): flags(0), previous(s), layer(NULL), fbo(s->fbo), viewport(s->viewport), height(s->height) { flags(0), previous(s), layer(NULL), fbo(s->fbo), invisible(s->invisible), viewport(s->viewport), height(s->height) { if (saveFlags & SkCanvas::kMatrix_SaveFlag) { mTransformRoot.load(*s->transform); transform = &mTransformRoot; Loading Loading @@ -211,6 +211,12 @@ public: */ GLuint fbo; /** * Indicates that this snapshot is invisible and nothing should be drawn * inside it. */ bool invisible; /** * Current viewport. */ Loading