blob: 1d226949df08af359dddcd664b31ad8535eed9bc [file] [log] [blame]
Naseer Ahmed29a26812012-06-14 00:56:20 -07001/*
2* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are
6* met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above
10* copyright notice, this list of conditions and the following
11* disclaimer in the documentation and/or other materials provided
12* with the distribution.
13* * Neither the name of Code Aurora Forum, Inc. nor the names of its
14* contributors may be used to endorse or promote products derived
15* from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30#ifndef OVERLAY_IMPL_H
31#define OVERLAY_IMPL_H
32
33#include "overlayUtils.h"
34#include "overlayRotator.h"
35
Naseer Ahmed29a26812012-06-14 00:56:20 -070036namespace overlay {
37
38// Interface only. No member, no definiton (except ~ which can
39// also be =0 with impl in cpp)
40class OverlayImplBase {
41public:
42 /* empty dtor. can be =0 with cpp impl*/
43 virtual ~OverlayImplBase() {}
44
Naseer Ahmedf48aef62012-07-20 09:05:53 -070045 /* Init pipe/rot for one dest */
46 virtual bool initPipe(RotatorBase* rot, utils::eDest dest) = 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -070047
48 /* Close pipe/rot for all specified dest */
49 virtual bool closePipe(utils::eDest dest) = 0;
50
51 /* Copy specified pipe/rot from ov passed in (used by state machine only) */
52 virtual bool copyOvPipe(OverlayImplBase* ov, utils::eDest dest) = 0;
53
Naseer Ahmedf48aef62012-07-20 09:05:53 -070054 /* Init all pipes
55 * To init just one pipe, use initPipe()
Naseer Ahmed29a26812012-06-14 00:56:20 -070056 * */
Naseer Ahmedf48aef62012-07-20 09:05:53 -070057 virtual bool init(RotatorBase* rot0,
Naseer Ahmed29a26812012-06-14 00:56:20 -070058 RotatorBase* rot1,
59 RotatorBase* rot2) = 0;
60
61 /* Close all pipes
62 * To close just one pipe, use closePipe()
63 * */
64 virtual bool close() = 0;
65
66 /*
67 * Commit changes to the overlay
68 * */
69 virtual bool commit(utils::eDest dest = utils::OV_PIPE_ALL) = 0;
70
Naseer Ahmedf48aef62012-07-20 09:05:53 -070071 /* Queue buffer with fd from an offset*/
72 virtual bool queueBuffer(int fd, uint32_t offset,
Naseer Ahmed29a26812012-06-14 00:56:20 -070073 utils::eDest dest = utils::OV_PIPE_ALL) = 0;
74
Naseer Ahmed29a26812012-06-14 00:56:20 -070075 /* Crop existing destination using Dim coordinates */
76 virtual bool setCrop(const utils::Dim& d,
77 utils::eDest dest = utils::OV_PIPE_ALL) = 0;
78
79 /* Set new position using Dim */
80 virtual bool setPosition(const utils::Dim& dim,
81 utils::eDest dest = utils::OV_PIPE_ALL) = 0;
82
83 /* Set parameters - usually needed for Rotator, but would
84 * be passed down the stack as well */
Naseer Ahmedf48aef62012-07-20 09:05:53 -070085 virtual bool setTransform(const utils::eTransform& param,
Naseer Ahmed29a26812012-06-14 00:56:20 -070086 utils::eDest dest = utils::OV_PIPE_ALL) = 0;
87
88 /* Set new source including orientation */
89 virtual bool setSource(const utils::PipeArgs[utils::MAX_PIPES],
90 utils::eDest dest = utils::OV_PIPE_ALL) = 0;
91
Naseer Ahmed29a26812012-06-14 00:56:20 -070092 /* Dump underlying state */
93 virtual void dump() const = 0;
94};
95
96class NullPipe {
97public:
Naseer Ahmedf48aef62012-07-20 09:05:53 -070098 bool init(RotatorBase* rot) { return true; }
99 bool close() { return true; }
100 bool start(const utils::PipeArgs& args) { return true; }
101 bool commit() { return true; }
102 bool setCrop(const utils::Dim& d) { return true; }
103 bool setPosition(const utils::Dim& dim) { return true; }
104 bool setTransform(const utils::eTransform& param) { return true; }
105 bool setSource(const utils::PipeArgs& args) { return true; }
106 bool queueBuffer(int fd, uint32_t offset) { return true; }
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700107 void dump() const {}
Naseer Ahmed29a26812012-06-14 00:56:20 -0700108};
109
110/*
111* Each pipe is not specific to a display (primary/external). The order in the
112* template params, will setup the priorities of the pipes.
113* */
114template <class P0, class P1=NullPipe, class P2=NullPipe>
115class OverlayImpl : public OverlayImplBase {
116public:
117 typedef P0 pipe0;
118 typedef P1 pipe1;
119 typedef P2 pipe2;
120
121 /* ctor */
122 OverlayImpl();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700123
124 /*
125 * Comments of the below functions are the same as the one
126 * in OverlayImplBase.
127 * */
128 virtual ~OverlayImpl();
129
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700130 virtual bool initPipe(RotatorBase* rot, utils::eDest dest);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700131 virtual bool closePipe(utils::eDest dest);
132 virtual bool copyOvPipe(OverlayImplBase* ov, utils::eDest dest);
133
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700134 virtual bool init(RotatorBase* rot0,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700135 RotatorBase* rot1,
136 RotatorBase* rot2);
137 virtual bool close();
138 virtual bool commit(utils::eDest dest = utils::OV_PIPE_ALL);
139 virtual bool setCrop(const utils::Dim& d,
140 utils::eDest dest = utils::OV_PIPE_ALL);
141 virtual bool setPosition(const utils::Dim& dim,
142 utils::eDest dest = utils::OV_PIPE_ALL);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700143 virtual bool setTransform(const utils::eTransform& param,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700144 utils::eDest dest = utils::OV_PIPE_ALL);
145 virtual bool setSource(const utils::PipeArgs[utils::MAX_PIPES],
146 utils::eDest dest = utils::OV_PIPE_ALL);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700147 virtual bool queueBuffer(int fd, uint32_t offset,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700148 utils::eDest dest = utils::OV_PIPE_ALL);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700149 virtual void dump() const;
150
151private:
152 P0* mPipe0;
153 P1* mPipe1;
154 P2* mPipe2;
155 // More Px here in the future as needed
156
157 /* */
158
159 /* Each Px has it's own Rotator here.
160 * will pass rotator to the lower layer in stack
161 * but only overlay is allowed to control the lifetime
162 * of the rotator instace */
163 RotatorBase* mRotP0;
164 RotatorBase* mRotP1;
165 RotatorBase* mRotP2;
166};
167
168
169
Naseer Ahmed29a26812012-06-14 00:56:20 -0700170//-----------Inlines and Template defn---------------------------------
171
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700172/**** OverlayImpl ****/
173
Naseer Ahmed29a26812012-06-14 00:56:20 -0700174template <class P0, class P1, class P2>
175OverlayImpl<P0, P1, P2>::OverlayImpl() :
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700176 mPipe0(0), mPipe1(0), mPipe2(0),
Naseer Ahmed29a26812012-06-14 00:56:20 -0700177 mRotP0(0), mRotP1(0), mRotP2(0)
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700178{
179 //Do not create a pipe here.
180 //Either initPipe can create a pipe OR
181 //copyOvPipe can assign a pipe.
182}
Naseer Ahmed29a26812012-06-14 00:56:20 -0700183
184template <class P0, class P1, class P2>
185OverlayImpl<P0, P1, P2>::~OverlayImpl()
186{
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700187 //Do not delete pipes.
188 //closePipe will close and delete.
Naseer Ahmed29a26812012-06-14 00:56:20 -0700189}
190
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700191/* Init only one pipe/rot pair per call */
Naseer Ahmed29a26812012-06-14 00:56:20 -0700192template <class P0, class P1, class P2>
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700193bool OverlayImpl<P0, P1, P2>::initPipe(RotatorBase* rot, utils::eDest dest)
Naseer Ahmed29a26812012-06-14 00:56:20 -0700194{
195 OVASSERT(rot, "%s: OverlayImpl rot is null", __FUNCTION__);
196 OVASSERT(utils::isValidDest(dest), "%s: OverlayImpl invalid dest=%d",
197 __FUNCTION__, dest);
198
Naseer Ahmed29a26812012-06-14 00:56:20 -0700199 bool ret = true;
200
201 if (utils::OV_PIPE0 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700202 ALOGE_IF(DEBUG_OVERLAY, "init pipe0");
203
Naseer Ahmed29a26812012-06-14 00:56:20 -0700204 mRotP0 = rot;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700205 ret = mRotP0->init();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700206 if(!ret) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700207 ALOGE("%s: OverlayImpl rot0 failed to init", __FUNCTION__);
208 return false;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700209 }
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700210
211 mPipe0 = new P0();
212 OVASSERT(mPipe0, "%s: OverlayImpl pipe0 is null", __FUNCTION__);
213 ret = mPipe0->init(rot);
214 if(!ret) {
215 ALOGE("%s: OverlayImpl pipe0 failed to init", __FUNCTION__);
216 return false;
217 }
218
Naseer Ahmed29a26812012-06-14 00:56:20 -0700219 return ret;
220 }
221
222 if (utils::OV_PIPE1 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700223 ALOGE_IF(DEBUG_OVERLAY, "init pipe1");
224
Naseer Ahmed29a26812012-06-14 00:56:20 -0700225 mRotP1 = rot;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700226 ret = mRotP1->init();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700227 if(!ret) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700228 ALOGE("%s: OverlayImpl rot1 failed to init", __FUNCTION__);
229 return false;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700230 }
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700231
232 mPipe1 = new P1();
233 OVASSERT(mPipe1, "%s: OverlayImpl pipe1 is null", __FUNCTION__);
234 ret = mPipe1->init(rot);
235 if(!ret) {
236 ALOGE("%s: OverlayImpl pipe1 failed to init", __FUNCTION__);
237 return false;
238 }
239
Naseer Ahmed29a26812012-06-14 00:56:20 -0700240 return ret;
241 }
242
243 if (utils::OV_PIPE2 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700244 ALOGE_IF(DEBUG_OVERLAY, "init pipe2");
245
Naseer Ahmed29a26812012-06-14 00:56:20 -0700246 mRotP2 = rot;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700247 ret = mRotP2->init();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700248 if(!ret) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700249 ALOGE("%s: OverlayImpl rot2 failed to init", __FUNCTION__);
250 return false;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700251 }
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700252
253 mPipe2 = new P2();
254 OVASSERT(mPipe2, "%s: OverlayImpl pipe2 is null", __FUNCTION__);
255 ret = mPipe2->init(rot);
256 if(!ret) {
257 ALOGE("%s: OverlayImpl pipe2 failed to init", __FUNCTION__);
258 return false;
259 }
260
Naseer Ahmed29a26812012-06-14 00:56:20 -0700261 return ret;
262 }
263
264 // Should have returned by here
265 return false;
266}
267
268/* Close pipe/rot for all specified dest */
269template <class P0, class P1, class P2>
270bool OverlayImpl<P0, P1, P2>::closePipe(utils::eDest dest)
271{
272 OVASSERT(utils::isValidDest(dest), "%s: OverlayImpl invalid dest=%d",
273 __FUNCTION__, dest);
274
275 if (utils::OV_PIPE0 & dest) {
276 // Close pipe0
277 OVASSERT(mPipe0, "%s: OverlayImpl pipe0 is null", __FUNCTION__);
278 ALOGE_IF(DEBUG_OVERLAY, "Close pipe0");
279 if (!mPipe0->close()) {
280 ALOGE("%s: OverlayImpl failed to close pipe0", __FUNCTION__);
281 return false;
282 }
283 delete mPipe0;
284 mPipe0 = 0;
285
286 // Close the rotator for pipe0
287 OVASSERT(mRotP0, "%s: OverlayImpl rot0 is null", __FUNCTION__);
288 if (!mRotP0->close()) {
289 ALOGE("%s: OverlayImpl failed to close rot for pipe0", __FUNCTION__);
290 }
291 delete mRotP0;
292 mRotP0 = 0;
293 }
294
295 if (utils::OV_PIPE1 & dest) {
296 // Close pipe1
297 OVASSERT(mPipe1, "%s: OverlayImpl pipe1 is null", __FUNCTION__);
298 ALOGE_IF(DEBUG_OVERLAY, "Close pipe1");
299 if (!mPipe1->close()) {
300 ALOGE("%s: OverlayImpl failed to close pipe1", __FUNCTION__);
301 return false;
302 }
303 delete mPipe1;
304 mPipe1 = 0;
305
306 // Close the rotator for pipe1
307 OVASSERT(mRotP1, "%s: OverlayImpl rot1 is null", __FUNCTION__);
308 if (!mRotP1->close()) {
309 ALOGE("%s: OverlayImpl failed to close rot for pipe1", __FUNCTION__);
310 }
311 delete mRotP1;
312 mRotP1 = 0;
313 }
314
315 if (utils::OV_PIPE2 & dest) {
316 // Close pipe2
317 OVASSERT(mPipe2, "%s: OverlayImpl pipe2 is null", __FUNCTION__);
318 ALOGE_IF(DEBUG_OVERLAY, "Close pipe2");
319 if (!mPipe2->close()) {
320 ALOGE("%s: OverlayImpl failed to close pipe2", __FUNCTION__);
321 return false;
322 }
323 delete mPipe2;
324 mPipe2 = 0;
325
326 // Close the rotator for pipe2
327 OVASSERT(mRotP2, "%s: OverlayImpl rot2 is null", __FUNCTION__);
328 if (!mRotP2->close()) {
329 ALOGE("%s: OverlayImpl failed to close rot for pipe2", __FUNCTION__);
330 }
331 delete mRotP2;
332 mRotP2 = 0;
333 }
334
335 return true;
336}
337
338/* Copy pipe/rot from ov for all specified dest */
339template <class P0, class P1, class P2>
340bool OverlayImpl<P0, P1, P2>::copyOvPipe(OverlayImplBase* ov,
341 utils::eDest dest)
342{
343 OVASSERT(ov, "%s: OverlayImpl ov is null", __FUNCTION__);
344 OVASSERT(utils::isValidDest(dest), "%s: OverlayImpl invalid dest=%d",
345 __FUNCTION__, dest);
346
347 OverlayImpl<P0, P1, P2>* ovimpl = static_cast<OverlayImpl<P0, P1, P2>*>(ov);
348
349 if (utils::OV_PIPE0 & dest) {
350 mPipe0 = ovimpl->mPipe0;
351 mRotP0 = ovimpl->mRotP0;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700352 ovimpl->mPipe0 = 0;
353 ovimpl->mRotP0 = 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700354 }
355
356 if (utils::OV_PIPE1 & dest) {
357 mPipe1 = ovimpl->mPipe1;
358 mRotP1 = ovimpl->mRotP1;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700359 ovimpl->mPipe1 = 0;
360 ovimpl->mRotP1 = 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700361 }
362
363 if (utils::OV_PIPE2 & dest) {
364 mPipe2 = ovimpl->mPipe2;
365 mRotP2 = ovimpl->mRotP2;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700366 ovimpl->mPipe2 = 0;
367 ovimpl->mRotP2 = 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700368 }
369
370 return true;
371}
372
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700373/* Init all pipes/rot */
Naseer Ahmed29a26812012-06-14 00:56:20 -0700374template <class P0, class P1, class P2>
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700375bool OverlayImpl<P0, P1, P2>::init(RotatorBase* rot0,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700376 RotatorBase* rot1,
377 RotatorBase* rot2)
378{
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700379 if (!this->initPipe(rot0, utils::OV_PIPE0)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700380 if (!this->close()) {
381 ALOGE("%s: failed to close at least one pipe", __FUNCTION__);
382 }
383 return false;
384 }
385
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700386 if (!this->initPipe(rot1, utils::OV_PIPE1)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700387 if (!this->close()) {
388 ALOGE("%s: failed to close at least one pipe", __FUNCTION__);
389 }
390 return false;
391 }
392
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700393 if (!this->initPipe(rot2, utils::OV_PIPE2)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700394 if (!this->close()) {
395 ALOGE("%s: failed to close at least one pipe", __FUNCTION__);
396 }
397 return false;
398 }
399
400 return true;
401}
402
403/* Close all pipes/rot */
404template <class P0, class P1, class P2>
405bool OverlayImpl<P0, P1, P2>::close()
406{
407 if (!this->closePipe(utils::OV_PIPE_ALL)) {
408 return false;
409 }
410
411 return true;
412}
413
414template <class P0, class P1, class P2>
415bool OverlayImpl<P0, P1, P2>::commit(utils::eDest dest)
416{
417 OVASSERT(mPipe0 && mPipe1 && mPipe2,
418 "%s: Pipes are null p0=%p p1=%p p2=%p",
419 __FUNCTION__, mPipe0, mPipe1, mPipe2);
420
421 if (utils::OV_PIPE0 & dest) {
422 if(!mPipe0->commit()) {
423 ALOGE("OverlayImpl p0 failed to commit");
424 return false;
425 }
426 }
427
428 if (utils::OV_PIPE1 & dest) {
429 if(!mPipe1->commit()) {
430 ALOGE("OverlayImpl p1 failed to commit");
431 return false;
432 }
433 }
434
435 if (utils::OV_PIPE2 & dest) {
436 if(!mPipe2->commit()) {
437 ALOGE("OverlayImpl p2 failed to commit");
438 return false;
439 }
440 }
441
442 return true;
443}
444
445template <class P0, class P1, class P2>
446bool OverlayImpl<P0, P1, P2>::setCrop(const utils::Dim& d, utils::eDest dest)
447{
448 OVASSERT(mPipe0 && mPipe1 && mPipe2,
449 "%s: Pipes are null p0=%p p1=%p p2=%p",
450 __FUNCTION__, mPipe0, mPipe1, mPipe2);
451
452 if (utils::OV_PIPE0 & dest) {
453 if(!mPipe0->setCrop(d)) {
454 ALOGE("OverlayImpl p0 failed to crop");
455 return false;
456 }
457 }
458
459 if (utils::OV_PIPE1 & dest) {
460 if(!mPipe1->setCrop(d)) {
461 ALOGE("OverlayImpl p1 failed to crop");
462 return false;
463 }
464 }
465
466 if (utils::OV_PIPE2 & dest) {
467 if(!mPipe2->setCrop(d)) {
468 ALOGE("OverlayImpl p2 failed to crop");
469 return false;
470 }
471 }
472
473 return true;
474}
475
476template <class P0, class P1, class P2>
477bool OverlayImpl<P0, P1, P2>::setPosition(const utils::Dim& d,
478 utils::eDest dest)
479{
480 OVASSERT(mPipe0 && mPipe1 && mPipe2,
481 "%s: Pipes are null p0=%p p1=%p p2=%p",
482 __FUNCTION__, mPipe0, mPipe1, mPipe2);
483
484 if (utils::OV_PIPE0 & dest) {
485 if(!mPipe0->setPosition(d)) {
486 ALOGE("OverlayImpl p0 failed to setpos");
487 return false;
488 }
489 }
490
491 if (utils::OV_PIPE1 & dest) {
492 if(!mPipe1->setPosition(d)) {
493 ALOGE("OverlayImpl p1 failed to setpos");
494 return false;
495 }
496 }
497
498 if (utils::OV_PIPE2 & dest) {
499 if(!mPipe2->setPosition(d)) {
500 ALOGE("OverlayImpl p2 failed to setpos");
501 return false;
502 }
503 }
504
505 return true;
506}
507
508template <class P0, class P1, class P2>
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700509bool OverlayImpl<P0, P1, P2>::setTransform(const utils::eTransform& param,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700510 utils::eDest dest)
511{
512 OVASSERT(mPipe0 && mPipe1 && mPipe2,
513 "%s: Pipes are null p0=%p p1=%p p2=%p",
514 __FUNCTION__, mPipe0, mPipe1, mPipe2);
515
516 if (utils::OV_PIPE0 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700517 if(!mPipe0->setTransform(param)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700518 ALOGE("OverlayImpl p0 failed to setparam");
519 return false;
520 }
521 }
522
523 if (utils::OV_PIPE1 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700524 if(!mPipe1->setTransform(param)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700525 ALOGE("OverlayImpl p1 failed to setparam");
526 return false;
527 }
528 }
529
530 if (utils::OV_PIPE2 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700531 if(!mPipe2->setTransform(param)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700532 ALOGE("OverlayImpl p2 failed to setparam");
533 return false;
534 }
535 }
536
537 return true;
538}
539
540template <class P0, class P1, class P2>
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700541bool OverlayImpl<P0, P1, P2>::setSource(
542 const utils::PipeArgs args[utils::MAX_PIPES],
Naseer Ahmed29a26812012-06-14 00:56:20 -0700543 utils::eDest dest)
544{
545 OVASSERT(mPipe0 && mPipe1 && mPipe2,
546 "%s: Pipes are null p0=%p p1=%p p2=%p",
547 __FUNCTION__, mPipe0, mPipe1, mPipe2);
548
549 if (utils::OV_PIPE0 & dest) {
550 if(!mPipe0->setSource(args[0])) {
551 ALOGE("OverlayImpl p0 failed to setsrc");
552 return false;
553 }
554 }
555
556 if (utils::OV_PIPE1 & dest) {
557 if(!mPipe1->setSource(args[1])) {
558 ALOGE("OverlayImpl p1 failed to setsrc");
559 return false;
560 }
561 }
562
563 if (utils::OV_PIPE2 & dest) {
564 if(!mPipe2->setSource(args[2])) {
565 ALOGE("OverlayImpl p2 failed to setsrc");
566 return false;
567 }
568 }
569
570 return true;
571}
572
573template <class P0, class P1, class P2>
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700574bool OverlayImpl<P0, P1, P2>::queueBuffer(int fd, uint32_t offset,
575 utils::eDest dest)
Naseer Ahmed29a26812012-06-14 00:56:20 -0700576{
577 OVASSERT(mPipe0 && mPipe1 && mPipe2,
578 "%s: Pipes are null p0=%p p1=%p p2=%p",
579 __FUNCTION__, mPipe0, mPipe1, mPipe2);
580
581 if (utils::OV_PIPE0 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700582 if(!mPipe0->queueBuffer(fd, offset)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700583 ALOGE("OverlayImpl p0 failed to queueBuffer");
584 return false;
585 }
586 }
587
588 if (utils::OV_PIPE1 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700589 if(!mPipe1->queueBuffer(fd, offset)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700590 ALOGE("OverlayImpl p1 failed to queueBuffer");
591 return false;
592 }
593 }
594
595 if (utils::OV_PIPE2 & dest) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700596 if(!mPipe2->queueBuffer(fd, offset)) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700597 ALOGE("OverlayImpl p2 failed to queueBuffer");
598 return false;
599 }
600 }
601
602 return true;
603}
604
605template <class P0, class P1, class P2>
Naseer Ahmed29a26812012-06-14 00:56:20 -0700606void OverlayImpl<P0, P1, P2>::dump() const
607{
608 OVASSERT(mPipe0 && mPipe1 && mPipe2,
609 "%s: Pipes are null p0=%p p1=%p p2=%p",
610 __FUNCTION__, mPipe0, mPipe1, mPipe2);
611 ALOGE("== Dump OverlayImpl dump start ROT p0 ==");
612 mRotP0->dump();
613 ALOGE("== Dump OverlayImpl dump end ROT p0 ==");
614 ALOGE("== Dump OverlayImpl dump start ROT p1 ==");
615 mRotP1->dump();
616 ALOGE("== Dump OverlayImpl dump end ROT p1 ==");
617 ALOGE("== Dump OverlayImpl dump start ROT p2 ==");
618 mRotP2->dump();
619 ALOGE("== Dump OverlayImpl dump end ROT p2 ==");
620 ALOGE("== Dump OverlayImpl dump start p0 ==");
621 mPipe0->dump();
622 ALOGE("== Dump OverlayImpl dump end p0 ==");
623 ALOGE("== Dump OverlayImpl dump start p1 ==");
624 mPipe1->dump();
625 ALOGE("== Dump OverlayImpl dump end p1 ==");
626 ALOGE("== Dump OverlayImpl dump start p2 ==");
627 mPipe2->dump();
628 ALOGE("== Dump OverlayImpl dump end p2 ==");
629}
630
631
632} // overlay
633
634#endif // OVERLAY_IMPL_H