blob: d601f8ff11d57df33184b42e7c00f9d7b4627802 [file] [log] [blame]
Naseer Ahmed758bfc52012-11-28 17:02:08 -05001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 * Copyright (C) 2012, The Linux Foundation. All rights reserved.
4 *
5 * Not a Contribution, Apache license notifications and license are
6 * retained for attribution purposes only.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
Saurabh Shahcf053c62012-12-13 12:32:55 -080021#define DEBUG_FBUPDATE 0
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070022#include <cutils/properties.h>
Naseer Ahmed758bfc52012-11-28 17:02:08 -050023#include <gralloc_priv.h>
Saurabh Shahaf5f5972013-07-30 13:56:35 -070024#include <overlay.h>
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070025#include <overlayRotator.h>
Naseer Ahmed758bfc52012-11-28 17:02:08 -050026#include "hwc_fbupdate.h"
Saurabh Shahbd2d0832013-04-04 14:33:08 -070027#include "mdp_version.h"
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070028#include "external.h"
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -070029#include "virtual.h"
Saurabh Shahbd2d0832013-04-04 14:33:08 -070030
31using namespace qdutils;
Saurabh Shahaf5f5972013-07-30 13:56:35 -070032using namespace overlay;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070033using overlay::Rotator;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -070034using namespace overlay::utils;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070035
Naseer Ahmed758bfc52012-11-28 17:02:08 -050036namespace qhwc {
37
38namespace ovutils = overlay::utils;
39
Saurabh Shah88e4d272013-09-03 13:31:29 -070040IFBUpdate* IFBUpdate::getObject(hwc_context_t *ctx, const int& dpy) {
41 if(isDisplaySplit(ctx, dpy)) {
Saurabh Shah220a30c2013-10-29 16:12:12 -070042 return new FBUpdateSplit(ctx, dpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -080043 }
Saurabh Shah220a30c2013-10-29 16:12:12 -070044 return new FBUpdateNonSplit(ctx, dpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -050045}
46
Saurabh Shah220a30c2013-10-29 16:12:12 -070047IFBUpdate::IFBUpdate(hwc_context_t *ctx, const int& dpy) : mDpy(dpy) {
48 getBufferSizeAndDimensions(ctx->dpyAttr[dpy].xres,
49 ctx->dpyAttr[dpy].yres,
50 HAL_PIXEL_FORMAT_RGBA_8888,
51 mAlignedFBWidth,
52 mAlignedFBHeight);
53}
54
55void IFBUpdate::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080056 mModeOn = false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070057 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -080058}
59
60//================= Low res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -070061FBUpdateNonSplit::FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy):
62 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -080063
Saurabh Shah220a30c2013-10-29 16:12:12 -070064void FBUpdateNonSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080065 IFBUpdate::reset();
66 mDest = ovutils::OV_INVALID;
67}
68
Saurabh Shah88e4d272013-09-03 13:31:29 -070069bool FBUpdateNonSplit::preRotateExtDisplay(hwc_context_t *ctx,
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +053070 hwc_layer_1_t *layer,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070071 ovutils::Whf &info,
72 hwc_rect_t& sourceCrop,
73 ovutils::eMdpFlags& mdpFlags,
74 int& rotFlags)
75{
76 int extOrient = getExtOrientation(ctx);
77 ovutils::eTransform orient = static_cast<ovutils::eTransform >(extOrient);
78 if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) {
79 mRot = ctx->mRotMgr->getNext();
80 if(mRot == NULL) return false;
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -080081 // Composed FB content will have black bars, if the viewFrame of the
82 // external is different from {0, 0, fbWidth, fbHeight}, so intersect
83 // viewFrame with sourceCrop to avoid those black bars
84 sourceCrop = getIntersection(sourceCrop, ctx->mViewFrame[mDpy]);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070085 //Configure rotator for pre-rotation
86 if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) {
87 ALOGE("%s: configRotator Failed!", __FUNCTION__);
88 mRot = NULL;
89 return false;
90 }
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -080091 ctx->mLayerRotMap[mDpy]->add(layer, mRot);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070092 info.format = (mRot)->getDstFormat();
93 updateSource(orient, info, sourceCrop);
94 rotFlags |= ovutils::ROT_PREROTATED;
95 }
96 return true;
97}
98
Saurabh Shah88e4d272013-09-03 13:31:29 -070099bool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800100 int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500101 if(!ctx->mMDP.hasOverlay) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800102 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800103 __FUNCTION__);
104 return false;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500105 }
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800106 mModeOn = configure(ctx, list, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800107 return mModeOn;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500108}
109
110// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700111bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800112 int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500113 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500114 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500115 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800116 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
117 // ext only layer present..
118 if(extOnlyLayerIndex != -1) {
119 layer = &list->hwLayers[extOnlyLayerIndex];
120 layer->compositionType = HWC_OVERLAY;
121 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500122 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700123
124 ovutils::Whf info(mAlignedFBWidth,
125 mAlignedFBHeight,
126 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500127
Saurabh Shahd4e65852013-06-17 11:33:53 -0700128 //Request a pipe
129 ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY;
130 if(qdutils::MDPVersion::getInstance().is8x26() && mDpy) {
131 //For 8x26 external always use DMA pipe
132 type = ovutils::OV_MDP_PIPE_DMA;
133 }
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700134 ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500135 if(dest == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700136 ALOGE("%s: No pipes available to configure fb for dpy %d",
137 __FUNCTION__, mDpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500138 return false;
139 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800140 mDest = dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500141
Ramkumar Radhakrishnan1829d282013-07-23 14:54:36 -0700142 if((mDpy && ctx->deviceOrientation) &&
143 ctx->listStats[mDpy].isDisplayAnimating) {
144 fbZorder = 0;
145 }
146
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800147 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700148 ovutils::eIsFg isFg = ovutils::IS_FG_OFF;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800149 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500150
Saurabh Shah62e1d732013-09-17 10:44:05 -0700151 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800152 hwc_rect_t displayFrame = layer->displayFrame;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700153 int transform = layer->transform;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700154 int rotFlags = ovutils::ROT_FLAGS_NONE;
155
156 ovutils::eTransform orient =
157 static_cast<ovutils::eTransform>(transform);
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700158 // use ext orientation if any
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700159 int extOrient = getExtOrientation(ctx);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700160
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700161 // Do not use getNonWormholeRegion() function to calculate the
162 // sourceCrop during animation on external display and
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700163 // Dont do wormhole calculation when extorientation is set on External
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700164 // Dont do wormhole calculation when extDownscale is enabled on External
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700165 if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) {
166 sourceCrop = layer->displayFrame;
167 displayFrame = sourceCrop;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700168 } else if((!mDpy ||
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700169 (mDpy && !extOrient
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700170 && !ctx->dpyAttr[mDpy].mDownScaleMode))
171 && (extOnlyLayerIndex == -1)) {
Saurabh Shahd4e65852013-06-17 11:33:53 -0700172 if(!qdutils::MDPVersion::getInstance().is8x26()) {
173 getNonWormholeRegion(list, sourceCrop);
174 displayFrame = sourceCrop;
175 }
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800176 }
Saurabh Shah220a30c2013-10-29 16:12:12 -0700177 calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700178 transform, orient);
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800179 //Store the displayFrame, will be used in getDisplayViewFrame
180 ctx->dpyAttr[mDpy].mDstRect = displayFrame;
Ramkumar Radhakrishnan9d52f432013-05-14 14:46:59 -0700181 setMdpFlags(layer, mdpFlags, 0, transform);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700182 // For External use rotator if there is a rotation value set
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +0530183 ret = preRotateExtDisplay(ctx, layer, info,
184 sourceCrop, mdpFlags, rotFlags);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700185 if(!ret) {
186 ALOGE("%s: preRotate for external Failed!", __FUNCTION__);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800187 ctx->mOverlay->clear(mDpy);
188 ctx->mLayerRotMap[mDpy]->clear();
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700189 return false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700190 }
191 //For the mdp, since either we are pre-rotating or MDP does flips
192 orient = ovutils::OVERLAY_TRANSFORM_0;
193 transform = 0;
194 ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400195 static_cast<ovutils::eRotFlags>(rotFlags),
196 ovutils::DEFAULT_PLANE_ALPHA,
197 (ovutils::eBlending)
198 getBlending(layer->blending));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500199 ret = true;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700200 if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame,
201 NULL, mDest) < 0) {
Saurabh Shahe2474082013-05-15 16:32:13 -0700202 ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800203 ctx->mLayerRotMap[mDpy]->clear();
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500204 ret = false;
205 }
206 }
207 return ret;
208}
209
Saurabh Shah88e4d272013-09-03 13:31:29 -0700210bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500211{
Saurabh Shahcf053c62012-12-13 12:32:55 -0800212 if(!mModeOn) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500213 return true;
214 }
215 bool ret = true;
216 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800217 ovutils::eDest dest = mDest;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700218 int fd = hnd->fd;
219 uint32_t offset = hnd->offset;
220 if(mRot) {
221 if(!mRot->queueBuffer(fd, offset))
222 return false;
223 fd = mRot->getDstMemId();
224 offset = mRot->getDstOffset();
225 }
226 if (!ov.queueBuffer(fd, offset, dest)) {
Amara Venkata Mastan Manoj Kumardc01a532013-01-30 18:34:56 -0800227 ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500228 ret = false;
229 }
230 return ret;
231}
232
Saurabh Shahcf053c62012-12-13 12:32:55 -0800233//================= High res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -0700234FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy):
235 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -0800236
Saurabh Shah220a30c2013-10-29 16:12:12 -0700237void FBUpdateSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800238 IFBUpdate::reset();
239 mDestLeft = ovutils::OV_INVALID;
240 mDestRight = ovutils::OV_INVALID;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700241 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800242}
243
Saurabh Shah88e4d272013-09-03 13:31:29 -0700244bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800245 int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800246 if(!ctx->mMDP.hasOverlay) {
247 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800248 __FUNCTION__);
249 return false;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800250 }
251 ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800252 mModeOn = configure(ctx, list, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800253 return mModeOn;
254}
255
256// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700257bool FBUpdateSplit::configure(hwc_context_t *ctx,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700258 hwc_display_contents_1 *list, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800259 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500260 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Saurabh Shahcf053c62012-12-13 12:32:55 -0800261 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800262 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
263 // ext only layer present..
264 if(extOnlyLayerIndex != -1) {
265 layer = &list->hwLayers[extOnlyLayerIndex];
266 layer->compositionType = HWC_OVERLAY;
267 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800268 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700269
270 ovutils::Whf info(mAlignedFBWidth,
271 mAlignedFBHeight,
272 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800273
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700274 //Request left pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700275 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
276 Overlay::MIXER_LEFT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800277 if(destL == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700278 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
279 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800280 return false;
281 }
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700282 //Request right pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700283 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
284 Overlay::MIXER_RIGHT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800285 if(destR == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700286 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
287 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800288 return false;
289 }
290
291 mDestLeft = destL;
292 mDestRight = destR;
293
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800294 ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_BLEND_FG_PREMULT;
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +0530295
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800296 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800297
Naseer Ahmed522ce662013-03-18 20:14:05 -0400298 //XXX: FB layer plane alpha is currently sent as zero from
299 //surfaceflinger
Saurabh Shahcf053c62012-12-13 12:32:55 -0800300 ovutils::PipeArgs pargL(mdpFlagsL,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800301 info,
302 zOrder,
303 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400304 ovutils::ROT_FLAGS_NONE,
305 ovutils::DEFAULT_PLANE_ALPHA,
306 (ovutils::eBlending)
307 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800308 ov.setSource(pargL, destL);
309
310 ovutils::eMdpFlags mdpFlagsR = mdpFlagsL;
311 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
312 ovutils::PipeArgs pargR(mdpFlagsR,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800313 info,
314 zOrder,
315 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400316 ovutils::ROT_FLAGS_NONE,
317 ovutils::DEFAULT_PLANE_ALPHA,
318 (ovutils::eBlending)
319 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800320 ov.setSource(pargR, destR);
321
Saurabh Shah62e1d732013-09-17 10:44:05 -0700322 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800323 hwc_rect_t displayFrame = layer->displayFrame;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700324
325 const float xres = ctx->dpyAttr[mDpy].xres;
Saurabh Shah07a8ca82013-08-06 18:45:42 -0700326 const int lSplit = getLeftSplit(ctx, mDpy);
Saurabh Shah67a38c32013-06-10 16:23:15 -0700327 const float lSplitRatio = lSplit / xres;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700328 const float lCropWidth =
329 (sourceCrop.right - sourceCrop.left) * lSplitRatio;
330
331 ovutils::Dim dcropL(
332 sourceCrop.left,
333 sourceCrop.top,
334 lCropWidth,
335 sourceCrop.bottom - sourceCrop.top);
336
Saurabh Shahcf053c62012-12-13 12:32:55 -0800337 ovutils::Dim dcropR(
Saurabh Shah67a38c32013-06-10 16:23:15 -0700338 sourceCrop.left + lCropWidth,
339 sourceCrop.top,
340 (sourceCrop.right - sourceCrop.left) - lCropWidth,
341 sourceCrop.bottom - sourceCrop.top);
342
Saurabh Shahcf053c62012-12-13 12:32:55 -0800343 ov.setCrop(dcropL, destL);
344 ov.setCrop(dcropR, destR);
345
346 int transform = layer->transform;
347 ovutils::eTransform orient =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800348 static_cast<ovutils::eTransform>(transform);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800349 ov.setTransform(orient, destL);
350 ov.setTransform(orient, destR);
351
Saurabh Shah67a38c32013-06-10 16:23:15 -0700352 const int lWidth = (lSplit - displayFrame.left);
353 const int rWidth = (displayFrame.right - lSplit);
Saurabh Shahce416f02013-04-10 13:33:09 -0700354 const int height = displayFrame.bottom - displayFrame.top;
355
Saurabh Shah67a38c32013-06-10 16:23:15 -0700356 ovutils::Dim dposL(displayFrame.left,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800357 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700358 lWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700359 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700360 ov.setPosition(dposL, destL);
Saurabh Shahce416f02013-04-10 13:33:09 -0700361
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700362 ovutils::Dim dposR(0,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800363 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700364 rWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700365 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700366 ov.setPosition(dposR, destR);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800367
368 ret = true;
369 if (!ov.commit(destL)) {
370 ALOGE("%s: commit fails for left", __FUNCTION__);
371 ret = false;
372 }
373 if (!ov.commit(destR)) {
374 ALOGE("%s: commit fails for right", __FUNCTION__);
375 ret = false;
376 }
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800377 if(ret == false) {
378 ctx->mLayerRotMap[mDpy]->clear();
379 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800380 }
381 return ret;
382}
383
Saurabh Shah88e4d272013-09-03 13:31:29 -0700384bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Saurabh Shahcf053c62012-12-13 12:32:55 -0800385{
386 if(!mModeOn) {
387 return true;
388 }
389 bool ret = true;
390 overlay::Overlay& ov = *(ctx->mOverlay);
391 ovutils::eDest destL = mDestLeft;
392 ovutils::eDest destR = mDestRight;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800393 if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) {
394 ALOGE("%s: queue failed for left of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800395 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800396 ret = false;
397 }
398 if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) {
399 ALOGE("%s: queue failed for right of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800400 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800401 ret = false;
402 }
403 return ret;
404}
405
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500406//---------------------------------------------------------------------
407}; //namespace qhwc