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
This commit is contained in:
@@ -347,7 +347,7 @@ bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) {
|
|||||||
|
|
||||||
hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf);
|
hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf);
|
||||||
hwc_rect_t dst = layer->displayFrame;
|
hwc_rect_t dst = layer->displayFrame;
|
||||||
bool rotated90 = (bool)layer->transform & HAL_TRANSFORM_ROT_90;
|
bool rotated90 = (bool)(layer->transform & HAL_TRANSFORM_ROT_90);
|
||||||
int crop_w = rotated90 ? crop.bottom - crop.top : crop.right - crop.left;
|
int crop_w = rotated90 ? crop.bottom - crop.top : crop.right - crop.left;
|
||||||
int crop_h = rotated90 ? crop.right - crop.left : crop.bottom - crop.top;
|
int crop_h = rotated90 ? crop.right - crop.left : crop.bottom - crop.top;
|
||||||
int dst_w = dst.right - dst.left;
|
int dst_w = dst.right - dst.left;
|
||||||
|
|||||||
@@ -2177,30 +2177,23 @@ void BwcPM::setBwc(const hwc_rect_t& crop,
|
|||||||
if(!qdutils::MDPVersion::getInstance().supportsBWC()) {
|
if(!qdutils::MDPVersion::getInstance().supportsBWC()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int src_w = crop.right - crop.left;
|
||||||
|
int src_h = crop.bottom - crop.top;
|
||||||
|
int dst_w = dst.right - dst.left;
|
||||||
|
int dst_h = dst.bottom - dst.top;
|
||||||
|
if(transform & HAL_TRANSFORM_ROT_90) {
|
||||||
|
swap(src_w, src_h);
|
||||||
|
}
|
||||||
//src width > MAX mixer supported dim
|
//src width > MAX mixer supported dim
|
||||||
if((crop.right - crop.left) > qdutils::MAX_DISPLAY_DIM) {
|
if(src_w > qdutils::MAX_DISPLAY_DIM) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Decimation necessary, cannot use BWC. H/W requirement.
|
//Decimation necessary, cannot use BWC. H/W requirement.
|
||||||
if(qdutils::MDPVersion::getInstance().supportsDecimation()) {
|
if(qdutils::MDPVersion::getInstance().supportsDecimation()) {
|
||||||
int src_w = crop.right - crop.left;
|
uint8_t horzDeci = 0;
|
||||||
int src_h = crop.bottom - crop.top;
|
uint8_t vertDeci = 0;
|
||||||
int dst_w = dst.right - dst.left;
|
ovutils::getDecimationFactor(src_w, src_h, dst_w, dst_h, horzDeci,
|
||||||
int dst_h = dst.bottom - dst.top;
|
vertDeci);
|
||||||
if(transform & HAL_TRANSFORM_ROT_90) {
|
|
||||||
swap(src_w, src_h);
|
|
||||||
}
|
|
||||||
float horDscale = 0.0f;
|
|
||||||
float verDscale = 0.0f;
|
|
||||||
int horzDeci = 0;
|
|
||||||
int vertDeci = 0;
|
|
||||||
ovutils::getDecimationFactor(src_w, src_h, dst_w, dst_h, horDscale,
|
|
||||||
verDscale);
|
|
||||||
//TODO Use log2f once math.h has it
|
|
||||||
if((int)horDscale)
|
|
||||||
horzDeci = (int)(log(horDscale) / log(2));
|
|
||||||
if((int)verDscale)
|
|
||||||
vertDeci = (int)(log(verDscale) / log(2));
|
|
||||||
if(horzDeci || vertDeci) return;
|
if(horzDeci || vertDeci) return;
|
||||||
}
|
}
|
||||||
//Property
|
//Property
|
||||||
|
|||||||
@@ -154,32 +154,9 @@ void MdpCtrl::doDownscale() {
|
|||||||
mOVInfo.src_rect.w >>= mDownscale;
|
mOVInfo.src_rect.w >>= mDownscale;
|
||||||
mOVInfo.src_rect.h >>= mDownscale;
|
mOVInfo.src_rect.h >>= mDownscale;
|
||||||
} else if(MDPVersion::getInstance().supportsDecimation()) {
|
} else if(MDPVersion::getInstance().supportsDecimation()) {
|
||||||
//Decimation + MDP Downscale
|
|
||||||
mOVInfo.horz_deci = 0;
|
|
||||||
mOVInfo.vert_deci = 0;
|
|
||||||
int minHorDeci = 0;
|
|
||||||
if(mOVInfo.src_rect.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.
|
|
||||||
minHorDeci = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
float horDscale = 0.0f;
|
|
||||||
float verDscale = 0.0f;
|
|
||||||
|
|
||||||
utils::getDecimationFactor(mOVInfo.src_rect.w, mOVInfo.src_rect.h,
|
utils::getDecimationFactor(mOVInfo.src_rect.w, mOVInfo.src_rect.h,
|
||||||
mOVInfo.dst_rect.w, mOVInfo.dst_rect.h, horDscale, verDscale);
|
mOVInfo.dst_rect.w, mOVInfo.dst_rect.h, mOVInfo.horz_deci,
|
||||||
|
mOVInfo.vert_deci);
|
||||||
if(horDscale < minHorDeci)
|
|
||||||
horDscale = minHorDeci;
|
|
||||||
|
|
||||||
if((int)horDscale)
|
|
||||||
mOVInfo.horz_deci = (int)log2f(horDscale);
|
|
||||||
|
|
||||||
if((int)verDscale)
|
|
||||||
mOVInfo.vert_deci = (int)log2f(verDscale);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -285,10 +285,12 @@ int getDownscaleFactor(const int& src_w, const int& src_h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getDecimationFactor(const int& src_w, const int& src_h,
|
void getDecimationFactor(const int& src_w, const int& src_h,
|
||||||
const int& dst_w, const int& dst_h, float& horDscale,
|
const int& dst_w, const int& dst_h, uint8_t& horzDeci,
|
||||||
float& verDscale) {
|
uint8_t& vertDeci) {
|
||||||
horDscale = ceilf((float)src_w / (float)dst_w);
|
horzDeci = 0;
|
||||||
verDscale = ceilf((float)src_h / (float)dst_h);
|
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
|
//Next power of 2, if not already
|
||||||
horDscale = powf(2.0f, ceilf(log2f(horDscale)));
|
horDscale = powf(2.0f, ceilf(log2f(horDscale)));
|
||||||
@@ -298,6 +300,21 @@ void getDecimationFactor(const int& src_w, const int& src_h,
|
|||||||
//between decimator and MDP downscale
|
//between decimator and MDP downscale
|
||||||
horDscale /= 4.0f;
|
horDscale /= 4.0f;
|
||||||
verDscale /= 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,
|
static inline int compute(const uint32_t& x, const uint32_t& y,
|
||||||
|
|||||||
@@ -413,8 +413,8 @@ int getHALFormat(int mdpFormat);
|
|||||||
int getDownscaleFactor(const int& src_w, const int& src_h,
|
int getDownscaleFactor(const int& src_w, const int& src_h,
|
||||||
const int& dst_w, const int& dst_h);
|
const int& dst_w, const int& dst_h);
|
||||||
void getDecimationFactor(const int& src_w, const int& src_h,
|
void getDecimationFactor(const int& src_w, const int& src_h,
|
||||||
const int& dst_w, const int& dst_h, float& horDscale,
|
const int& dst_w, const int& dst_h, uint8_t& horzDeci,
|
||||||
float& verDscale);
|
uint8_t& vertDeci);
|
||||||
|
|
||||||
/* flip is upside down and such. V, H flip
|
/* flip is upside down and such. V, H flip
|
||||||
* rotation is 90, 180 etc
|
* rotation is 90, 180 etc
|
||||||
|
|||||||
Reference in New Issue
Block a user