blob: 67cca886e3124024a2131e352f60e2292ed46be8 [file] [log] [blame]
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -08003 * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved.
Naseer Ahmed31da0b12012-07-31 18:55:33 -07004 *
radhakrishna2f00c8f2013-10-21 16:49:21 +05305 * Not a Contribution.
Naseer Ahmed31da0b12012-07-31 18:55:33 -07006 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
Naseer Ahmed45a99602012-07-31 19:15:24 -070020#define DEBUG_COPYBIT 0
Naseer Ahmed72cf9762012-07-21 12:17:13 -070021#include <copybit.h>
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080022#include <utils/Timers.h>
Terence Hampson0124cc72013-04-18 23:45:56 -070023#include <mdp_version.h>
Naseer Ahmed45a99602012-07-31 19:15:24 -070024#include "hwc_copybit.h"
25#include "comptype.h"
Naseer Ahmed64b81212013-02-14 10:29:47 -050026#include "gr.h"
radhakrishna2f00c8f2013-10-21 16:49:21 +053027#include "cb_utils.h"
Ramakant Singh762ae082013-11-28 18:45:34 +053028#include "cb_swap_rect.h"
Ramakant Singh80f36f22014-02-25 14:11:35 +053029#include "math.h"
Saurabh Shah74eff4d2014-03-28 16:33:13 -070030#include "sync/sync.h"
31
radhakrishna2f00c8f2013-10-21 16:49:21 +053032using namespace qdutils;
Naseer Ahmed31da0b12012-07-31 18:55:33 -070033namespace qhwc {
34
Naseer Ahmed31da0b12012-07-31 18:55:33 -070035struct range {
36 int current;
37 int end;
38};
39struct region_iterator : public copybit_region_t {
40
41 region_iterator(hwc_region_t region) {
42 mRegion = region;
Praveena Pachipulusud9443c72014-02-17 10:42:28 +053043 r.end = (int)region.numRects;
Naseer Ahmed31da0b12012-07-31 18:55:33 -070044 r.current = 0;
45 this->next = iterate;
46 }
47
48private:
49 static int iterate(copybit_region_t const * self, copybit_rect_t* rect){
50 if (!self || !rect) {
51 ALOGE("iterate invalid parameters");
52 return 0;
53 }
54
55 region_iterator const* me =
56 static_cast<region_iterator const*>(self);
57 if (me->r.current != me->r.end) {
58 rect->l = me->mRegion.rects[me->r.current].left;
59 rect->t = me->mRegion.rects[me->r.current].top;
60 rect->r = me->mRegion.rects[me->r.current].right;
61 rect->b = me->mRegion.rects[me->r.current].bottom;
62 me->r.current++;
63 return 1;
64 }
65 return 0;
66 }
67
68 hwc_region_t mRegion;
69 mutable range r;
70};
71
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080072void CopyBit::reset() {
73 mIsModeOn = false;
74 mCopyBitDraw = false;
Naseer Ahmed31da0b12012-07-31 18:55:33 -070075}
76
Naseer Ahmed45a99602012-07-31 19:15:24 -070077bool CopyBit::canUseCopybitForYUV(hwc_context_t *ctx) {
78 // return true for non-overlay targets
Terence Hampsond0fd5792013-05-29 11:56:52 -040079 if(ctx->mMDP.hasOverlay && ctx->mMDP.version >= qdutils::MDP_V4_0) {
Naseer Ahmed45a99602012-07-31 19:15:24 -070080 return false;
Naseer Ahmed31da0b12012-07-31 18:55:33 -070081 }
82 return true;
83}
Naseer Ahmed45a99602012-07-31 19:15:24 -070084
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080085bool CopyBit::canUseCopybitForRGB(hwc_context_t *ctx,
86 hwc_display_contents_1_t *list,
87 int dpy) {
88 int compositionType = qdutils::QCCompositionType::
89 getInstance().getCompositionType();
Naseer Ahmed45a99602012-07-31 19:15:24 -070090
Naseer Ahmed45a99602012-07-31 19:15:24 -070091 if (compositionType & qdutils::COMPOSITION_TYPE_DYN) {
92 // DYN Composition:
Prabhanjan Kandula73030ba2013-03-15 22:33:39 +053093 // use copybit, if (TotalRGBRenderArea < threashold * FB Area)
Naseer Ahmed45a99602012-07-31 19:15:24 -070094 // this is done based on perf inputs in ICS
95 // TODO: Above condition needs to be re-evaluated in JB
Arun Kumar K.R361da4f2012-11-28 10:42:59 -080096 int fbWidth = ctx->dpyAttr[dpy].xres;
97 int fbHeight = ctx->dpyAttr[dpy].yres;
98 unsigned int fbArea = (fbWidth * fbHeight);
Dileep Kumar Reddi4070e932014-09-30 09:00:57 +053099 unsigned int renderArea = getRGBRenderingArea(ctx, list);
Naseer Ahmed45a99602012-07-31 19:15:24 -0700100 ALOGD_IF (DEBUG_COPYBIT, "%s:renderArea %u, fbArea %u",
101 __FUNCTION__, renderArea, fbArea);
Prabhanjan Kandula73030ba2013-03-15 22:33:39 +0530102 if (renderArea < (mDynThreshold * fbArea)) {
Naseer Ahmed45a99602012-07-31 19:15:24 -0700103 return true;
104 }
105 } else if ((compositionType & qdutils::COMPOSITION_TYPE_MDP)) {
106 // MDP composition, use COPYBIT always
107 return true;
108 } else if ((compositionType & qdutils::COMPOSITION_TYPE_C2D)) {
109 // C2D composition, use COPYBIT
110 return true;
111 }
112 return false;
113}
114
Dileep Kumar Reddi4070e932014-09-30 09:00:57 +0530115unsigned int CopyBit::getRGBRenderingArea (const hwc_context_t *ctx,
116 const hwc_display_contents_1_t *list) {
Naseer Ahmed45a99602012-07-31 19:15:24 -0700117 //Calculates total rendering area for RGB layers
118 unsigned int renderArea = 0;
119 unsigned int w=0, h=0;
Terence Hampsonef379d42013-05-21 10:38:01 -0400120 // Skipping last layer since FrameBuffer layer should not affect
121 // which composition to choose
122 for (unsigned int i=0; i<list->numHwLayers -1; i++) {
Naseer Ahmed45a99602012-07-31 19:15:24 -0700123 private_handle_t *hnd = (private_handle_t *)list->hwLayers[i].handle;
124 if (hnd) {
Dileep Kumar Reddi4070e932014-09-30 09:00:57 +0530125 if (BUFFER_TYPE_UI == hnd->bufferType && !ctx->copybitDrop[i]) {
Naseer Ahmed45a99602012-07-31 19:15:24 -0700126 getLayerResolution(&list->hwLayers[i], w, h);
127 renderArea += (w*h);
128 }
129 }
130 }
131 return renderArea;
132}
133
Ramakant Singh21cec722014-03-07 19:11:45 +0530134int CopyBit::getLayersChanging(hwc_context_t *ctx,
135 hwc_display_contents_1_t *list,
136 int dpy){
137
138 int changingLayerIndex = -1;
139 if(mLayerCache.layerCount != ctx->listStats[dpy].numAppLayers) {
140 mLayerCache.reset();
141 mFbCache.reset();
142 mLayerCache.updateCounts(ctx,list,dpy);
143 return -1;
144 }
145
146 int updatingLayerCount = 0;
147 for (int k = ctx->listStats[dpy].numAppLayers-1; k >= 0 ; k--){
148 //swap rect will kick in only for single updating layer
149 if(mLayerCache.hnd[k] != list->hwLayers[k].handle){
150 updatingLayerCount ++;
151 if(updatingLayerCount == 1)
152 changingLayerIndex = k;
153 }
154 }
155 //since we are using more than one framebuffers,we have to
156 //kick in swap rect only if we are getting continuous same
157 //dirty rect for same layer at least equal of number of
158 //framebuffers
159
160 if ( updatingLayerCount == 1 ) {
Saurabh Shah93c69052014-04-24 10:27:10 -0700161 hwc_rect_t dirtyRect = list->hwLayers[changingLayerIndex].displayFrame;
162#ifdef QCOM_BSP
163 dirtyRect = list->hwLayers[changingLayerIndex].dirtyRect;
164#endif
Ramakant Singh21cec722014-03-07 19:11:45 +0530165
166 for (int k = ctx->listStats[dpy].numAppLayers-1; k >= 0 ; k--){
167 //disable swap rect for overlapping visible layer(s)
168 hwc_rect_t displayFrame = list->hwLayers[k].displayFrame;
169 hwc_rect_t result = getIntersection(displayFrame,dirtyRect);
170 if((k != changingLayerIndex) && isValidRect(result)){
171 return -1;
172 }
173 }
174 mFbCache.insertAndUpdateFbCache(dirtyRect);
175 if(mFbCache.getUnchangedFbDRCount(dirtyRect) <
176 NUM_RENDER_BUFFERS)
177 changingLayerIndex = -1;
178 }else {
179 mFbCache.reset();
180 changingLayerIndex = -1;
181 }
182 mLayerCache.updateCounts(ctx,list,dpy);
183 return changingLayerIndex;
184}
185
186int CopyBit::checkDirtyRect(hwc_context_t *ctx,
187 hwc_display_contents_1_t *list,
188 int dpy) {
189
190 //dirty rect will enable only if
191 //1.Only single layer is updating.
192 //2.No overlapping
193 //3.No scaling
194 //4.No video layer
195 if(mSwapRectEnable == false)
196 return -1;
197 int changingLayerIndex = getLayersChanging(ctx, list, dpy);
198 //swap rect will kick in only for single updating layer
199 if(changingLayerIndex == -1){
200 return -1;
201 }
202 if(!needsScaling(&list->hwLayers[changingLayerIndex])){
203 private_handle_t *hnd =
204 (private_handle_t *)list->hwLayers[changingLayerIndex].handle;
205 if( hnd && !isYuvBuffer(hnd))
206 return changingLayerIndex;
207 }
208 return -1;
209}
210
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700211bool CopyBit::prepareOverlap(hwc_context_t *ctx,
212 hwc_display_contents_1_t *list) {
Sushil Chauhandefd3522014-05-13 18:17:12 -0700213
214 if (ctx->mMDP.version < qdutils::MDP_V4_0) {
215 ALOGE("%s: Invalid request", __FUNCTION__);
216 return false;
217 }
218
219 if (mEngine == NULL || !(validateParams(ctx, list))) {
220 ALOGE("%s: Invalid Params", __FUNCTION__);
221 return false;
222 }
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700223 PtorInfo* ptorInfo = &(ctx->mPtorInfo);
Sushil Chauhandefd3522014-05-13 18:17:12 -0700224
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700225 // Allocate render buffers if they're not allocated
226 int alignW = 0, alignH = 0;
227 int finalW = 0, finalH = 0;
228 for (int i = 0; i < ptorInfo->count; i++) {
229 int ovlapIndex = ptorInfo->layerIndex[i];
230 hwc_rect_t overlap = list->hwLayers[ovlapIndex].displayFrame;
231 // render buffer width will be the max of two layers
232 // Align Widht and height to 32, Mdp would be configured
233 // with Aligned overlap w/h
234 finalW = max(finalW, ALIGN((overlap.right - overlap.left), 32));
235 finalH += ALIGN((overlap.bottom - overlap.top), 32);
236 if(finalH > ALIGN((overlap.bottom - overlap.top), 32)) {
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700237 // Calculate the dest top, left will always be zero
238 ptorInfo->displayFrame[i].top = (finalH -
239 (ALIGN((overlap.bottom - overlap.top), 32)));
240 }
241 // calculate the right and bottom values
242 ptorInfo->displayFrame[i].right = ptorInfo->displayFrame[i].left +
243 (overlap.right - overlap.left);
244 ptorInfo->displayFrame[i].bottom = ptorInfo->displayFrame[i].top +
245 (overlap.bottom - overlap.top);
246 }
Sushil Chauhandefd3522014-05-13 18:17:12 -0700247
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700248 getBufferSizeAndDimensions(finalW, finalH, HAL_PIXEL_FORMAT_RGBA_8888,
Sushil Chauhandefd3522014-05-13 18:17:12 -0700249 alignW, alignH);
250
251 if ((mAlignedWidth != alignW) || (mAlignedHeight != alignH)) {
252 // Overlap rect has changed, so free render buffers
253 freeRenderBuffers();
254 }
255
256 int ret = allocRenderBuffers(alignW, alignH, HAL_PIXEL_FORMAT_RGBA_8888);
257
258 if (ret < 0) {
259 ALOGE("%s: Render buffer allocation failed", __FUNCTION__);
260 return false;
261 }
262
263 mAlignedWidth = alignW;
264 mAlignedHeight = alignH;
265 mCurRenderBufferIndex = (mCurRenderBufferIndex + 1) % NUM_RENDER_BUFFERS;
266 return true;
267}
268
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800269bool CopyBit::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list,
270 int dpy) {
Naseer Ahmed45a99602012-07-31 19:15:24 -0700271
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800272 if(mEngine == NULL) {
273 // No copybit device found - cannot use copybit
274 return false;
275 }
Dileep Kumar Reddia25a9182014-07-24 20:01:44 +0530276
277 if(ctx->mThermalBurstMode) {
278 ALOGD_IF (DEBUG_COPYBIT, "%s:Copybit failed,"
279 "Running in Thermal Burst mode",__FUNCTION__);
280 return false;
281 }
282
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800283 int compositionType = qdutils::QCCompositionType::
284 getInstance().getCompositionType();
Naseer Ahmed45a99602012-07-31 19:15:24 -0700285
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800286 if ((compositionType == qdutils::COMPOSITION_TYPE_GPU) ||
287 (compositionType == qdutils::COMPOSITION_TYPE_CPU)) {
Naseer Ahmed45a99602012-07-31 19:15:24 -0700288 //GPU/CPU composition, don't change layer composition type
289 return true;
290 }
291
Naseer Ahmed45a99602012-07-31 19:15:24 -0700292 if(!(validateParams(ctx, list))) {
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800293 ALOGE("%s:Invalid Params", __FUNCTION__);
294 return false;
Naseer Ahmed45a99602012-07-31 19:15:24 -0700295 }
296
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800297 if(ctx->listStats[dpy].skipCount) {
298 //GPU will be anyways used
299 return false;
300 }
301
Ramkumar Radhakrishnane661f962013-06-05 17:21:38 -0700302 if (ctx->listStats[dpy].numAppLayers > MAX_NUM_APP_LAYERS) {
Sushil Chauhanb00f59d2013-04-29 18:35:54 -0700303 // Reached max layers supported by HWC.
304 return false;
305 }
306
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800307 bool useCopybitForYUV = canUseCopybitForYUV(ctx);
308 bool useCopybitForRGB = canUseCopybitForRGB(ctx, list, dpy);
Naseer Ahmed64b81212013-02-14 10:29:47 -0500309 LayerProp *layerProp = ctx->layerProp[dpy];
Naseer Ahmed64b81212013-02-14 10:29:47 -0500310
Radhika Ranjan Soni46cf4e92013-08-06 16:40:05 +0530311 // Following are MDP3 limitations for which we
312 // need to fallback to GPU composition:
Terence Hampsonb1021932013-09-18 11:15:19 -0400313 // 1. Plane alpha is not supported by MDP3.
Terence Hampson6b0a4272013-11-06 16:04:51 -0500314 // 2. Scaling is within range
Terence Hampsonc235bda2013-07-12 12:47:38 -0400315 if (qdutils::MDPVersion::getInstance().getMDPVersion() < 400) {
316 for (int i = ctx->listStats[dpy].numAppLayers-1; i >= 0 ; i--) {
Terence Hampson6b0a4272013-11-06 16:04:51 -0500317 int dst_h, dst_w, src_h, src_w;
318 float dx, dy;
Dileep Kumar Reddi4070e932014-09-30 09:00:57 +0530319 if(ctx->copybitDrop[i]) {
320 continue;
321 }
Terence Hampsonc235bda2013-07-12 12:47:38 -0400322 hwc_layer_1_t *layer = (hwc_layer_1_t *) &list->hwLayers[i];
Radhika Ranjan Soni46cf4e92013-08-06 16:40:05 +0530323 if (layer->planeAlpha != 0xFF)
324 return true;
Ramakant Singhf2b51e62013-11-28 12:07:51 +0530325 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Terence Hampson6b0a4272013-11-06 16:04:51 -0500326
Sushil Chauhanfda00fc2014-03-20 11:08:41 -0700327 if (has90Transform(layer)) {
Ramakant Singhf2b51e62013-11-28 12:07:51 +0530328 src_h = sourceCrop.right - sourceCrop.left;
329 src_w = sourceCrop.bottom - sourceCrop.top;
Terence Hampson6b0a4272013-11-06 16:04:51 -0500330 } else {
Ramakant Singhf2b51e62013-11-28 12:07:51 +0530331 src_h = sourceCrop.bottom - sourceCrop.top;
332 src_w = sourceCrop.right - sourceCrop.left;
Terence Hampson6b0a4272013-11-06 16:04:51 -0500333 }
334 dst_h = layer->displayFrame.bottom - layer->displayFrame.top;
335 dst_w = layer->displayFrame.right - layer->displayFrame.left;
336
Ramakant Singh0b35f2c2014-01-07 11:25:48 +0530337 if(src_w <=0 || src_h<=0 ||dst_w<=0 || dst_h<=0 ) {
338 ALOGE("%s: wrong params for display screen_w=%d \
339 src_crop_width=%d screen_h=%d src_crop_height=%d",
340 __FUNCTION__, dst_w,src_w,dst_h,src_h);
341 return false;
342 }
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530343 dx = (float)dst_w/(float)src_w;
344 dy = (float)dst_h/(float)src_h;
Ramakant Singh0b35f2c2014-01-07 11:25:48 +0530345
Terence Hampson6b0a4272013-11-06 16:04:51 -0500346 if (dx > MAX_SCALE_FACTOR || dx < MIN_SCALE_FACTOR)
347 return false;
348
349 if (dy > MAX_SCALE_FACTOR || dy < MIN_SCALE_FACTOR)
350 return false;
Terence Hampsonc235bda2013-07-12 12:47:38 -0400351 }
352 }
Naseer Ahmed64b81212013-02-14 10:29:47 -0500353
354 //Allocate render buffers if they're not allocated
Ramakant Singhb4106a12014-10-07 18:06:56 +0530355 if ((ctx->mMDP.version != qdutils::MDP_V3_0_4 &&
356 ctx->mMDP.version != qdutils::MDP_V3_0_5) &&
Terence Hampsonc67b0372013-10-09 11:32:21 -0400357 (useCopybitForYUV || useCopybitForRGB)) {
Sushil Chauhandefd3522014-05-13 18:17:12 -0700358 int ret = allocRenderBuffers(mAlignedWidth,
359 mAlignedHeight,
Saurabh Shah220a30c2013-10-29 16:12:12 -0700360 HAL_PIXEL_FORMAT_RGBA_8888);
Naseer Ahmed64b81212013-02-14 10:29:47 -0500361 if (ret < 0) {
362 return false;
363 } else {
364 mCurRenderBufferIndex = (mCurRenderBufferIndex + 1) %
365 NUM_RENDER_BUFFERS;
366 }
367 }
368
Terence Hampsond0fd5792013-05-29 11:56:52 -0400369 // We cannot mix copybit layer with layers marked to be drawn on FB
370 if (!useCopybitForYUV && ctx->listStats[dpy].yuvCount)
371 return true;
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800372
Radhika Ranjan Soni14f6c4b2013-08-28 17:04:49 +0530373 mCopyBitDraw = false;
374 if (useCopybitForRGB &&
375 (useCopybitForYUV || !ctx->listStats[dpy].yuvCount)) {
376 mCopyBitDraw = true;
377 // numAppLayers-1, as we iterate till 0th layer index
378 // Mark all layers to be drawn by copybit
379 for (int i = ctx->listStats[dpy].numAppLayers-1; i >= 0 ; i--) {
Naseer Ahmed64b81212013-02-14 10:29:47 -0500380 layerProp[i].mFlags |= HWC_COPYBIT;
Saurabh Shah74eff4d2014-03-28 16:33:13 -0700381#ifdef QCOM_BSP
Ramakant Singhb4106a12014-10-07 18:06:56 +0530382 if (ctx->mMDP.version == qdutils::MDP_V3_0_4 ||
383 ctx->mMDP.version == qdutils::MDP_V3_0_5)
Terence Hampsonc67b0372013-10-09 11:32:21 -0400384 list->hwLayers[i].compositionType = HWC_BLIT;
385 else
Saurabh Shah74eff4d2014-03-28 16:33:13 -0700386#endif
Terence Hampsonc67b0372013-10-09 11:32:21 -0400387 list->hwLayers[i].compositionType = HWC_OVERLAY;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700388 }
389 }
Radhika Ranjan Soni14f6c4b2013-08-28 17:04:49 +0530390
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700391 return true;
392}
393
Naseer Ahmed183939d2013-03-14 20:44:17 -0400394int CopyBit::clear (private_handle_t* hnd, hwc_rect_t& rect)
395{
396 int ret = 0;
397 copybit_rect_t clear_rect = {rect.left, rect.top,
398 rect.right,
399 rect.bottom};
400
401 copybit_image_t buf;
Ramkumar Radhakrishnan92f3abe2013-06-05 13:52:40 -0700402 buf.w = ALIGN(getWidth(hnd),32);
403 buf.h = getHeight(hnd);
Naseer Ahmed183939d2013-03-14 20:44:17 -0400404 buf.format = hnd->format;
405 buf.base = (void *)hnd->base;
406 buf.handle = (native_handle_t *)hnd;
407
408 copybit_device_t *copybit = mEngine;
409 ret = copybit->clear(copybit, &buf, &clear_rect);
410 return ret;
411}
412
Ramakant Singh0def28c2014-03-28 20:43:13 +0530413bool CopyBit::drawUsingAppBufferComposition(hwc_context_t *ctx,
414 hwc_display_contents_1_t *list,
Ramakant Singh467759f2014-04-16 11:09:40 +0530415 int dpy, int *copybitFd) {
416 int layerCount = 0;
Shalaj Jaina70b4352014-06-15 13:47:47 -0700417 uint32_t last = (uint32_t)list->numHwLayers - 1;
Ramakant Singh467759f2014-04-16 11:09:40 +0530418 hwc_layer_1_t *fbLayer = &list->hwLayers[last];
419 private_handle_t *fbhnd = (private_handle_t *)fbLayer->handle;
Ramakant Singh0def28c2014-03-28 20:43:13 +0530420
421 if(ctx->enableABC == false)
422 return false;
423
Ramakant Singh467759f2014-04-16 11:09:40 +0530424 if(ctx->listStats[dpy].numAppLayers > MAX_LAYERS_FOR_ABC )
Ramakant Singh0def28c2014-03-28 20:43:13 +0530425 return false;
426
427 layerCount = ctx->listStats[dpy].numAppLayers;
428 //bottom most layer should
429 //equal to FB
430 hwc_layer_1_t *tmpLayer = &list->hwLayers[0];
431 private_handle_t *hnd = (private_handle_t *)tmpLayer->handle;
432 if(hnd && fbhnd && (hnd->size == fbhnd->size) &&
433 (hnd->width == fbhnd->width) && (hnd->height == fbhnd->height)){
434 if(tmpLayer->transform ||
435 (!(hnd->format == HAL_PIXEL_FORMAT_RGBA_8888 ||
436 hnd->format == HAL_PIXEL_FORMAT_RGBX_8888)) ||
437 (needsScaling(tmpLayer) == true)) {
438 return false;
439 }else {
440 ctx->listStats[dpy].renderBufIndexforABC = 0;
441 }
442 }
443
Ramakant Singh467759f2014-04-16 11:09:40 +0530444 if(ctx->listStats[dpy].renderBufIndexforABC == 0) {
445 if(layerCount == 1)
Ramakant Singh0def28c2014-03-28 20:43:13 +0530446 return true;
Ramakant Singh467759f2014-04-16 11:09:40 +0530447
Ramakant Singhcc326612014-06-19 14:19:18 +0530448 if(layerCount == MAX_LAYERS_FOR_ABC) {
Ramakant Singh467759f2014-04-16 11:09:40 +0530449 int abcRenderBufIdx = ctx->listStats[dpy].renderBufIndexforABC;
Ramakant Singhcc326612014-06-19 14:19:18 +0530450 //enable ABC only for non intersecting layers.
451 hwc_rect_t displayFrame =
452 list->hwLayers[abcRenderBufIdx].displayFrame;
453 for (int i = abcRenderBufIdx + 1; i < layerCount; i++) {
454 hwc_rect_t tmpDisplayFrame = list->hwLayers[i].displayFrame;
455 hwc_rect_t result = getIntersection(displayFrame,tmpDisplayFrame);
456 if (isValidRect(result)) {
457 ctx->listStats[dpy].renderBufIndexforABC = -1;
458 return false;
459 }
460 }
461 // Pass the Acquire Fence FD to driver for base layer
Ramakant Singh467759f2014-04-16 11:09:40 +0530462 private_handle_t *renderBuffer =
463 (private_handle_t *)list->hwLayers[abcRenderBufIdx].handle;
464 copybit_device_t *copybit = getCopyBitDevice();
465 if(list->hwLayers[abcRenderBufIdx].acquireFenceFd >=0){
466 copybit->set_sync(copybit,
467 list->hwLayers[abcRenderBufIdx].acquireFenceFd);
468 }
Ramakant Singhcc326612014-06-19 14:19:18 +0530469 for(int i = abcRenderBufIdx + 1; i < layerCount; i++){
Ramakant Singh467759f2014-04-16 11:09:40 +0530470 int retVal = drawLayerUsingCopybit(ctx,
471 &(list->hwLayers[i]),renderBuffer, 0);
472 if(retVal < 0) {
473 ALOGE("%s : Copybit failed", __FUNCTION__);
474 }
475 }
476 // Get Release Fence FD of copybit for the App layer(s)
477 copybit->flush_get_fence(copybit, copybitFd);
478 close(list->hwLayers[abcRenderBufIdx].acquireFenceFd);
479 list->hwLayers[abcRenderBufIdx].acquireFenceFd = -1;
480 return true;
481 }
Ramakant Singh0def28c2014-03-28 20:43:13 +0530482 }
483 return false;
484}
485
486bool CopyBit::draw(hwc_context_t *ctx, hwc_display_contents_1_t *list,
487 int dpy, int32_t *fd) {
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800488 // draw layers marked for COPYBIT
489 int retVal = true;
490 int copybitLayerCount = 0;
Terence Hampsonc67b0372013-10-09 11:32:21 -0400491 uint32_t last = 0;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500492 LayerProp *layerProp = ctx->layerProp[dpy];
Terence Hampsonc67b0372013-10-09 11:32:21 -0400493 private_handle_t *renderBuffer;
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800494
Ramakant Singh21cec722014-03-07 19:11:45 +0530495 if(mCopyBitDraw == false){
496 mFbCache.reset(); // there is no layer marked for copybit
497 return false ;
498 }
Ramakant Singh0def28c2014-03-28 20:43:13 +0530499
Ramakant Singh467759f2014-04-16 11:09:40 +0530500 if(drawUsingAppBufferComposition(ctx, list, dpy, fd)) {
Ramakant Singh0def28c2014-03-28 20:43:13 +0530501 return true;
502 }
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800503 //render buffer
Ramakant Singhb4106a12014-10-07 18:06:56 +0530504 if (ctx->mMDP.version == qdutils::MDP_V3_0_4 ||
505 ctx->mMDP.version == qdutils::MDP_V3_0_5) {
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530506 last = (uint32_t)list->numHwLayers - 1;
Terence Hampsonc67b0372013-10-09 11:32:21 -0400507 renderBuffer = (private_handle_t *)list->hwLayers[last].handle;
508 } else {
509 renderBuffer = getCurrentRenderBuffer();
510 }
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800511 if (!renderBuffer) {
Naseer Ahmed64b81212013-02-14 10:29:47 -0500512 ALOGE("%s: Render buffer layer handle is NULL", __FUNCTION__);
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800513 return false;
514 }
Naseer Ahmed64b81212013-02-14 10:29:47 -0500515
Terence Hampson0124cc72013-04-18 23:45:56 -0700516 if (ctx->mMDP.version >= qdutils::MDP_V4_0) {
Terence Hampson65fe4522013-10-17 17:40:03 -0400517 //Wait for the previous frame to complete before rendering onto it
Prabhanjan Kandula5719da42013-11-01 00:14:04 +0530518 if(mRelFd[mCurRenderBufferIndex] >=0) {
519 sync_wait(mRelFd[mCurRenderBufferIndex], 1000);
520 close(mRelFd[mCurRenderBufferIndex]);
521 mRelFd[mCurRenderBufferIndex] = -1;
Terence Hampson65fe4522013-10-17 17:40:03 -0400522 }
Terence Hampson65fe4522013-10-17 17:40:03 -0400523 } else {
Terence Hampsonc67b0372013-10-09 11:32:21 -0400524 if(list->hwLayers[last].acquireFenceFd >=0) {
Terence Hampson65fe4522013-10-17 17:40:03 -0400525 copybit_device_t *copybit = getCopyBitDevice();
Terence Hampsonc67b0372013-10-09 11:32:21 -0400526 copybit->set_sync(copybit, list->hwLayers[last].acquireFenceFd);
Terence Hampson65fe4522013-10-17 17:40:03 -0400527 }
Terence Hampson0124cc72013-04-18 23:45:56 -0700528 }
radhakrishna2f00c8f2013-10-21 16:49:21 +0530529
Ramakant Singh21cec722014-03-07 19:11:45 +0530530 mDirtyLayerIndex = checkDirtyRect(ctx, list, dpy);
531 if( mDirtyLayerIndex != -1){
532 hwc_layer_1_t *layer = &list->hwLayers[mDirtyLayerIndex];
Saurabh Shah93c69052014-04-24 10:27:10 -0700533#ifdef QCOM_BSP
Ramakant Singh21cec722014-03-07 19:11:45 +0530534 clear(renderBuffer,layer->dirtyRect);
Saurabh Shah93c69052014-04-24 10:27:10 -0700535#else
536 clear(renderBuffer,layer->displayFrame);
537#endif
Ramakant Singh21cec722014-03-07 19:11:45 +0530538 } else {
539 hwc_rect_t clearRegion = {0,0,0,0};
540 if(CBUtils::getuiClearRegion(list, clearRegion, layerProp))
541 clear(renderBuffer, clearRegion);
542 }
radhakrishna2f00c8f2013-10-21 16:49:21 +0530543
Naseer Ahmed64b81212013-02-14 10:29:47 -0500544 // numAppLayers-1, as we iterate from 0th layer index with HWC_COPYBIT flag
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800545 for (int i = 0; i <= (ctx->listStats[dpy].numAppLayers-1); i++) {
Naseer Ahmed64b81212013-02-14 10:29:47 -0500546 if(!(layerProp[i].mFlags & HWC_COPYBIT)) {
547 ALOGD_IF(DEBUG_COPYBIT, "%s: Not Marked for copybit", __FUNCTION__);
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800548 continue;
549 }
Dileep Kumar Reddi4070e932014-09-30 09:00:57 +0530550 if(ctx->copybitDrop[i]) {
551 continue;
552 }
Ramakant Singh21cec722014-03-07 19:11:45 +0530553 //skip non updating layers
554 if((mDirtyLayerIndex != -1) && (mDirtyLayerIndex != i) )
Ramakant Singh762ae082013-11-28 18:45:34 +0530555 continue;
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800556 int ret = -1;
Terence Hampsonadf47302013-05-23 12:21:02 -0400557 if (list->hwLayers[i].acquireFenceFd != -1
558 && ctx->mMDP.version >= qdutils::MDP_V4_0) {
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800559 // Wait for acquire Fence on the App buffers.
560 ret = sync_wait(list->hwLayers[i].acquireFenceFd, 1000);
561 if(ret < 0) {
562 ALOGE("%s: sync_wait error!! error no = %d err str = %s",
563 __FUNCTION__, errno, strerror(errno));
564 }
565 close(list->hwLayers[i].acquireFenceFd);
566 list->hwLayers[i].acquireFenceFd = -1;
567 }
568 retVal = drawLayerUsingCopybit(ctx, &(list->hwLayers[i]),
Ramakant Singh21cec722014-03-07 19:11:45 +0530569 renderBuffer, !i);
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800570 copybitLayerCount++;
571 if(retVal < 0) {
572 ALOGE("%s : drawLayerUsingCopybit failed", __FUNCTION__);
573 }
574 }
575
576 if (copybitLayerCount) {
577 copybit_device_t *copybit = getCopyBitDevice();
578 // Async mode
579 copybit->flush_get_fence(copybit, fd);
Ramakant Singhb4106a12014-10-07 18:06:56 +0530580 if((ctx->mMDP.version == qdutils::MDP_V3_0_4 ||
581 ctx->mMDP.version == qdutils::MDP_V3_0_5) &&
Terence Hampsonc67b0372013-10-09 11:32:21 -0400582 list->hwLayers[last].acquireFenceFd >= 0) {
583 close(list->hwLayers[last].acquireFenceFd);
584 list->hwLayers[last].acquireFenceFd = -1;
Terence Hampson65fe4522013-10-17 17:40:03 -0400585 }
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800586 }
587 return true;
588}
589
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700590int CopyBit::drawOverlap(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
Sushil Chauhandefd3522014-05-13 18:17:12 -0700591 int fd = -1;
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700592 PtorInfo* ptorInfo = &(ctx->mPtorInfo);
Sushil Chauhandefd3522014-05-13 18:17:12 -0700593
594 if (ctx->mMDP.version < qdutils::MDP_V4_0) {
595 ALOGE("%s: Invalid request", __FUNCTION__);
596 return fd;
597 }
598
599 private_handle_t *renderBuffer = getCurrentRenderBuffer();
600
601 if (!renderBuffer) {
602 ALOGE("%s: Render buffer layer handle is NULL", __FUNCTION__);
603 return fd;
604 }
605
606 int copybitLayerCount = 0;
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700607 for(int j = 0; j < ptorInfo->count; j++) {
608 int ovlapIndex = ptorInfo->layerIndex[j];
609 hwc_rect_t overlap = list->hwLayers[ovlapIndex].displayFrame;
Prabhanjan Kandula9889a202014-09-04 21:50:35 +0530610 if(j) {
611 /**
612 * It's possible that 2 PTOR layers might have overlapping.
613 * In such case, remove the intersection(again if peripheral)
614 * from the lower PTOR layer to avoid overlapping.
615 * If intersection is not on peripheral then compromise
616 * by reducing number of PTOR layers.
617 **/
618 int prevOvlapIndex = ptorInfo->layerIndex[0];
619 hwc_rect_t prevOvlap = list->hwLayers[prevOvlapIndex].displayFrame;
620 hwc_rect_t commonRect = getIntersection(prevOvlap, overlap);
621 if(isValidRect(commonRect)) {
622 overlap = deductRect(overlap, commonRect);
623 }
624 }
Sushil Chauhandefd3522014-05-13 18:17:12 -0700625
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700626 // Draw overlapped content of layers on render buffer
627 for (int i = 0; i <= ovlapIndex; i++) {
628 hwc_layer_1_t *layer = &list->hwLayers[i];
629 if(!isValidRect(getIntersection(layer->displayFrame,
630 overlap))) {
631 continue;
Sushil Chauhandefd3522014-05-13 18:17:12 -0700632 }
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700633 if ((list->hwLayers[i].acquireFenceFd != -1)) {
634 // Wait for acquire fence on the App buffers.
635 if(sync_wait(list->hwLayers[i].acquireFenceFd, 1000) < 0) {
636 ALOGE("%s: sync_wait error!! error no = %d err str = %s",
637 __FUNCTION__, errno, strerror(errno));
638 }
639 close(list->hwLayers[i].acquireFenceFd);
640 list->hwLayers[i].acquireFenceFd = -1;
641 }
Sushil Chauhandefd3522014-05-13 18:17:12 -0700642
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700643 int retVal = drawRectUsingCopybit(ctx, layer, renderBuffer, overlap,
644 ptorInfo->displayFrame[j]);
645 copybitLayerCount++;
646 if(retVal < 0) {
647 ALOGE("%s: drawRectUsingCopybit failed", __FUNCTION__);
648 copybitLayerCount = 0;
649 }
Sushil Chauhandefd3522014-05-13 18:17:12 -0700650 }
651 }
652
653 if (copybitLayerCount) {
654 copybit_device_t *copybit = getCopyBitDevice();
655 copybit->flush_get_fence(copybit, &fd);
656 }
657
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700658 ALOGD_IF(DEBUG_COPYBIT, "%s: done! copybitLayerCount = %d", __FUNCTION__,
659 copybitLayerCount);
Sushil Chauhandefd3522014-05-13 18:17:12 -0700660 return fd;
661}
662
663int CopyBit::drawRectUsingCopybit(hwc_context_t *dev, hwc_layer_1_t *layer,
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700664 private_handle_t *renderBuffer, hwc_rect_t overlap,
665 hwc_rect_t destRect)
Sushil Chauhandefd3522014-05-13 18:17:12 -0700666{
667 hwc_context_t* ctx = (hwc_context_t*)(dev);
668 if (!ctx) {
669 ALOGE("%s: null context ", __FUNCTION__);
670 return -1;
671 }
672
673 private_handle_t *hnd = (private_handle_t *)layer->handle;
674 if (!hnd) {
675 ALOGE("%s: invalid handle", __FUNCTION__);
676 return -1;
677 }
678
679 private_handle_t *dstHandle = (private_handle_t *)renderBuffer;
680 if (!dstHandle) {
681 ALOGE("%s: RenderBuffer handle is NULL", __FUNCTION__);
682 return -1;
683 }
684
685 // Set the Copybit Source
686 copybit_image_t src;
687 src.handle = (native_handle_t *)layer->handle;
688 src.w = hnd->width;
689 src.h = hnd->height;
690 src.base = (void *)hnd->base;
691 src.format = hnd->format;
692 src.horiz_padding = 0;
693 src.vert_padding = 0;
694
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700695
Sushil Chauhandefd3522014-05-13 18:17:12 -0700696 hwc_rect_t dispFrame = layer->displayFrame;
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700697 hwc_rect_t iRect = getIntersection(dispFrame, overlap);
Sushil Chauhandefd3522014-05-13 18:17:12 -0700698 hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700699 qhwc::calculate_crop_rects(crop, dispFrame, iRect,
700 layer->transform);
Sushil Chauhandefd3522014-05-13 18:17:12 -0700701
702 // Copybit source rect
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700703 copybit_rect_t srcRect = {crop.left, crop.top, crop.right,
704 crop.bottom};
Sushil Chauhandefd3522014-05-13 18:17:12 -0700705
706 // Copybit destination rect
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700707 copybit_rect_t dstRect = {destRect.left, destRect.top, destRect.right,
708 destRect.bottom};
Sushil Chauhandefd3522014-05-13 18:17:12 -0700709
710 // Copybit dst
711 copybit_image_t dst;
712 dst.handle = (native_handle_t *)dstHandle;
713 dst.w = ALIGN(dstHandle->width, 32);
714 dst.h = dstHandle->height;
715 dst.base = (void *)dstHandle->base;
716 dst.format = dstHandle->format;
717
718 copybit_device_t *copybit = mEngine;
719
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700720 // Copybit region is the destRect
721 hwc_rect_t regRect = {dstRect.l,dstRect.t, dstRect.r, dstRect.b};
722 hwc_region_t region;
723 region.numRects = 1;
724 region.rects = &regRect;
Sushil Chauhandefd3522014-05-13 18:17:12 -0700725 region_iterator copybitRegion(region);
726 int acquireFd = layer->acquireFenceFd;
727
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700728 copybit->set_parameter(copybit, COPYBIT_FRAMEBUFFER_WIDTH,
729 renderBuffer->width);
730 copybit->set_parameter(copybit, COPYBIT_FRAMEBUFFER_HEIGHT,
731 renderBuffer->height);
Sushil Chauhandefd3522014-05-13 18:17:12 -0700732 copybit->set_parameter(copybit, COPYBIT_TRANSFORM, layer->transform);
733 copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, layer->planeAlpha);
734 copybit->set_parameter(copybit, COPYBIT_BLEND_MODE, layer->blending);
735 copybit->set_parameter(copybit, COPYBIT_DITHER,
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700736 (dst.format == HAL_PIXEL_FORMAT_RGB_565) ? COPYBIT_ENABLE :
737 COPYBIT_DISABLE);
Sushil Chauhandefd3522014-05-13 18:17:12 -0700738 copybit->set_sync(copybit, acquireFd);
Arun Kumar K.Rb2a03b12014-06-03 11:54:10 -0700739 int err = copybit->stretch(copybit, &dst, &src, &dstRect, &srcRect,
740 &copybitRegion);
Sushil Chauhandefd3522014-05-13 18:17:12 -0700741
742 if (err < 0)
743 ALOGE("%s: copybit stretch failed",__FUNCTION__);
744
745 return err;
746}
747
Naseer Ahmed5b6708a2012-08-02 13:46:08 -0700748int CopyBit::drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_1_t *layer,
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -0800749 private_handle_t *renderBuffer, bool isFG)
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700750{
751 hwc_context_t* ctx = (hwc_context_t*)(dev);
Terence Hampsonadf47302013-05-23 12:21:02 -0400752 int err = 0, acquireFd;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700753 if(!ctx) {
754 ALOGE("%s: null context ", __FUNCTION__);
755 return -1;
756 }
757
758 private_handle_t *hnd = (private_handle_t *)layer->handle;
759 if(!hnd) {
Sushil Chauhan943797c2013-10-21 17:35:55 -0700760 if (layer->flags & HWC_COLOR_FILL) { // Color layer
761 return fillColorUsingCopybit(layer, renderBuffer);
762 }
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700763 ALOGE("%s: invalid handle", __FUNCTION__);
764 return -1;
765 }
766
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800767 private_handle_t *fbHandle = (private_handle_t *)renderBuffer;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700768 if(!fbHandle) {
769 ALOGE("%s: Framebuffer handle is NULL", __FUNCTION__);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700770 return -1;
771 }
772
773 // Set the copybit source:
774 copybit_image_t src;
Ramkumar Radhakrishnan92f3abe2013-06-05 13:52:40 -0700775 src.w = getWidth(hnd);
776 src.h = getHeight(hnd);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700777 src.format = hnd->format;
Sushil Chauhan1f6d68f2013-10-11 11:49:35 -0700778
779 // Handle R/B swap
780 if ((layer->flags & HWC_FORMAT_RB_SWAP)) {
781 if (src.format == HAL_PIXEL_FORMAT_RGBA_8888) {
782 src.format = HAL_PIXEL_FORMAT_BGRA_8888;
783 } else if (src.format == HAL_PIXEL_FORMAT_RGBX_8888) {
784 src.format = HAL_PIXEL_FORMAT_BGRX_8888;
785 }
786 }
787
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700788 src.base = (void *)hnd->base;
789 src.handle = (native_handle_t *)layer->handle;
Ramkumar Radhakrishnan92f3abe2013-06-05 13:52:40 -0700790 src.horiz_padding = src.w - getWidth(hnd);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700791 // Initialize vertical padding to zero for now,
792 // this needs to change to accomodate vertical stride
793 // if needed in the future
794 src.vert_padding = 0;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700795
shuoy7c101f92013-08-26 14:48:57 +0800796 int layerTransform = layer->transform ;
797 // When flip and rotation(90) are present alter the flip,
798 // as GPU is doing the flip and rotation in opposite order
799 // to that of MDP3.0
800 // For 270 degrees, we get 90 + (H+V) which is same as doing
801 // flip first and then rotation (H+V) + 90
802 if (qdutils::MDPVersion::getInstance().getMDPVersion() < 400) {
803 if (((layer->transform& HAL_TRANSFORM_FLIP_H) ||
804 (layer->transform & HAL_TRANSFORM_FLIP_V)) &&
805 (layer->transform & HAL_TRANSFORM_ROT_90) &&
806 !(layer->transform == HAL_TRANSFORM_ROT_270)){
807 if(layer->transform & HAL_TRANSFORM_FLIP_H){
808 layerTransform ^= HAL_TRANSFORM_FLIP_H;
809 layerTransform |= HAL_TRANSFORM_FLIP_V;
810 }
811 if(layer->transform & HAL_TRANSFORM_FLIP_V){
812 layerTransform ^= HAL_TRANSFORM_FLIP_V;
813 layerTransform |= HAL_TRANSFORM_FLIP_H;
814 }
815 }
816 }
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700817 // Copybit source rect
Saurabh Shah62e1d732013-09-17 10:44:05 -0700818 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700819 copybit_rect_t srcRect = {sourceCrop.left, sourceCrop.top,
820 sourceCrop.right,
821 sourceCrop.bottom};
822
823 // Copybit destination rect
824 hwc_rect_t displayFrame = layer->displayFrame;
825 copybit_rect_t dstRect = {displayFrame.left, displayFrame.top,
826 displayFrame.right,
827 displayFrame.bottom};
Saurabh Shah93c69052014-04-24 10:27:10 -0700828#ifdef QCOM_BSP
Ramakant Singh21cec722014-03-07 19:11:45 +0530829 //change src and dst with dirtyRect
830 if(mDirtyLayerIndex != -1) {
831 srcRect.l = layer->dirtyRect.left;
832 srcRect.t = layer->dirtyRect.top;
833 srcRect.r = layer->dirtyRect.right;
834 srcRect.b = layer->dirtyRect.bottom;
835 dstRect = srcRect;
836 }
Saurabh Shah93c69052014-04-24 10:27:10 -0700837#endif
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700838 // Copybit dst
839 copybit_image_t dst;
840 dst.w = ALIGN(fbHandle->width,32);
841 dst.h = fbHandle->height;
842 dst.format = fbHandle->format;
843 dst.base = (void *)fbHandle->base;
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800844 dst.handle = (native_handle_t *)fbHandle;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700845
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800846 copybit_device_t *copybit = mEngine;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700847
848 int32_t screen_w = displayFrame.right - displayFrame.left;
849 int32_t screen_h = displayFrame.bottom - displayFrame.top;
850 int32_t src_crop_width = sourceCrop.right - sourceCrop.left;
851 int32_t src_crop_height = sourceCrop.bottom -sourceCrop.top;
852
853 // Copybit dst
854 float copybitsMaxScale =
855 (float)copybit->get(copybit,COPYBIT_MAGNIFICATION_LIMIT);
856 float copybitsMinScale =
857 (float)copybit->get(copybit,COPYBIT_MINIFICATION_LIMIT);
858
Sushil Chauhandffbf432013-12-09 15:33:57 -0800859 if (layer->transform & HWC_TRANSFORM_ROT_90) {
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700860 //swap screen width and height
861 int tmp = screen_w;
862 screen_w = screen_h;
863 screen_h = tmp;
864 }
865 private_handle_t *tmpHnd = NULL;
866
867 if(screen_w <=0 || screen_h<=0 ||src_crop_width<=0 || src_crop_height<=0 ) {
868 ALOGE("%s: wrong params for display screen_w=%d src_crop_width=%d \
Ramakant Singh0b35f2c2014-01-07 11:25:48 +0530869 screen_h=%d src_crop_height=%d", __FUNCTION__, screen_w,
870 src_crop_width,screen_h,src_crop_height);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700871 return -1;
872 }
873
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530874 float dsdx = (float)screen_w/(float)src_crop_width;
875 float dtdy = (float)screen_h/(float)src_crop_height;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700876
877 float scaleLimitMax = copybitsMaxScale * copybitsMaxScale;
878 float scaleLimitMin = copybitsMinScale * copybitsMinScale;
879 if(dsdx > scaleLimitMax ||
880 dtdy > scaleLimitMax ||
881 dsdx < 1/scaleLimitMin ||
882 dtdy < 1/scaleLimitMin) {
Terence Hampson3c560b92013-09-03 16:58:02 -0400883 ALOGW("%s: greater than max supported size dsdx=%f dtdy=%f \
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700884 scaleLimitMax=%f scaleLimitMin=%f", __FUNCTION__,dsdx,dtdy,
885 scaleLimitMax,1/scaleLimitMin);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700886 return -1;
887 }
Terence Hampsonadf47302013-05-23 12:21:02 -0400888 acquireFd = layer->acquireFenceFd;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700889 if(dsdx > copybitsMaxScale ||
890 dtdy > copybitsMaxScale ||
891 dsdx < 1/copybitsMinScale ||
892 dtdy < 1/copybitsMinScale){
893 // The requested scale is out of the range the hardware
894 // can support.
Terence Hampson663dfa72013-08-08 12:35:41 -0400895 ALOGD("%s:%d::Need to scale twice dsdx=%f, dtdy=%f,copybitsMaxScale=%f,\
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700896 copybitsMinScale=%f,screen_w=%d,screen_h=%d \
897 src_crop_width=%d src_crop_height=%d",__FUNCTION__,__LINE__,
898 dsdx,dtdy,copybitsMaxScale,1/copybitsMinScale,screen_w,screen_h,
899 src_crop_width,src_crop_height);
900
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700901
902 int tmp_w = src_crop_width;
903 int tmp_h = src_crop_height;
904
905 if (dsdx > copybitsMaxScale || dtdy > copybitsMaxScale ){
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530906 tmp_w = (int)((float)src_crop_width*copybitsMaxScale);
907 tmp_h = (int)((float)src_crop_height*copybitsMaxScale);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700908 }else if (dsdx < 1/copybitsMinScale ||dtdy < 1/copybitsMinScale ){
Ramakant Singh80f36f22014-02-25 14:11:35 +0530909 // ceil the tmp_w and tmp_h value to maintain proper ratio
910 // b/w src and dst (should not cross the desired scale limit
911 // due to float -> int )
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530912 tmp_w = (int)ceil((float)src_crop_width/copybitsMinScale);
913 tmp_h = (int)ceil((float)src_crop_height/copybitsMinScale);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700914 }
Terence Hampson663dfa72013-08-08 12:35:41 -0400915 ALOGD("%s:%d::tmp_w = %d,tmp_h = %d",__FUNCTION__,__LINE__,tmp_w,tmp_h);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700916
Naseer Ahmed64b81212013-02-14 10:29:47 -0500917 int usage = GRALLOC_USAGE_PRIVATE_IOMMU_HEAP;
Terence Hampsonb6a123a2013-07-18 11:54:16 -0400918 int format = fbHandle->format;
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700919
Terence Hampsonb6a123a2013-07-18 11:54:16 -0400920 // We do not want copybit to generate alpha values from nothing
921 if (format == HAL_PIXEL_FORMAT_RGBA_8888 &&
922 src.format != HAL_PIXEL_FORMAT_RGBA_8888) {
923 format = HAL_PIXEL_FORMAT_RGBX_8888;
924 }
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800925 if (0 == alloc_buffer(&tmpHnd, tmp_w, tmp_h, format, usage) && tmpHnd) {
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700926 copybit_image_t tmp_dst;
927 copybit_rect_t tmp_rect;
928 tmp_dst.w = tmp_w;
929 tmp_dst.h = tmp_h;
930 tmp_dst.format = tmpHnd->format;
931 tmp_dst.handle = tmpHnd;
932 tmp_dst.horiz_padding = src.horiz_padding;
933 tmp_dst.vert_padding = src.vert_padding;
934 tmp_rect.l = 0;
935 tmp_rect.t = 0;
936 tmp_rect.r = tmp_dst.w;
937 tmp_rect.b = tmp_dst.h;
938 //create one clip region
939 hwc_rect tmp_hwc_rect = {0,0,tmp_rect.r,tmp_rect.b};
940 hwc_region_t tmp_hwc_reg = {1,(hwc_rect_t const*)&tmp_hwc_rect};
941 region_iterator tmp_it(tmp_hwc_reg);
942 copybit->set_parameter(copybit,COPYBIT_TRANSFORM,0);
Naseer Ahmed45a99602012-07-31 19:15:24 -0700943 //TODO: once, we are able to read layer alpha, update this
944 copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 255);
Terence Hampsonadf47302013-05-23 12:21:02 -0400945 copybit->set_sync(copybit, acquireFd);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700946 err = copybit->stretch(copybit,&tmp_dst, &src, &tmp_rect,
947 &srcRect, &tmp_it);
948 if(err < 0){
949 ALOGE("%s:%d::tmp copybit stretch failed",__FUNCTION__,
950 __LINE__);
951 if(tmpHnd)
952 free_buffer(tmpHnd);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700953 return err;
954 }
Terence Hampsonadf47302013-05-23 12:21:02 -0400955 // use release fence as aquire fd for next stretch
Terence Hampson1d8db6f2013-07-17 11:05:36 -0400956 if (ctx->mMDP.version < qdutils::MDP_V4_0) {
Terence Hampsonadf47302013-05-23 12:21:02 -0400957 copybit->flush_get_fence(copybit, &acquireFd);
Terence Hampson1d8db6f2013-07-17 11:05:36 -0400958 close(acquireFd);
959 acquireFd = -1;
960 }
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700961 // copy new src and src rect crop
962 src = tmp_dst;
963 srcRect = tmp_rect;
964 }
965 }
966 // Copybit region
967 hwc_region_t region = layer->visibleRegionScreen;
968 region_iterator copybitRegion(region);
969
970 copybit->set_parameter(copybit, COPYBIT_FRAMEBUFFER_WIDTH,
971 renderBuffer->width);
972 copybit->set_parameter(copybit, COPYBIT_FRAMEBUFFER_HEIGHT,
973 renderBuffer->height);
974 copybit->set_parameter(copybit, COPYBIT_TRANSFORM,
shuoy7c101f92013-08-26 14:48:57 +0800975 layerTransform);
Naseer Ahmed45a99602012-07-31 19:15:24 -0700976 //TODO: once, we are able to read layer alpha, update this
977 copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 255);
Arun Kumar K.R361da4f2012-11-28 10:42:59 -0800978 copybit->set_parameter(copybit, COPYBIT_BLEND_MODE,
979 layer->blending);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700980 copybit->set_parameter(copybit, COPYBIT_DITHER,
981 (dst.format == HAL_PIXEL_FORMAT_RGB_565)?
982 COPYBIT_ENABLE : COPYBIT_DISABLE);
Shivaraj Shettye86506a2013-08-06 12:56:30 +0530983 copybit->set_parameter(copybit, COPYBIT_FG_LAYER, isFG ?
984 COPYBIT_ENABLE : COPYBIT_DISABLE);
985
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700986 copybit->set_parameter(copybit, COPYBIT_BLIT_TO_FRAMEBUFFER,
987 COPYBIT_ENABLE);
Terence Hampsonadf47302013-05-23 12:21:02 -0400988 copybit->set_sync(copybit, acquireFd);
Naseer Ahmed31da0b12012-07-31 18:55:33 -0700989 err = copybit->stretch(copybit, &dst, &src, &dstRect, &srcRect,
990 &copybitRegion);
991 copybit->set_parameter(copybit, COPYBIT_BLIT_TO_FRAMEBUFFER,
992 COPYBIT_DISABLE);
993
Terence Hampsonadf47302013-05-23 12:21:02 -0400994 if(tmpHnd) {
995 if (ctx->mMDP.version < qdutils::MDP_V4_0){
996 int ret = -1, releaseFd;
997 // we need to wait for the buffer before freeing
998 copybit->flush_get_fence(copybit, &releaseFd);
999 ret = sync_wait(releaseFd, 1000);
1000 if(ret < 0) {
1001 ALOGE("%s: sync_wait error!! error no = %d err str = %s",
1002 __FUNCTION__, errno, strerror(errno));
1003 }
1004 close(releaseFd);
1005 }
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001006 free_buffer(tmpHnd);
Terence Hampsonadf47302013-05-23 12:21:02 -04001007 }
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001008
1009 if(err < 0)
1010 ALOGE("%s: copybit stretch failed",__FUNCTION__);
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001011 return err;
1012}
1013
Sushil Chauhan943797c2013-10-21 17:35:55 -07001014int CopyBit::fillColorUsingCopybit(hwc_layer_1_t *layer,
1015 private_handle_t *renderBuffer)
1016{
1017 if (!renderBuffer) {
1018 ALOGE("%s: Render Buffer is NULL", __FUNCTION__);
1019 return -1;
1020 }
1021
1022 // Copybit dst
1023 copybit_image_t dst;
1024 dst.w = ALIGN(renderBuffer->width, 32);
1025 dst.h = renderBuffer->height;
1026 dst.format = renderBuffer->format;
1027 dst.base = (void *)renderBuffer->base;
1028 dst.handle = (native_handle_t *)renderBuffer;
1029
1030 // Copybit dst rect
1031 hwc_rect_t displayFrame = layer->displayFrame;
1032 copybit_rect_t dstRect = {displayFrame.left, displayFrame.top,
1033 displayFrame.right, displayFrame.bottom};
1034
1035 uint32_t color = layer->transform;
1036 copybit_device_t *copybit = mEngine;
1037 copybit->set_parameter(copybit, COPYBIT_FRAMEBUFFER_WIDTH,
1038 renderBuffer->width);
1039 copybit->set_parameter(copybit, COPYBIT_FRAMEBUFFER_HEIGHT,
1040 renderBuffer->height);
1041 copybit->set_parameter(copybit, COPYBIT_DITHER,
1042 (dst.format == HAL_PIXEL_FORMAT_RGB_565) ?
1043 COPYBIT_ENABLE : COPYBIT_DISABLE);
Sushil Chauhan2babecc2013-12-04 17:29:48 -08001044 copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
Sushil Chauhan943797c2013-10-21 17:35:55 -07001045 copybit->set_parameter(copybit, COPYBIT_BLEND_MODE, layer->blending);
1046 copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, layer->planeAlpha);
1047 copybit->set_parameter(copybit, COPYBIT_BLIT_TO_FRAMEBUFFER,COPYBIT_ENABLE);
1048 int res = copybit->fill_color(copybit, &dst, &dstRect, color);
1049 copybit->set_parameter(copybit,COPYBIT_BLIT_TO_FRAMEBUFFER,COPYBIT_DISABLE);
1050 return res;
1051}
1052
Naseer Ahmed5b6708a2012-08-02 13:46:08 -07001053void CopyBit::getLayerResolution(const hwc_layer_1_t* layer,
Naseer Ahmed45a99602012-07-31 19:15:24 -07001054 unsigned int& width, unsigned int& height)
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001055{
1056 hwc_rect_t displayFrame = layer->displayFrame;
1057
1058 width = displayFrame.right - displayFrame.left;
1059 height = displayFrame.bottom - displayFrame.top;
1060}
1061
Arun Kumar K.R361da4f2012-11-28 10:42:59 -08001062bool CopyBit::validateParams(hwc_context_t *ctx,
1063 const hwc_display_contents_1_t *list) {
1064 //Validate parameters
1065 if (!ctx) {
1066 ALOGE("%s:Invalid HWC context", __FUNCTION__);
1067 return false;
1068 } else if (!list) {
1069 ALOGE("%s:Invalid HWC layer list", __FUNCTION__);
1070 return false;
1071 }
1072 return true;
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001073}
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001074
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001075
Naseer Ahmed64b81212013-02-14 10:29:47 -05001076int CopyBit::allocRenderBuffers(int w, int h, int f)
1077{
1078 int ret = 0;
1079 for (int i = 0; i < NUM_RENDER_BUFFERS; i++) {
1080 if (mRenderBuffer[i] == NULL) {
1081 ret = alloc_buffer(&mRenderBuffer[i],
1082 w, h, f,
1083 GRALLOC_USAGE_PRIVATE_IOMMU_HEAP);
1084 }
1085 if(ret < 0) {
1086 freeRenderBuffers();
1087 break;
1088 }
1089 }
1090 return ret;
1091}
1092
1093void CopyBit::freeRenderBuffers()
1094{
1095 for (int i = 0; i < NUM_RENDER_BUFFERS; i++) {
1096 if(mRenderBuffer[i]) {
Prabhanjan Kandula5719da42013-11-01 00:14:04 +05301097 //Since we are freeing buffer close the fence if it has a valid one.
1098 if(mRelFd[i] >= 0) {
1099 close(mRelFd[i]);
1100 mRelFd[i] = -1;
1101 }
Naseer Ahmed64b81212013-02-14 10:29:47 -05001102 free_buffer(mRenderBuffer[i]);
1103 mRenderBuffer[i] = NULL;
1104 }
1105 }
1106}
1107
1108private_handle_t * CopyBit::getCurrentRenderBuffer() {
1109 return mRenderBuffer[mCurRenderBufferIndex];
1110}
1111
1112void CopyBit::setReleaseFd(int fd) {
Prabhanjan Kandula5719da42013-11-01 00:14:04 +05301113 if(mRelFd[mCurRenderBufferIndex] >=0)
1114 close(mRelFd[mCurRenderBufferIndex]);
1115 mRelFd[mCurRenderBufferIndex] = dup(fd);
Naseer Ahmed64b81212013-02-14 10:29:47 -05001116}
1117
Sushil Chauhandefd3522014-05-13 18:17:12 -07001118void CopyBit::setReleaseFdSync(int fd) {
1119 if (mRelFd[mCurRenderBufferIndex] >=0) {
1120 int ret = -1;
1121 ret = sync_wait(mRelFd[mCurRenderBufferIndex], 1000);
1122 if (ret < 0)
1123 ALOGE("%s: sync_wait error! errno = %d, err str = %s",
1124 __FUNCTION__, errno, strerror(errno));
1125 close(mRelFd[mCurRenderBufferIndex]);
1126 }
1127 mRelFd[mCurRenderBufferIndex] = dup(fd);
1128}
1129
Arun Kumar K.R361da4f2012-11-28 10:42:59 -08001130struct copybit_device_t* CopyBit::getCopyBitDevice() {
1131 return mEngine;
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001132}
1133
Shalaj Jaina70b4352014-06-15 13:47:47 -07001134CopyBit::CopyBit(hwc_context_t *ctx, const int& dpy) : mEngine(0),
1135 mIsModeOn(false), mCopyBitDraw(false), mCurRenderBufferIndex(0) {
Saurabh Shah220a30c2013-10-29 16:12:12 -07001136
1137 getBufferSizeAndDimensions(ctx->dpyAttr[dpy].xres,
1138 ctx->dpyAttr[dpy].yres,
1139 HAL_PIXEL_FORMAT_RGBA_8888,
Sushil Chauhandefd3522014-05-13 18:17:12 -07001140 mAlignedWidth,
1141 mAlignedHeight);
Saurabh Shah220a30c2013-10-29 16:12:12 -07001142
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001143 hw_module_t const *module;
Prabhanjan Kandula5719da42013-11-01 00:14:04 +05301144 for (int i = 0; i < NUM_RENDER_BUFFERS; i++) {
Naseer Ahmed64b81212013-02-14 10:29:47 -05001145 mRenderBuffer[i] = NULL;
Prabhanjan Kandula5719da42013-11-01 00:14:04 +05301146 mRelFd[i] = -1;
1147 }
Prabhanjan Kandula73030ba2013-03-15 22:33:39 +05301148
1149 char value[PROPERTY_VALUE_MAX];
1150 property_get("debug.hwc.dynThreshold", value, "2");
1151 mDynThreshold = atof(value);
1152
Ramakant Singh21cec722014-03-07 19:11:45 +05301153 property_get("debug.sf.swaprect", value, "0");
1154 mSwapRectEnable = atoi(value) ? true:false ;
1155 mDirtyLayerIndex = -1;
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001156 if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0) {
Arun Kumar K.R361da4f2012-11-28 10:42:59 -08001157 if(copybit_open(module, &mEngine) < 0) {
1158 ALOGE("FATAL ERROR: copybit open failed.");
1159 }
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001160 } else {
Arun Kumar K.R361da4f2012-11-28 10:42:59 -08001161 ALOGE("FATAL ERROR: copybit hw module not found");
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001162 }
1163}
Saurabh Shah661a58f2012-08-30 15:30:49 -07001164
Arun Kumar K.R361da4f2012-11-28 10:42:59 -08001165CopyBit::~CopyBit()
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001166{
Naseer Ahmed64b81212013-02-14 10:29:47 -05001167 freeRenderBuffers();
Arun Kumar K.R361da4f2012-11-28 10:42:59 -08001168 if(mEngine)
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001169 {
Arun Kumar K.R361da4f2012-11-28 10:42:59 -08001170 copybit_close(mEngine);
1171 mEngine = NULL;
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001172 }
1173}
Ramakant Singh21cec722014-03-07 19:11:45 +05301174CopyBit::LayerCache::LayerCache() {
1175 reset();
1176}
1177void CopyBit::LayerCache::reset() {
1178 memset(&hnd, 0, sizeof(hnd));
1179 layerCount = 0;
1180}
1181void CopyBit::LayerCache::updateCounts(hwc_context_t *ctx,
1182 hwc_display_contents_1_t *list, int dpy)
1183{
1184 layerCount = ctx->listStats[dpy].numAppLayers;
1185 for (int i=0; i<ctx->listStats[dpy].numAppLayers; i++){
1186 hnd[i] = list->hwLayers[i].handle;
1187 }
1188}
1189
1190CopyBit::FbCache::FbCache() {
1191 reset();
1192}
1193void CopyBit::FbCache::reset() {
1194 memset(&FbdirtyRect, 0, sizeof(FbdirtyRect));
1195 FbIndex =0;
1196}
1197
1198void CopyBit::FbCache::insertAndUpdateFbCache(hwc_rect_t dirtyRect) {
1199 FbIndex = FbIndex % NUM_RENDER_BUFFERS;
1200 FbdirtyRect[FbIndex] = dirtyRect;
1201 FbIndex++;
1202}
1203
1204int CopyBit::FbCache::getUnchangedFbDRCount(hwc_rect_t dirtyRect){
1205 int sameDirtyCount = 0;
1206 for (int i = 0 ; i < NUM_RENDER_BUFFERS ; i++ ){
1207 if( FbdirtyRect[i] == dirtyRect)
1208 sameDirtyCount++;
1209 }
1210 return sameDirtyCount;
1211}
1212
Naseer Ahmed31da0b12012-07-31 18:55:33 -07001213}; //namespace qhwc