blob: bb9adbfb825abd1331d65fbd9d7d6e7e8eab051d [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;
81 //Configure rotator for pre-rotation
82 if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) {
83 ALOGE("%s: configRotator Failed!", __FUNCTION__);
84 mRot = NULL;
85 return false;
86 }
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +053087 ctx->mLayerRotMap[mDpy]->add(layer, mRot);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070088 info.format = (mRot)->getDstFormat();
89 updateSource(orient, info, sourceCrop);
90 rotFlags |= ovutils::ROT_PREROTATED;
91 }
92 return true;
93}
94
Saurabh Shah88e4d272013-09-03 13:31:29 -070095bool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080096 int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050097 if(!ctx->mMDP.hasOverlay) {
Saurabh Shahcf053c62012-12-13 12:32:55 -080098 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080099 __FUNCTION__);
100 return false;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500101 }
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800102 mModeOn = configure(ctx, list, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800103 return mModeOn;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500104}
105
106// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700107bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800108 int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500109 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500110 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500111 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800112 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
113 // ext only layer present..
114 if(extOnlyLayerIndex != -1) {
115 layer = &list->hwLayers[extOnlyLayerIndex];
116 layer->compositionType = HWC_OVERLAY;
117 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500118 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700119
120 ovutils::Whf info(mAlignedFBWidth,
121 mAlignedFBHeight,
122 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500123
Saurabh Shahd4e65852013-06-17 11:33:53 -0700124 //Request a pipe
125 ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY;
126 if(qdutils::MDPVersion::getInstance().is8x26() && mDpy) {
127 //For 8x26 external always use DMA pipe
128 type = ovutils::OV_MDP_PIPE_DMA;
129 }
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700130 ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500131 if(dest == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700132 ALOGE("%s: No pipes available to configure fb for dpy %d",
133 __FUNCTION__, mDpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500134 return false;
135 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800136 mDest = dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500137
Ramkumar Radhakrishnan1829d282013-07-23 14:54:36 -0700138 if((mDpy && ctx->deviceOrientation) &&
139 ctx->listStats[mDpy].isDisplayAnimating) {
140 fbZorder = 0;
141 }
142
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800143 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700144 ovutils::eIsFg isFg = ovutils::IS_FG_OFF;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800145 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500146
Saurabh Shah62e1d732013-09-17 10:44:05 -0700147 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800148 hwc_rect_t displayFrame = layer->displayFrame;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700149 int transform = layer->transform;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700150 int rotFlags = ovutils::ROT_FLAGS_NONE;
151
152 ovutils::eTransform orient =
153 static_cast<ovutils::eTransform>(transform);
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700154 // use ext orientation if any
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700155 int extOrient = getExtOrientation(ctx);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700156
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700157 // Do not use getNonWormholeRegion() function to calculate the
158 // sourceCrop during animation on external display and
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700159 // Dont do wormhole calculation when extorientation is set on External
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700160 // Dont do wormhole calculation when extDownscale is enabled on External
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700161 if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) {
162 sourceCrop = layer->displayFrame;
163 displayFrame = sourceCrop;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700164 } else if((!mDpy ||
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700165 (mDpy && !extOrient
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700166 && !ctx->dpyAttr[mDpy].mDownScaleMode))
167 && (extOnlyLayerIndex == -1)) {
Saurabh Shahd4e65852013-06-17 11:33:53 -0700168 if(!qdutils::MDPVersion::getInstance().is8x26()) {
169 getNonWormholeRegion(list, sourceCrop);
170 displayFrame = sourceCrop;
171 }
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800172 }
Saurabh Shah220a30c2013-10-29 16:12:12 -0700173 calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700174 transform, orient);
Ramkumar Radhakrishnan9d52f432013-05-14 14:46:59 -0700175 setMdpFlags(layer, mdpFlags, 0, transform);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700176 // For External use rotator if there is a rotation value set
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +0530177 ret = preRotateExtDisplay(ctx, layer, info,
178 sourceCrop, mdpFlags, rotFlags);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700179 if(!ret) {
180 ALOGE("%s: preRotate for external Failed!", __FUNCTION__);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800181 ctx->mOverlay->clear(mDpy);
182 ctx->mLayerRotMap[mDpy]->clear();
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700183 return false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700184 }
185 //For the mdp, since either we are pre-rotating or MDP does flips
186 orient = ovutils::OVERLAY_TRANSFORM_0;
187 transform = 0;
188 ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400189 static_cast<ovutils::eRotFlags>(rotFlags),
190 ovutils::DEFAULT_PLANE_ALPHA,
191 (ovutils::eBlending)
192 getBlending(layer->blending));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500193 ret = true;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700194 if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame,
195 NULL, mDest) < 0) {
Saurabh Shahe2474082013-05-15 16:32:13 -0700196 ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800197 ctx->mLayerRotMap[mDpy]->clear();
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500198 ret = false;
199 }
200 }
201 return ret;
202}
203
Saurabh Shah88e4d272013-09-03 13:31:29 -0700204bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500205{
Saurabh Shahcf053c62012-12-13 12:32:55 -0800206 if(!mModeOn) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500207 return true;
208 }
209 bool ret = true;
210 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800211 ovutils::eDest dest = mDest;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700212 int fd = hnd->fd;
213 uint32_t offset = hnd->offset;
214 if(mRot) {
215 if(!mRot->queueBuffer(fd, offset))
216 return false;
217 fd = mRot->getDstMemId();
218 offset = mRot->getDstOffset();
219 }
220 if (!ov.queueBuffer(fd, offset, dest)) {
Amara Venkata Mastan Manoj Kumardc01a532013-01-30 18:34:56 -0800221 ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500222 ret = false;
223 }
224 return ret;
225}
226
Saurabh Shahcf053c62012-12-13 12:32:55 -0800227//================= High res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -0700228FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy):
229 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -0800230
Saurabh Shah220a30c2013-10-29 16:12:12 -0700231void FBUpdateSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800232 IFBUpdate::reset();
233 mDestLeft = ovutils::OV_INVALID;
234 mDestRight = ovutils::OV_INVALID;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700235 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800236}
237
Saurabh Shah88e4d272013-09-03 13:31:29 -0700238bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800239 int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800240 if(!ctx->mMDP.hasOverlay) {
241 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800242 __FUNCTION__);
243 return false;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800244 }
245 ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800246 mModeOn = configure(ctx, list, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800247 return mModeOn;
248}
249
250// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700251bool FBUpdateSplit::configure(hwc_context_t *ctx,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700252 hwc_display_contents_1 *list, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800253 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500254 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Saurabh Shahcf053c62012-12-13 12:32:55 -0800255 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800256 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
257 // ext only layer present..
258 if(extOnlyLayerIndex != -1) {
259 layer = &list->hwLayers[extOnlyLayerIndex];
260 layer->compositionType = HWC_OVERLAY;
261 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800262 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700263
264 ovutils::Whf info(mAlignedFBWidth,
265 mAlignedFBHeight,
266 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800267
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700268 //Request left pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700269 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
270 Overlay::MIXER_LEFT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800271 if(destL == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700272 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
273 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800274 return false;
275 }
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700276 //Request right pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700277 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
278 Overlay::MIXER_RIGHT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800279 if(destR == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700280 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
281 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800282 return false;
283 }
284
285 mDestLeft = destL;
286 mDestRight = destR;
287
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800288 ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_BLEND_FG_PREMULT;
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +0530289
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800290 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800291
Naseer Ahmed522ce662013-03-18 20:14:05 -0400292 //XXX: FB layer plane alpha is currently sent as zero from
293 //surfaceflinger
Saurabh Shahcf053c62012-12-13 12:32:55 -0800294 ovutils::PipeArgs pargL(mdpFlagsL,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800295 info,
296 zOrder,
297 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400298 ovutils::ROT_FLAGS_NONE,
299 ovutils::DEFAULT_PLANE_ALPHA,
300 (ovutils::eBlending)
301 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800302 ov.setSource(pargL, destL);
303
304 ovutils::eMdpFlags mdpFlagsR = mdpFlagsL;
305 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
306 ovutils::PipeArgs pargR(mdpFlagsR,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800307 info,
308 zOrder,
309 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400310 ovutils::ROT_FLAGS_NONE,
311 ovutils::DEFAULT_PLANE_ALPHA,
312 (ovutils::eBlending)
313 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800314 ov.setSource(pargR, destR);
315
Saurabh Shah62e1d732013-09-17 10:44:05 -0700316 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800317 hwc_rect_t displayFrame = layer->displayFrame;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700318
319 const float xres = ctx->dpyAttr[mDpy].xres;
Saurabh Shah07a8ca82013-08-06 18:45:42 -0700320 const int lSplit = getLeftSplit(ctx, mDpy);
Saurabh Shah67a38c32013-06-10 16:23:15 -0700321 const float lSplitRatio = lSplit / xres;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700322 const float lCropWidth =
323 (sourceCrop.right - sourceCrop.left) * lSplitRatio;
324
325 ovutils::Dim dcropL(
326 sourceCrop.left,
327 sourceCrop.top,
328 lCropWidth,
329 sourceCrop.bottom - sourceCrop.top);
330
Saurabh Shahcf053c62012-12-13 12:32:55 -0800331 ovutils::Dim dcropR(
Saurabh Shah67a38c32013-06-10 16:23:15 -0700332 sourceCrop.left + lCropWidth,
333 sourceCrop.top,
334 (sourceCrop.right - sourceCrop.left) - lCropWidth,
335 sourceCrop.bottom - sourceCrop.top);
336
Saurabh Shahcf053c62012-12-13 12:32:55 -0800337 ov.setCrop(dcropL, destL);
338 ov.setCrop(dcropR, destR);
339
340 int transform = layer->transform;
341 ovutils::eTransform orient =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800342 static_cast<ovutils::eTransform>(transform);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800343 ov.setTransform(orient, destL);
344 ov.setTransform(orient, destR);
345
Saurabh Shah67a38c32013-06-10 16:23:15 -0700346 const int lWidth = (lSplit - displayFrame.left);
347 const int rWidth = (displayFrame.right - lSplit);
Saurabh Shahce416f02013-04-10 13:33:09 -0700348 const int height = displayFrame.bottom - displayFrame.top;
349
Saurabh Shah67a38c32013-06-10 16:23:15 -0700350 ovutils::Dim dposL(displayFrame.left,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800351 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700352 lWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700353 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700354 ov.setPosition(dposL, destL);
Saurabh Shahce416f02013-04-10 13:33:09 -0700355
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700356 ovutils::Dim dposR(0,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800357 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700358 rWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700359 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700360 ov.setPosition(dposR, destR);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800361
362 ret = true;
363 if (!ov.commit(destL)) {
364 ALOGE("%s: commit fails for left", __FUNCTION__);
365 ret = false;
366 }
367 if (!ov.commit(destR)) {
368 ALOGE("%s: commit fails for right", __FUNCTION__);
369 ret = false;
370 }
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800371 if(ret == false) {
372 ctx->mLayerRotMap[mDpy]->clear();
373 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800374 }
375 return ret;
376}
377
Saurabh Shah88e4d272013-09-03 13:31:29 -0700378bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Saurabh Shahcf053c62012-12-13 12:32:55 -0800379{
380 if(!mModeOn) {
381 return true;
382 }
383 bool ret = true;
384 overlay::Overlay& ov = *(ctx->mOverlay);
385 ovutils::eDest destL = mDestLeft;
386 ovutils::eDest destR = mDestRight;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800387 if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) {
388 ALOGE("%s: queue failed for left of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800389 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800390 ret = false;
391 }
392 if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) {
393 ALOGE("%s: queue failed for right of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800394 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800395 ret = false;
396 }
397 return ret;
398}
399
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500400//---------------------------------------------------------------------
401}; //namespace qhwc