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/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 23088d7..923d296 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -824,7 +824,8 @@
return err;
}
// we're intending to do software rendering from this point
- setUsage(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
+ setUsage(mReqUsage | GRALLOC_USAGE_SW_READ_OFTEN |
+ GRALLOC_USAGE_SW_WRITE_OFTEN);
}
ANativeWindowBuffer* out;
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 457a92d..f962331 100755
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -46,6 +46,9 @@
#include "DisplayHardware/HWComposer.h"
#include "RenderEngine/RenderEngine.h"
+#ifdef QCOM_BSP
+#include <gralloc_priv.h>
+#endif
#define DEBUG_RESIZE 0
@@ -469,6 +472,15 @@
const Transform& tr(hw->getTransform());
layer.setFrame(tr.transform(frame));
+#ifdef QCOM_BSP
+ // set dest_rect to frame buffer width and height, if external_only flag
+ // for the layer is enabled.
+ if(isExtOnly()) {
+ uint32_t w = hw->getWidth();
+ uint32_t h = hw->getHeight();
+ layer.setFrame(Rect(w,h));
+ }
+#endif
layer.setCrop(computeCrop(hw));
layer.setPlaneAlpha(s.alpha);
@@ -1453,6 +1465,28 @@
bool Layer::hasNewFrame() const {
return (mQueuedFrames > 0);
}
+
+bool Layer::isExtOnly() const
+{
+ const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
+ if (activeBuffer != 0) {
+ uint32_t usage = activeBuffer->getUsage();
+ if(usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY)
+ return true;
+ }
+ return false;
+}
+
+bool Layer::isIntOnly() const
+{
+ const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
+ if (activeBuffer != 0) {
+ uint32_t usage = activeBuffer->getUsage();
+ if(usage & GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY)
+ return true;
+ }
+ return false;
+}
#endif
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index a4d0fcf..0f2da28 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -274,6 +274,10 @@
// Updates the transform hint in our SurfaceFlingerConsumer to match
// the current orientation of the display device.
void updateTransformHint(const sp<const DisplayDevice>& hw);
+#ifdef QCOM_BSP
+ virtual bool isExtOnly() const;
+ virtual bool isIntOnly() const;
+#endif
/*
* returns the rectangle that crops the content of the layer and scales it
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;
/*
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index dec85a3..20eaff6 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -381,7 +381,7 @@
* Compositing
*/
void invalidateHwcGeometry();
- static void computeVisibleRegions(
+ static void computeVisibleRegions(size_t dpy,
const LayerVector& currentLayers, uint32_t layerStack,
Region& dirtyRegion, Region& opaqueRegion);