From 6f560322d7f655ba25e499094a42c2add499df2f Mon Sep 17 00:00:00 2001 From: "Arun Kumar K.R" Date: Tue, 28 Aug 2012 18:33:09 -0700 Subject: [PATCH] display: Add support for video rotation on Ext display - sourceTransform in the hwc_layer_t has the source buffer transform, use this transform for external display. - This helps in showing videos with source orientation properly on the external display CRs-fixed: 387357 Change-Id: I2ac7e5481a27b93d10ba3fc1ad2e4a8788dc20a5 (cherry picked from commit a51a41188d34db49528edadadbf9ddbc052e772d) --- libhwcomposer/hwc_video.cpp | 5 ++--- liboverlay/pipes/overlayVideoExtPipe.h | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libhwcomposer/hwc_video.cpp b/libhwcomposer/hwc_video.cpp index 4e7bc5f..cbfcd8e 100644 --- a/libhwcomposer/hwc_video.cpp +++ b/libhwcomposer/hwc_video.cpp @@ -215,9 +215,8 @@ bool configExtVid(hwc_context_t *ctx, hwc_layer_t *layer) { //Only for External ov.setCrop(dcrop, ovutils::OV_PIPE1); - // FIXME: Use source orientation for TV when source is portrait - //Only for External - ov.setTransform(0, ovutils::OV_PIPE1); + //use sourceTransform only for External + ov.setTransform(layer->sourceTransform, ovutils::OV_PIPE1); ovutils::Dim dpos; hwc_rect_t displayFrame = layer->displayFrame; diff --git a/liboverlay/pipes/overlayVideoExtPipe.h b/liboverlay/pipes/overlayVideoExtPipe.h index d4e1f3f..b498576 100644 --- a/liboverlay/pipes/overlayVideoExtPipe.h +++ b/liboverlay/pipes/overlayVideoExtPipe.h @@ -57,11 +57,13 @@ public: void dump() const; private: overlay::GenericPipe mVideoExt; + utils::eTransform mSrcTransform; }; //------------------Inlines ----------------------------- -inline VideoExtPipe::VideoExtPipe() {} +inline VideoExtPipe::VideoExtPipe() : + mSrcTransform(utils::OVERLAY_TRANSFORM_0) {} inline VideoExtPipe::~VideoExtPipe() { close(); } inline bool VideoExtPipe::init(RotatorBase* rot) { ALOGE_IF(DEBUG_OVERLAY, "VideoExtPipe init"); @@ -86,6 +88,10 @@ inline bool VideoExtPipe::setPosition(const utils::Dim& dim) // Use cached crop data to get aspect ratio utils::Dim crop = mVideoExt.getCrop(); utils::Whf whf(crop.w, crop.h, 0); + // Swap width and height when there is a 90/270 deg rotation + if(mSrcTransform & HAL_TRANSFORM_ROT_90) + utils::swap(whf.w, whf.h); + d = mVideoExt.getAspectRatio(whf); } ALOGE_IF(DEBUG_OVERLAY, "Calculated aspect ratio for EXT: x=%d, y=%d, w=%d," @@ -94,6 +100,7 @@ inline bool VideoExtPipe::setPosition(const utils::Dim& dim) return mVideoExt.setPosition(d); } inline bool VideoExtPipe::setTransform(const utils::eTransform& param) { + mSrcTransform = param; return mVideoExt.setTransform(param); } inline bool VideoExtPipe::setSource(const utils::PipeArgs& args) {