blob: 0ca5ad948695bec1b1175532e62ec52b04c95c1f [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);
Ramkumar Radhakrishnan9d52f432013-05-14 14:46:59 -0700179 setMdpFlags(layer, mdpFlags, 0, transform);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700180 // For External use rotator if there is a rotation value set
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +0530181 ret = preRotateExtDisplay(ctx, layer, info,
182 sourceCrop, mdpFlags, rotFlags);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700183 if(!ret) {
184 ALOGE("%s: preRotate for external Failed!", __FUNCTION__);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800185 ctx->mOverlay->clear(mDpy);
186 ctx->mLayerRotMap[mDpy]->clear();
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700187 return false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700188 }
189 //For the mdp, since either we are pre-rotating or MDP does flips
190 orient = ovutils::OVERLAY_TRANSFORM_0;
191 transform = 0;
192 ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400193 static_cast<ovutils::eRotFlags>(rotFlags),
194 ovutils::DEFAULT_PLANE_ALPHA,
195 (ovutils::eBlending)
196 getBlending(layer->blending));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500197 ret = true;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700198 if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame,
199 NULL, mDest) < 0) {
Saurabh Shahe2474082013-05-15 16:32:13 -0700200 ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800201 ctx->mLayerRotMap[mDpy]->clear();
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500202 ret = false;
203 }
204 }
205 return ret;
206}
207
Saurabh Shah88e4d272013-09-03 13:31:29 -0700208bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500209{
Saurabh Shahcf053c62012-12-13 12:32:55 -0800210 if(!mModeOn) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500211 return true;
212 }
213 bool ret = true;
214 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800215 ovutils::eDest dest = mDest;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700216 int fd = hnd->fd;
217 uint32_t offset = hnd->offset;
218 if(mRot) {
219 if(!mRot->queueBuffer(fd, offset))
220 return false;
221 fd = mRot->getDstMemId();
222 offset = mRot->getDstOffset();
223 }
224 if (!ov.queueBuffer(fd, offset, dest)) {
Amara Venkata Mastan Manoj Kumardc01a532013-01-30 18:34:56 -0800225 ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500226 ret = false;
227 }
228 return ret;
229}
230
Saurabh Shahcf053c62012-12-13 12:32:55 -0800231//================= High res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -0700232FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy):
233 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -0800234
Saurabh Shah220a30c2013-10-29 16:12:12 -0700235void FBUpdateSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800236 IFBUpdate::reset();
237 mDestLeft = ovutils::OV_INVALID;
238 mDestRight = ovutils::OV_INVALID;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700239 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800240}
241
Saurabh Shah88e4d272013-09-03 13:31:29 -0700242bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800243 int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800244 if(!ctx->mMDP.hasOverlay) {
245 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800246 __FUNCTION__);
247 return false;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800248 }
249 ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800250 mModeOn = configure(ctx, list, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800251 return mModeOn;
252}
253
254// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700255bool FBUpdateSplit::configure(hwc_context_t *ctx,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700256 hwc_display_contents_1 *list, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800257 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500258 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Saurabh Shahcf053c62012-12-13 12:32:55 -0800259 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800260 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
261 // ext only layer present..
262 if(extOnlyLayerIndex != -1) {
263 layer = &list->hwLayers[extOnlyLayerIndex];
264 layer->compositionType = HWC_OVERLAY;
265 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800266 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700267
268 ovutils::Whf info(mAlignedFBWidth,
269 mAlignedFBHeight,
270 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800271
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700272 //Request left pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700273 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
274 Overlay::MIXER_LEFT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800275 if(destL == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700276 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
277 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800278 return false;
279 }
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700280 //Request right pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700281 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
282 Overlay::MIXER_RIGHT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800283 if(destR == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700284 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
285 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800286 return false;
287 }
288
289 mDestLeft = destL;
290 mDestRight = destR;
291
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800292 ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_BLEND_FG_PREMULT;
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +0530293
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800294 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800295
Naseer Ahmed522ce662013-03-18 20:14:05 -0400296 //XXX: FB layer plane alpha is currently sent as zero from
297 //surfaceflinger
Saurabh Shahcf053c62012-12-13 12:32:55 -0800298 ovutils::PipeArgs pargL(mdpFlagsL,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800299 info,
300 zOrder,
301 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400302 ovutils::ROT_FLAGS_NONE,
303 ovutils::DEFAULT_PLANE_ALPHA,
304 (ovutils::eBlending)
305 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800306 ov.setSource(pargL, destL);
307
308 ovutils::eMdpFlags mdpFlagsR = mdpFlagsL;
309 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
310 ovutils::PipeArgs pargR(mdpFlagsR,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800311 info,
312 zOrder,
313 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400314 ovutils::ROT_FLAGS_NONE,
315 ovutils::DEFAULT_PLANE_ALPHA,
316 (ovutils::eBlending)
317 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800318 ov.setSource(pargR, destR);
319
Saurabh Shah62e1d732013-09-17 10:44:05 -0700320 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800321 hwc_rect_t displayFrame = layer->displayFrame;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700322
323 const float xres = ctx->dpyAttr[mDpy].xres;
Saurabh Shah07a8ca82013-08-06 18:45:42 -0700324 const int lSplit = getLeftSplit(ctx, mDpy);
Saurabh Shah67a38c32013-06-10 16:23:15 -0700325 const float lSplitRatio = lSplit / xres;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700326 const float lCropWidth =
327 (sourceCrop.right - sourceCrop.left) * lSplitRatio;
328
329 ovutils::Dim dcropL(
330 sourceCrop.left,
331 sourceCrop.top,
332 lCropWidth,
333 sourceCrop.bottom - sourceCrop.top);
334
Saurabh Shahcf053c62012-12-13 12:32:55 -0800335 ovutils::Dim dcropR(
Saurabh Shah67a38c32013-06-10 16:23:15 -0700336 sourceCrop.left + lCropWidth,
337 sourceCrop.top,
338 (sourceCrop.right - sourceCrop.left) - lCropWidth,
339 sourceCrop.bottom - sourceCrop.top);
340
Saurabh Shahcf053c62012-12-13 12:32:55 -0800341 ov.setCrop(dcropL, destL);
342 ov.setCrop(dcropR, destR);
343
344 int transform = layer->transform;
345 ovutils::eTransform orient =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800346 static_cast<ovutils::eTransform>(transform);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800347 ov.setTransform(orient, destL);
348 ov.setTransform(orient, destR);
349
Saurabh Shah67a38c32013-06-10 16:23:15 -0700350 const int lWidth = (lSplit - displayFrame.left);
351 const int rWidth = (displayFrame.right - lSplit);
Saurabh Shahce416f02013-04-10 13:33:09 -0700352 const int height = displayFrame.bottom - displayFrame.top;
353
Saurabh Shah67a38c32013-06-10 16:23:15 -0700354 ovutils::Dim dposL(displayFrame.left,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800355 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700356 lWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700357 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700358 ov.setPosition(dposL, destL);
Saurabh Shahce416f02013-04-10 13:33:09 -0700359
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700360 ovutils::Dim dposR(0,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800361 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700362 rWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700363 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700364 ov.setPosition(dposR, destR);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800365
366 ret = true;
367 if (!ov.commit(destL)) {
368 ALOGE("%s: commit fails for left", __FUNCTION__);
369 ret = false;
370 }
371 if (!ov.commit(destR)) {
372 ALOGE("%s: commit fails for right", __FUNCTION__);
373 ret = false;
374 }
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800375 if(ret == false) {
376 ctx->mLayerRotMap[mDpy]->clear();
377 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800378 }
379 return ret;
380}
381
Saurabh Shah88e4d272013-09-03 13:31:29 -0700382bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Saurabh Shahcf053c62012-12-13 12:32:55 -0800383{
384 if(!mModeOn) {
385 return true;
386 }
387 bool ret = true;
388 overlay::Overlay& ov = *(ctx->mOverlay);
389 ovutils::eDest destL = mDestLeft;
390 ovutils::eDest destR = mDestRight;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800391 if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) {
392 ALOGE("%s: queue failed for left of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800393 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800394 ret = false;
395 }
396 if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) {
397 ALOGE("%s: queue failed for right of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800398 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800399 ret = false;
400 }
401 return ret;
402}
403
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500404//---------------------------------------------------------------------
405}; //namespace qhwc