frameworks/native: Add support for custom layers in Surfaceflinger
- Check for the EXT_ONLY layer and add only that layer to external
list and do not add that layer to the primary list
- Check for INT_ONLY layer and remove that layer from external list
- These are added to support EXTERNAL_ONLY & INTERNAL_ONLY feature
Change-Id: I8f84eeacebf97d44446f319f69b8a73e56f2cb6d
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 09e0849..29cb41d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1029,8 +1029,9 @@
const sp<DisplayDevice>& hw(mDisplays[dpy]);
const Transform& tr(hw->getTransform());
const Rect bounds(hw->getBounds());
+ int dpyId = hw->getHwcDisplayId();
if (hw->isDisplayOn()) {
- SurfaceFlinger::computeVisibleRegions(layers,
+ SurfaceFlinger::computeVisibleRegions(dpyId, layers,
hw->getLayerStack(), dirtyRegion, opaqueRegion);
const size_t count = layers.size();
@@ -1745,7 +1746,7 @@
mTransactionCV.broadcast();
}
-void SurfaceFlinger::computeVisibleRegions(
+void SurfaceFlinger::computeVisibleRegions(size_t dpy,
const LayerVector& currentLayers, uint32_t layerStack,
Region& outDirtyRegion, Region& outOpaqueRegion)
{
@@ -1756,7 +1757,7 @@
Region dirty;
outDirtyRegion.clear();
-
+ bool bIgnoreLayers = false;
size_t i = currentLayers.size();
while (i--) {
const sp<Layer>& layer = currentLayers[i];
@@ -1764,8 +1765,34 @@
// start with the whole surface at its current location
const Layer::State& s(layer->getDrawingState());
- // only consider the layers on the given layer stack
- if (s.layerStack != layerStack)
+#ifdef QCOM_BSP
+ if(bIgnoreLayers) {
+ // Ignore all other layers except the layers marked as ext_only
+ // by setting visible non transparent region empty.
+ Region visibleNonTransRegion;
+ visibleNonTransRegion.set(Rect(0,0));
+ layer->setVisibleNonTransparentRegion(visibleNonTransRegion);
+ continue;
+ }
+ // Only add the layer marked as "external_only" to external list and
+ // only remove the layer marked as "external_only" from primary list
+ // and do not add the layer marked as "internal_only" to external list
+ if ((dpy && layer->isExtOnly())) {
+ bIgnoreLayers = true;
+ } else if(layer->isExtOnly() || (dpy && layer->isIntOnly())) {
+ // Ignore only ext_only layers for primary by setting
+ // visible non transparent region empty.
+ Region visibleNonTransRegion;
+ visibleNonTransRegion.set(Rect(0,0));
+ layer->setVisibleNonTransparentRegion(visibleNonTransRegion);
+ continue;
+ }
+#endif
+
+ // only consider the layers on the given later stack
+ // Override layers created using presentation class by the layers having
+ // ext_only flag enabled
+ if (s.layerStack != layerStack && !bIgnoreLayers)
continue;
/*