hwc: external: Add screen-fitting to external panel.
Screen fitting for out-of-bounds videos (with overlays) exists for primary
panel. Add this same support for external panels, so that GPU won't be needed
in panning use-cases.
Bug: 7313955
Change-Id: I274a821264d87098227b144752f4d0b89d342cd9
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 0398a17..340490a 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -148,21 +148,21 @@
}
}
-static inline void calc_cut(float& leftCut, float& topCut, float& rightCut,
- float& bottomCut, int orient) {
+static inline void calc_cut(float& leftCutRatio, float& topCutRatio,
+ float& rightCutRatio, float& bottomCutRatio, int orient) {
if(orient & HAL_TRANSFORM_FLIP_H) {
- swap(leftCut, rightCut);
+ swap(leftCutRatio, rightCutRatio);
}
if(orient & HAL_TRANSFORM_FLIP_V) {
- swap(topCut, bottomCut);
+ swap(topCutRatio, bottomCutRatio);
}
if(orient & HAL_TRANSFORM_ROT_90) {
//Anti clock swapping
- float tmpCut = leftCut;
- leftCut = topCut;
- topCut = rightCut;
- rightCut = bottomCut;
- bottomCut = tmpCut;
+ float tmpCutRatio = leftCutRatio;
+ leftCutRatio = topCutRatio;
+ topCutRatio = rightCutRatio;
+ rightCutRatio = bottomCutRatio;
+ bottomCutRatio = tmpCutRatio;
}
}
@@ -183,30 +183,31 @@
int dst_w = abs(dst.right - dst.left);
int dst_h = abs(dst.bottom - dst.top);
- float leftCut = 0.0f, rightCut = 0.0f, topCut = 0.0f, bottomCut = 0.0f;
+ float leftCutRatio = 0.0f, rightCutRatio = 0.0f, topCutRatio = 0.0f,
+ bottomCutRatio = 0.0f;
if(dst_l < 0) {
- leftCut = (float)(0.0f - dst_l) / (float)dst_w;
+ leftCutRatio = (float)(0.0f - dst_l) / (float)dst_w;
dst_l = 0;
}
if(dst_r > fbWidth) {
- rightCut = (float)(dst_r - fbWidth) / (float)dst_w;
+ rightCutRatio = (float)(dst_r - fbWidth) / (float)dst_w;
dst_r = fbWidth;
}
if(dst_t < 0) {
- topCut = (float)(0 - dst_t) / (float)dst_h;
+ topCutRatio = (float)(0 - dst_t) / (float)dst_h;
dst_t = 0;
}
if(dst_b > fbHeight) {
- bottomCut = (float)(dst_b - fbHeight) / (float)dst_h;
+ bottomCutRatio = (float)(dst_b - fbHeight) / (float)dst_h;
dst_b = fbHeight;
}
- calc_cut(leftCut, topCut, rightCut, bottomCut, orient);
- crop_l += crop_w * leftCut;
- crop_t += crop_h * topCut;
- crop_r -= crop_w * rightCut;
- crop_b -= crop_h * bottomCut;
+ calc_cut(leftCutRatio, topCutRatio, rightCutRatio, bottomCutRatio, orient);
+ crop_l += crop_w * leftCutRatio;
+ crop_t += crop_h * topCutRatio;
+ crop_r -= crop_w * rightCutRatio;
+ crop_b -= crop_h * bottomCutRatio;
}
bool isExternalActive(hwc_context_t* ctx) {
diff --git a/libhwcomposer/hwc_video.cpp b/libhwcomposer/hwc_video.cpp
index 77c9328..aad2939 100644
--- a/libhwcomposer/hwc_video.cpp
+++ b/libhwcomposer/hwc_video.cpp
@@ -152,10 +152,8 @@
//Calculate the rect for primary based on whether the supplied position
//is within or outside bounds.
- const int fbWidth =
- ovutils::FrameBufferInfo::getInstance()->getWidth();
- const int fbHeight =
- ovutils::FrameBufferInfo::getInstance()->getHeight();
+ const int fbWidth = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
+ const int fbHeight = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].yres;
if( displayFrame.left < 0 ||
displayFrame.top < 0 ||
@@ -217,7 +215,26 @@
ovutils::PipeArgs pargs[ovutils::MAX_PIPES] = { parg, parg, parg };
ov.setSource(pargs, ovutils::OV_PIPE1);
+ int transform = layer->transform;
+ ovutils::eTransform orient =
+ static_cast<ovutils::eTransform>(transform);
+
hwc_rect_t sourceCrop = layer->sourceCrop;
+ hwc_rect_t displayFrame = layer->displayFrame;
+
+ //Calculate the rect for primary based on whether the supplied position
+ //is within or outside bounds.
+ const int fbWidth = ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].xres;
+ const int fbHeight = ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].yres;
+
+ if( displayFrame.left < 0 ||
+ displayFrame.top < 0 ||
+ displayFrame.right > fbWidth ||
+ displayFrame.bottom > fbHeight) {
+ calculate_crop_rects(sourceCrop, displayFrame, fbWidth, fbHeight,
+ transform);
+ }
+
// x,y,w,h
ovutils::Dim dcrop(sourceCrop.left, sourceCrop.top,
sourceCrop.right - sourceCrop.left,
@@ -225,17 +242,12 @@
//Only for External
ov.setCrop(dcrop, ovutils::OV_PIPE1);
- int transform = layer->transform;
- ovutils::eTransform orient =
- static_cast<ovutils::eTransform>(transform);
ov.setTransform(orient, ovutils::OV_PIPE1);
- ovutils::Dim dpos;
- hwc_rect_t displayFrame = layer->displayFrame;
- dpos.x = displayFrame.left;
- dpos.y = displayFrame.top;
- dpos.w = (displayFrame.right - displayFrame.left);
- dpos.h = (displayFrame.bottom - displayFrame.top);
+ ovutils::Dim dpos(displayFrame.left,
+ displayFrame.top,
+ (displayFrame.right - displayFrame.left),
+ (displayFrame.bottom - displayFrame.top));
//Only for External
ov.setPosition(dpos, ovutils::OV_PIPE1);