blob: 6bc2e75ad923e3b72bfcec77324ff715abd7cd0e [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) {
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070048 size_t size;
49 getBufferAttributes(ctx->dpyAttr[mDpy].xres,
50 ctx->dpyAttr[mDpy].yres,
Saurabh Shah220a30c2013-10-29 16:12:12 -070051 HAL_PIXEL_FORMAT_RGBA_8888,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070052 0,
Saurabh Shah220a30c2013-10-29 16:12:12 -070053 mAlignedFBWidth,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070054 mAlignedFBHeight,
55 mTileEnabled, size);
Saurabh Shah220a30c2013-10-29 16:12:12 -070056}
57
58void IFBUpdate::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080059 mModeOn = false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070060 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -080061}
62
63//================= Low res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -070064FBUpdateNonSplit::FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy):
65 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -080066
Saurabh Shah220a30c2013-10-29 16:12:12 -070067void FBUpdateNonSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080068 IFBUpdate::reset();
69 mDest = ovutils::OV_INVALID;
70}
71
Saurabh Shah88e4d272013-09-03 13:31:29 -070072bool FBUpdateNonSplit::preRotateExtDisplay(hwc_context_t *ctx,
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +053073 hwc_layer_1_t *layer,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070074 ovutils::Whf &info,
75 hwc_rect_t& sourceCrop,
76 ovutils::eMdpFlags& mdpFlags,
77 int& rotFlags)
78{
79 int extOrient = getExtOrientation(ctx);
80 ovutils::eTransform orient = static_cast<ovutils::eTransform >(extOrient);
81 if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) {
82 mRot = ctx->mRotMgr->getNext();
83 if(mRot == NULL) return false;
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -080084 // Composed FB content will have black bars, if the viewFrame of the
85 // external is different from {0, 0, fbWidth, fbHeight}, so intersect
86 // viewFrame with sourceCrop to avoid those black bars
87 sourceCrop = getIntersection(sourceCrop, ctx->mViewFrame[mDpy]);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070088 //Configure rotator for pre-rotation
89 if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) {
90 ALOGE("%s: configRotator Failed!", __FUNCTION__);
91 mRot = NULL;
92 return false;
93 }
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -080094 ctx->mLayerRotMap[mDpy]->add(layer, mRot);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070095 info.format = (mRot)->getDstFormat();
96 updateSource(orient, info, sourceCrop);
97 rotFlags |= ovutils::ROT_PREROTATED;
98 }
99 return true;
100}
101
Saurabh Shah88e4d272013-09-03 13:31:29 -0700102bool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800103 int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500104 if(!ctx->mMDP.hasOverlay) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800105 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800106 __FUNCTION__);
107 return false;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500108 }
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800109 mModeOn = configure(ctx, list, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800110 return mModeOn;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500111}
112
113// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700114bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800115 int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500116 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500117 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500118 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800119 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
120 // ext only layer present..
121 if(extOnlyLayerIndex != -1) {
122 layer = &list->hwLayers[extOnlyLayerIndex];
123 layer->compositionType = HWC_OVERLAY;
124 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500125 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700126
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700127 ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight,
128 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
129 mTileEnabled));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500130
Saurabh Shahd4e65852013-06-17 11:33:53 -0700131 //Request a pipe
132 ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY;
133 if(qdutils::MDPVersion::getInstance().is8x26() && mDpy) {
134 //For 8x26 external always use DMA pipe
135 type = ovutils::OV_MDP_PIPE_DMA;
136 }
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700137 ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500138 if(dest == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700139 ALOGE("%s: No pipes available to configure fb for dpy %d",
140 __FUNCTION__, mDpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500141 return false;
142 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800143 mDest = dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500144
Ramkumar Radhakrishnan1829d282013-07-23 14:54:36 -0700145 if((mDpy && ctx->deviceOrientation) &&
146 ctx->listStats[mDpy].isDisplayAnimating) {
147 fbZorder = 0;
148 }
149
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800150 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700151 ovutils::eIsFg isFg = ovutils::IS_FG_OFF;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800152 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500153
Saurabh Shah62e1d732013-09-17 10:44:05 -0700154 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800155 hwc_rect_t displayFrame = layer->displayFrame;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700156 int transform = layer->transform;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700157 int rotFlags = ovutils::ROT_FLAGS_NONE;
158
159 ovutils::eTransform orient =
160 static_cast<ovutils::eTransform>(transform);
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700161 // use ext orientation if any
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700162 int extOrient = getExtOrientation(ctx);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700163
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700164 // Do not use getNonWormholeRegion() function to calculate the
165 // sourceCrop during animation on external display and
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700166 // Dont do wormhole calculation when extorientation is set on External
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700167 // Dont do wormhole calculation when extDownscale is enabled on External
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700168 if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) {
169 sourceCrop = layer->displayFrame;
170 displayFrame = sourceCrop;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700171 } else if((!mDpy ||
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700172 (mDpy && !extOrient
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700173 && !ctx->dpyAttr[mDpy].mDownScaleMode))
174 && (extOnlyLayerIndex == -1)) {
Saurabh Shahd4e65852013-06-17 11:33:53 -0700175 if(!qdutils::MDPVersion::getInstance().is8x26()) {
176 getNonWormholeRegion(list, sourceCrop);
177 displayFrame = sourceCrop;
178 }
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800179 }
Saurabh Shah220a30c2013-10-29 16:12:12 -0700180 calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700181 transform, orient);
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800182 //Store the displayFrame, will be used in getDisplayViewFrame
183 ctx->dpyAttr[mDpy].mDstRect = displayFrame;
Ramkumar Radhakrishnan9d52f432013-05-14 14:46:59 -0700184 setMdpFlags(layer, mdpFlags, 0, transform);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700185 // For External use rotator if there is a rotation value set
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +0530186 ret = preRotateExtDisplay(ctx, layer, info,
187 sourceCrop, mdpFlags, rotFlags);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700188 if(!ret) {
189 ALOGE("%s: preRotate for external Failed!", __FUNCTION__);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800190 ctx->mOverlay->clear(mDpy);
191 ctx->mLayerRotMap[mDpy]->clear();
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700192 return false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700193 }
194 //For the mdp, since either we are pre-rotating or MDP does flips
195 orient = ovutils::OVERLAY_TRANSFORM_0;
196 transform = 0;
197 ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400198 static_cast<ovutils::eRotFlags>(rotFlags),
199 ovutils::DEFAULT_PLANE_ALPHA,
200 (ovutils::eBlending)
201 getBlending(layer->blending));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500202 ret = true;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700203 if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame,
204 NULL, mDest) < 0) {
Saurabh Shahe2474082013-05-15 16:32:13 -0700205 ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800206 ctx->mLayerRotMap[mDpy]->clear();
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500207 ret = false;
208 }
209 }
210 return ret;
211}
212
Saurabh Shah88e4d272013-09-03 13:31:29 -0700213bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500214{
Saurabh Shahcf053c62012-12-13 12:32:55 -0800215 if(!mModeOn) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500216 return true;
217 }
218 bool ret = true;
219 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800220 ovutils::eDest dest = mDest;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700221 int fd = hnd->fd;
222 uint32_t offset = hnd->offset;
223 if(mRot) {
224 if(!mRot->queueBuffer(fd, offset))
225 return false;
226 fd = mRot->getDstMemId();
227 offset = mRot->getDstOffset();
228 }
229 if (!ov.queueBuffer(fd, offset, dest)) {
Amara Venkata Mastan Manoj Kumardc01a532013-01-30 18:34:56 -0800230 ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500231 ret = false;
232 }
233 return ret;
234}
235
Saurabh Shahcf053c62012-12-13 12:32:55 -0800236//================= High res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -0700237FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy):
238 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -0800239
Saurabh Shah220a30c2013-10-29 16:12:12 -0700240void FBUpdateSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800241 IFBUpdate::reset();
242 mDestLeft = ovutils::OV_INVALID;
243 mDestRight = ovutils::OV_INVALID;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700244 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800245}
246
Saurabh Shah88e4d272013-09-03 13:31:29 -0700247bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800248 int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800249 if(!ctx->mMDP.hasOverlay) {
250 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800251 __FUNCTION__);
252 return false;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800253 }
254 ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800255 mModeOn = configure(ctx, list, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800256 return mModeOn;
257}
258
259// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700260bool FBUpdateSplit::configure(hwc_context_t *ctx,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700261 hwc_display_contents_1 *list, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800262 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500263 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Saurabh Shahcf053c62012-12-13 12:32:55 -0800264 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800265 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
266 // ext only layer present..
267 if(extOnlyLayerIndex != -1) {
268 layer = &list->hwLayers[extOnlyLayerIndex];
269 layer->compositionType = HWC_OVERLAY;
270 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800271 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700272
273 ovutils::Whf info(mAlignedFBWidth,
274 mAlignedFBHeight,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700275 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
276 mTileEnabled));
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700277 //Request left pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700278 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
279 Overlay::MIXER_LEFT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800280 if(destL == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700281 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
282 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800283 return false;
284 }
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700285 //Request right pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700286 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
287 Overlay::MIXER_RIGHT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800288 if(destR == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700289 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
290 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800291 return false;
292 }
293
294 mDestLeft = destL;
295 mDestRight = destR;
296
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800297 ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_BLEND_FG_PREMULT;
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +0530298
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800299 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800300
Naseer Ahmed522ce662013-03-18 20:14:05 -0400301 //XXX: FB layer plane alpha is currently sent as zero from
302 //surfaceflinger
Saurabh Shahcf053c62012-12-13 12:32:55 -0800303 ovutils::PipeArgs pargL(mdpFlagsL,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800304 info,
305 zOrder,
306 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400307 ovutils::ROT_FLAGS_NONE,
308 ovutils::DEFAULT_PLANE_ALPHA,
309 (ovutils::eBlending)
310 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800311 ov.setSource(pargL, destL);
312
313 ovutils::eMdpFlags mdpFlagsR = mdpFlagsL;
314 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
315 ovutils::PipeArgs pargR(mdpFlagsR,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800316 info,
317 zOrder,
318 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400319 ovutils::ROT_FLAGS_NONE,
320 ovutils::DEFAULT_PLANE_ALPHA,
321 (ovutils::eBlending)
322 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800323 ov.setSource(pargR, destR);
324
Saurabh Shah62e1d732013-09-17 10:44:05 -0700325 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800326 hwc_rect_t displayFrame = layer->displayFrame;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700327
328 const float xres = ctx->dpyAttr[mDpy].xres;
Saurabh Shah07a8ca82013-08-06 18:45:42 -0700329 const int lSplit = getLeftSplit(ctx, mDpy);
Saurabh Shah67a38c32013-06-10 16:23:15 -0700330 const float lSplitRatio = lSplit / xres;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700331 const float lCropWidth =
332 (sourceCrop.right - sourceCrop.left) * lSplitRatio;
333
334 ovutils::Dim dcropL(
335 sourceCrop.left,
336 sourceCrop.top,
337 lCropWidth,
338 sourceCrop.bottom - sourceCrop.top);
339
Saurabh Shahcf053c62012-12-13 12:32:55 -0800340 ovutils::Dim dcropR(
Saurabh Shah67a38c32013-06-10 16:23:15 -0700341 sourceCrop.left + lCropWidth,
342 sourceCrop.top,
343 (sourceCrop.right - sourceCrop.left) - lCropWidth,
344 sourceCrop.bottom - sourceCrop.top);
345
Saurabh Shahcf053c62012-12-13 12:32:55 -0800346 ov.setCrop(dcropL, destL);
347 ov.setCrop(dcropR, destR);
348
349 int transform = layer->transform;
350 ovutils::eTransform orient =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800351 static_cast<ovutils::eTransform>(transform);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800352 ov.setTransform(orient, destL);
353 ov.setTransform(orient, destR);
354
Saurabh Shah67a38c32013-06-10 16:23:15 -0700355 const int lWidth = (lSplit - displayFrame.left);
356 const int rWidth = (displayFrame.right - lSplit);
Saurabh Shahce416f02013-04-10 13:33:09 -0700357 const int height = displayFrame.bottom - displayFrame.top;
358
Saurabh Shah67a38c32013-06-10 16:23:15 -0700359 ovutils::Dim dposL(displayFrame.left,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800360 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700361 lWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700362 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700363 ov.setPosition(dposL, destL);
Saurabh Shahce416f02013-04-10 13:33:09 -0700364
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700365 ovutils::Dim dposR(0,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800366 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700367 rWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700368 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700369 ov.setPosition(dposR, destR);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800370
371 ret = true;
372 if (!ov.commit(destL)) {
373 ALOGE("%s: commit fails for left", __FUNCTION__);
374 ret = false;
375 }
376 if (!ov.commit(destR)) {
377 ALOGE("%s: commit fails for right", __FUNCTION__);
378 ret = false;
379 }
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800380 if(ret == false) {
381 ctx->mLayerRotMap[mDpy]->clear();
382 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800383 }
384 return ret;
385}
386
Saurabh Shah88e4d272013-09-03 13:31:29 -0700387bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Saurabh Shahcf053c62012-12-13 12:32:55 -0800388{
389 if(!mModeOn) {
390 return true;
391 }
392 bool ret = true;
393 overlay::Overlay& ov = *(ctx->mOverlay);
394 ovutils::eDest destL = mDestLeft;
395 ovutils::eDest destR = mDestRight;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800396 if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) {
397 ALOGE("%s: queue failed for left 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 if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) {
402 ALOGE("%s: queue failed for right of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800403 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800404 ret = false;
405 }
406 return ret;
407}
408
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500409//---------------------------------------------------------------------
410}; //namespace qhwc