hwc/overlay: Fix decimation / bwc bugs
1) While setting BWC check for 90 transform and swap crop
2) Calculate decimation in the getDecimationFactor API itself.
Currently, a residual downscale is calculated and the clients have
to take logs and apply forcible decimation like in MdpCtrl
3) Fix bug where transform gets typecasted to bool
b/14225977
Change-Id: I3c99c571e02e2cf7822342516b6a87d97be553d1
diff --git a/liboverlay/overlayUtils.cpp b/liboverlay/overlayUtils.cpp
index 0b78e4d..312a6c6 100644
--- a/liboverlay/overlayUtils.cpp
+++ b/liboverlay/overlayUtils.cpp
@@ -285,10 +285,12 @@
}
void getDecimationFactor(const int& src_w, const int& src_h,
- const int& dst_w, const int& dst_h, float& horDscale,
- float& verDscale) {
- horDscale = ceilf((float)src_w / (float)dst_w);
- verDscale = ceilf((float)src_h / (float)dst_h);
+ const int& dst_w, const int& dst_h, uint8_t& horzDeci,
+ uint8_t& vertDeci) {
+ horzDeci = 0;
+ vertDeci = 0;
+ float horDscale = ceilf((float)src_w / (float)dst_w);
+ float verDscale = ceilf((float)src_h / (float)dst_h);
//Next power of 2, if not already
horDscale = powf(2.0f, ceilf(log2f(horDscale)));
@@ -298,6 +300,21 @@
//between decimator and MDP downscale
horDscale /= 4.0f;
verDscale /= 4.0f;
+
+ if((int)horDscale)
+ horzDeci = (uint8_t)log2f(horDscale);
+
+ if((int)verDscale)
+ vertDeci = (uint8_t)log2f(verDscale);
+
+ if(src_w > 2048) {
+ //If the client sends us something > what a layer mixer supports
+ //then it means it doesn't want to use split-pipe but wants us to
+ //decimate. A minimum decimation of 2 will ensure that the width is
+ //always within layer mixer limits.
+ if(horzDeci < 2)
+ horzDeci = 2;
+ }
}
static inline int compute(const uint32_t& x, const uint32_t& y,