summaryrefslogtreecommitdiffstats
path: root/libs/hwui/RenderNode.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2015-06-12 11:07:23 -0700
committerChris Craik <ccraik@google.com>2015-06-12 11:07:23 -0700
commit4e9d9b2a590105035c29f12ecf0689333e6b55e7 (patch)
tree250eea350d584e8d280d5923eb2a3ad092d2f3c7 /libs/hwui/RenderNode.cpp
parentcc87cfa29c4b38d1f119bdce652918565b0fed0f (diff)
downloadframeworks_base-4e9d9b2a590105035c29f12ecf0689333e6b55e7.zip
frameworks_base-4e9d9b2a590105035c29f12ecf0689333e6b55e7.tar.gz
frameworks_base-4e9d9b2a590105035c29f12ecf0689333e6b55e7.tar.bz2
Revert to save-layer based alpha if layer would be too large
bug:21011574 Change-Id: I323f2398188ffc2bbed6a98578d25d7e5f6c337d
Diffstat (limited to 'libs/hwui/RenderNode.cpp')
-rw-r--r--libs/hwui/RenderNode.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 4ac4362..75e700a 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -392,11 +392,27 @@ void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) {
if (isLayer) {
clipFlags &= ~CLIP_TO_BOUNDS; // bounds clipping done by layer
}
- LOG_ALWAYS_FATAL_IF(!isLayer && properties().getHasOverlappingRendering());
- renderer.scaleAlpha(properties().getAlpha());
+ if (CC_LIKELY(isLayer || !properties().getHasOverlappingRendering())) {
+ // simply scale rendering content's alpha
+ renderer.scaleAlpha(properties().getAlpha());
+ } else {
+ // savelayer needed to create an offscreen buffer
+ Rect layerBounds(0, 0, getWidth(), getHeight());
+ if (clipFlags) {
+ properties().getClippingRectForFlags(clipFlags, &layerBounds);
+ clipFlags = 0; // all clipping done by savelayer
+ }
+ SaveLayerOp* op = new (handler.allocator()) SaveLayerOp(
+ layerBounds.left, layerBounds.top,
+ layerBounds.right, layerBounds.bottom,
+ (int) (properties().getAlpha() * 255),
+ SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kClipToLayer_SaveFlag);
+ handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds());
+ }
if (CC_UNLIKELY(ATRACE_ENABLED() && properties().promotedToLayer())) {
- // pretend to cause savelayer to warn about performance problem affecting old versions
+ // pretend alpha always causes savelayer to warn about
+ // performance problem affecting old versions
ATRACE_FORMAT("%s alpha caused saveLayer %dx%d", getName(),
static_cast<int>(getWidth()),
static_cast<int>(getHeight()));