// regions below are in window-manager space
Region visibleRegion;
Region coveredRegion;
+ Region visibleNonTransparentRegion;
int32_t sequence;
struct Geometry {
bool setSize(uint32_t w, uint32_t h);
bool setAlpha(uint8_t alpha);
bool setMatrix(const layer_state_t::matrix22_t& matrix);
- bool setTransparentRegionHint(const Region& opaque);
+ bool setTransparentRegionHint(const Region& transparent);
bool setFlags(uint8_t flags, uint8_t mask);
bool setCrop(const Rect& crop);
bool setLayerStack(uint32_t layerStack);
virtual void setCoveredRegion(const Region& coveredRegion);
/**
+ * setVisibleNonTransparentRegion - called when the visible and
+ * non-transparent region changes.
+ */
+ virtual void setVisibleNonTransparentRegion(const Region&
+ visibleNonTransparentRegion);
+
+ /**
* latchBuffer - called each time the screen is redrawn and returns whether
* the visible regions need to be recomputed (this is a fairly heavy
* operation, so this should be set only if needed). Typically this is used
const sp<LayerBase>& layer(currentLayers[i]);
const Layer::State& s(layer->drawingState());
if (s.layerStack == hw->getLayerStack()) {
- Region visibleRegion(tr.transform(layer->visibleRegion));
- visibleRegion.andSelf(bounds);
- if (!visibleRegion.isEmpty()) {
+ Region drawRegion(tr.transform(
+ layer->visibleNonTransparentRegion));
+ drawRegion.andSelf(bounds);
+ if (!drawRegion.isEmpty()) {
layersSortedByZ.add(layer);
}
}
*/
Region coveredRegion;
+ /*
+ * transparentRegion: area of a surface that is hinted to be completely
+ * transparent. This is only used to tell when the layer has no visible
+ * non-transparent regions and can be removed from the layer list. It
+ * does not affect the visibleRegion of this layer or any layers
+ * beneath it. The hint may not be correct if apps don't respect the
+ * SurfaceView restrictions (which, sadly, some don't).
+ */
+ Region transparentRegion;
+
// handle hidden surfaces by setting the visible region to empty
if (CC_LIKELY(layer->isVisible())) {
if (!visibleRegion.isEmpty()) {
// Remove the transparent area from the visible region
if (translucent) {
- Region transparentRegionScreen;
const Transform tr(s.transform);
if (tr.transformed()) {
if (tr.preserveRects()) {
// transform the transparent region
- transparentRegionScreen = tr.transform(s.transparentRegion);
+ transparentRegion = tr.transform(s.transparentRegion);
} else {
// transformation too complex, can't do the
// transparent region optimization.
- transparentRegionScreen.clear();
+ transparentRegion.clear();
}
} else {
- transparentRegionScreen = s.transparentRegion;
+ transparentRegion = s.transparentRegion;
}
- visibleRegion.subtractSelf(transparentRegionScreen);
}
// compute the opaque region
// Update aboveOpaqueLayers for next (lower) layer
aboveOpaqueLayers.orSelf(opaqueRegion);
- // Store the visible region is screen space
+ // Store the visible region in screen space
layer->setVisibleRegion(visibleRegion);
layer->setCoveredRegion(coveredRegion);
+ layer->setVisibleNonTransparentRegion(
+ visibleRegion.subtract(transparentRegion));
}
outOpaqueRegion = aboveOpaqueLayers;