blob: 1d13a2e855a809bfa17ec18a64ee96f8ff06ddad [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_STATE_H
31#define OVERLAY_STATE_H
32
33#include "overlayUtils.h"
34#include "overlayImpl.h"
35#include "overlayRotator.h"
36#include "pipes/overlayGenPipe.h"
37#include "pipes/overlayBypassPipe.h"
38#include "pipes/overlayHdmiPipe.h"
39#include "pipes/overlayUIMirrorPipe.h"
40#include "pipes/overlay3DPipe.h"
41
42// FIXME make int to be uint32 whenever possible
43
44namespace overlay {
45
46/*
47* Used by Overlay class. Invokes each event
48* */
49
50/* TODO case of RGBx will call mOv open with diff
51* params customized for RGBx pipes */
52
53class OverlayState : utils::NoCopy {
54public:
55 /**/
56 explicit OverlayState();
57
58 /**/
59 ~OverlayState();
60
61 /* return current state */
62 utils::eOverlayState state() const;
63
64 /* Overlay Event */
65
66 /* Hard reset to a new state. If the state is the same
67 * as the current one, it would be a no-op */
68 OverlayImplBase* reset(utils::eOverlayState s);
69
70 /* Caller pass the state to the handleEvent function.
71 * The input is the current OverlayImplBase*, and output is
72 * a pointer to (possibly new) instance of OverlayImplBase
73 * The eFormat can be 2D/3D etc. */
74 OverlayImplBase* handleEvent(utils::eOverlayState s,
75 OverlayImplBase* ov);
76
77 /* Transitions from XXX to XXX */
78 OverlayImplBase* handle_closed(utils::eOverlayState s);
79 OverlayImplBase* handle_2D_2DPanel(utils::eOverlayState s,
80 OverlayImplBase* ov);
81 OverlayImplBase* handle_2D_2DTV(utils::eOverlayState s,
82 OverlayImplBase* ov);
83 OverlayImplBase* handle_3D_2DPanel(utils::eOverlayState s,
84 OverlayImplBase* ov);
85 OverlayImplBase* handle_3D_3DPanel(utils::eOverlayState s,
86 OverlayImplBase* ov);
87 OverlayImplBase* handle_3D_3DTV(utils::eOverlayState s,
88 OverlayImplBase* ov);
89 OverlayImplBase* handle_3D_2DTV(utils::eOverlayState s,
90 OverlayImplBase* ov);
91 OverlayImplBase* handle_UI_Mirror(utils::eOverlayState s,
92 OverlayImplBase* ov);
93 OverlayImplBase* handle_2D_trueUI_Mirror(utils::eOverlayState s,
94 OverlayImplBase* ov);
95 OverlayImplBase* handle_bypass(utils::eOverlayState s,
96 OverlayImplBase* ov);
97
98 /* Transition from any state to 2D video on 2D panel */
99 OverlayImplBase* handle_xxx_to_2D_2DPanel(OverlayImplBase* ov);
100
101 /* Transition from any state to 2D video on 2D panel and 2D TV */
102 OverlayImplBase* handle_xxx_to_2D_2DTV(OverlayImplBase* ov);
103
104 /* Transition from any state to 3D video on 2D panel */
105 OverlayImplBase* handle_xxx_to_3D_2DPanel(OverlayImplBase* ov);
106
107 /* Transition from any state to 3D video on 2D panel and 2D TV */
108 OverlayImplBase* handle_xxx_to_3D_2DTV(OverlayImplBase* ov);
109
110 /* Transition from any state to 2D video true UI mirroring (2D video + UI) */
111 OverlayImplBase* handle_xxx_to_2D_trueUI_Mirror(OverlayImplBase* ov);
112
113 /* Transitions from any state to 1 layer composition bypass */
114 OverlayImplBase* handle_xxx_to_bypass1(OverlayImplBase* ov);
115
116 /* Transitions from any state to 2 layers composition bypass */
117 OverlayImplBase* handle_xxx_to_bypass2(OverlayImplBase* ov);
118
119 /* Transitions from any state to 3 layers composition bypass */
120 OverlayImplBase* handle_xxx_to_bypass3(OverlayImplBase* ov);
121
122 /* Dump */
123 void dump() const;
124private:
125 /* States here */
126 utils::eOverlayState mState;
127};
128
129//------------------------State Traits --------------------------
130
131// primary has nothing
132template <int STATE> struct StateTraits {};
133
134/*
135 * For 3D_xxx we need channel ID besides the FBx since
136 * get crop/position 3D need that to determine pos/crop
137 * info.
138 * */
139
140template <> struct StateTraits<utils::OV_2D_VIDEO_ON_PANEL>
141{
142 typedef overlay::GenericPipe<utils::PRIMARY> pipe0;
143 typedef overlay::NullPipe pipe1; // place holder
144 typedef overlay::NullPipe pipe2; // place holder
145
146 typedef Rotator rot0;
147 typedef NullRotator rot1;
148 typedef NullRotator rot2;
149
150 typedef overlay::OverlayImpl<pipe0> ovimpl;
151};
152
153template <> struct StateTraits<utils::OV_2D_VIDEO_ON_PANEL_TV>
154{
155 typedef overlay::GenericPipe<utils::PRIMARY> pipe0;
156 typedef overlay::HdmiPipe pipe1;
157 typedef overlay::NullPipe pipe2; // place holder
158
159 typedef Rotator rot0;
160 typedef NullRotator rot1;
161 typedef NullRotator rot2;
162
163 typedef overlay::OverlayImpl<pipe0, pipe1> ovimpl;
164};
165
166template <> struct StateTraits<utils::OV_3D_VIDEO_ON_2D_PANEL>
167{
168 typedef overlay::M3DPrimaryPipe<utils::OV_PIPE0> pipe0;
169 typedef overlay::NullPipe pipe1; // place holder
170 typedef overlay::NullPipe pipe2; // place holder
171
172 typedef Rotator rot0;
173 typedef NullRotator rot1;
174 typedef NullRotator rot2;
175
176 typedef overlay::OverlayImpl<pipe0> ovimpl;
177};
178
179template <> struct StateTraits<utils::OV_3D_VIDEO_ON_3D_PANEL>
180{
181 typedef overlay::S3DPrimaryPipe<utils::OV_PIPE0> pipe0;
182 typedef overlay::S3DPrimaryPipe<utils::OV_PIPE1> pipe1;
183 typedef overlay::NullPipe pipe2; // place holder
184
185 typedef Rotator rot0;
186 typedef Rotator rot1;
187 typedef NullRotator rot2;
188
189 typedef overlay::OverlayImpl<pipe0, pipe1> ovimpl;
190};
191
192template <> struct StateTraits<utils::OV_3D_VIDEO_ON_3D_TV>
193{
194 typedef overlay::S3DExtPipe<utils::OV_PIPE0> pipe0;
195 typedef overlay::S3DExtPipe<utils::OV_PIPE1> pipe1;
196 typedef overlay::NullPipe pipe2; // place holder
197
198 typedef NullRotator rot0;
199 typedef NullRotator rot1;
200 typedef NullRotator rot2;
201
202 typedef overlay::OverlayImpl<pipe0, pipe1> ovimpl;
203};
204
205template <> struct StateTraits<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>
206{
207 typedef overlay::M3DPrimaryPipe<utils::OV_PIPE0> pipe0;
208 typedef overlay::M3DExtPipe<utils::OV_PIPE1> pipe1;
209 typedef overlay::NullPipe pipe2; // place holder
210
211 typedef Rotator rot0;
212 typedef NullRotator rot1;
213 typedef NullRotator rot2;
214
215 typedef overlay::OverlayImpl<pipe0, pipe1> ovimpl;
216};
217
218template <> struct StateTraits<utils::OV_UI_MIRROR>
219{
220 typedef overlay::UIMirrorPipe pipe0;
221 typedef overlay::NullPipe pipe1; // place holder
222 typedef overlay::NullPipe pipe2; // place holder
223
224 typedef Rotator rot0;
225 typedef NullRotator rot1;
226 typedef NullRotator rot2;
227
228 typedef overlay::OverlayImpl<pipe0> ovimpl;
229};
230
231template <> struct StateTraits<utils::OV_2D_TRUE_UI_MIRROR>
232{
233 typedef overlay::GenericPipe<utils::PRIMARY> pipe0;
234 typedef overlay::HdmiPipe pipe1;
235 typedef overlay::UIMirrorPipe pipe2;
236
237 typedef Rotator rot0;
238 typedef NullRotator rot1;
239 typedef Rotator rot2;
240
241 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
242};
243
244template <> struct StateTraits<utils::OV_BYPASS_1_LAYER>
245{
246 typedef overlay::BypassPipe<utils::OV_MDP_PIPE_VG, utils::IS_FG_SET, utils::WAIT, utils::ZORDER_0> pipe0;
247 typedef overlay::NullPipe pipe1; // place holder
248 typedef overlay::NullPipe pipe2; // place holder
249
250 typedef NullRotator rot0;
251 typedef NullRotator rot1;
252 typedef NullRotator rot2;
253
254 typedef overlay::OverlayImpl<pipe0> ovimpl;
255};
256
257template <> struct StateTraits<utils::OV_BYPASS_2_LAYER>
258{
259 typedef overlay::BypassPipe<utils::OV_MDP_PIPE_VG, utils::IS_FG_SET, utils::NO_WAIT, utils::ZORDER_0> pipe0;
260 typedef overlay::BypassPipe<utils::OV_MDP_PIPE_VG, utils::IS_FG_OFF, utils::WAIT, utils::ZORDER_1> pipe1;
261 typedef overlay::NullPipe pipe2; // place holder
262
263 typedef NullRotator rot0;
264 typedef NullRotator rot1;
265 typedef NullRotator rot2;
266
267 typedef overlay::OverlayImpl<pipe0, pipe1> ovimpl;
268};
269
270template <> struct StateTraits<utils::OV_BYPASS_3_LAYER>
271{
272 typedef overlay::BypassPipe<utils::OV_MDP_PIPE_VG, utils::IS_FG_SET, utils::NO_WAIT, utils::ZORDER_0> pipe0;
273 typedef overlay::BypassPipe<utils::OV_MDP_PIPE_VG, utils::IS_FG_OFF, utils::NO_WAIT, utils::ZORDER_1> pipe1;
274 typedef overlay::BypassPipe<utils::OV_MDP_PIPE_RGB, utils::IS_FG_OFF, utils::WAIT, utils::ZORDER_2> pipe2;
275
276 typedef NullRotator rot0;
277 typedef NullRotator rot1;
278 typedef NullRotator rot2;
279
280 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
281};
282
283
284//------------------------Inlines --------------------------------
285
286inline OverlayState::OverlayState() : mState(utils::OV_CLOSED)
287{}
288
289inline OverlayState::~OverlayState() {}
290
291inline utils::eOverlayState OverlayState::state() const
292{
293 return mState;
294}
295
296inline OverlayImplBase* OverlayState::reset(utils::eOverlayState s)
297{
298 return handleEvent(s, 0);
299}
300
301inline void OverlayState::dump() const
302{
303 ALOGE("== Dump state %d start/end ==", mState);
304}
305
306template <int STATE>
307inline OverlayImplBase* handle_closed_to_xxx()
308{
309 OverlayImplBase* ov = new typename StateTraits<STATE>::ovimpl;
310 RotatorBase* rot0 = new typename StateTraits<STATE>::rot0;
311 RotatorBase* rot1 = new typename StateTraits<STATE>::rot1;
312 RotatorBase* rot2 = new typename StateTraits<STATE>::rot2;
313 if(!ov->open(rot0, rot1, rot2)) {
314 ALOGE("Overlay failed to open in state %d", STATE);
315 return 0;
316 }
317 return ov;
318}
319
320inline OverlayImplBase* handle_xxx_to_closed(OverlayImplBase* ov)
321{
322 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
323
324 if(!ov->close()) {
325 ALOGE("%s: Failed to ov close", __FUNCTION__);
326 }
327 delete ov;
328 ov = 0;
329 return 0;
330}
331
332/* Hard transitions from any state to any state will close and then open */
333template <int STATE>
334inline OverlayImplBase* handle_xxx_to_xxx(OverlayImplBase* ov)
335{
336 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
337
338 handle_xxx_to_closed(ov);
339 return handle_closed_to_xxx<STATE>();
340}
341
342inline OverlayImplBase* OverlayState::handleEvent(utils::eOverlayState newState,
343 OverlayImplBase* ov)
344{
345 OverlayImplBase* newov = ov; // at least, we return the same
346 if (mState != newState) {
347 ALOGE_IF(DEBUG_OVERLAY, "%s: state changed %s-->%s",
348 __FUNCTION__, getStateString(mState), getStateString(newState));
349 } else {
350 ALOGE_IF(DEBUG_OVERLAY, "%s: no state change, state=%s",
351 __FUNCTION__, getStateString(newState));
352 return newov;
353 }
354
355 switch(mState)
356 {
357 case utils::OV_CLOSED:
358 newov = handle_closed(newState);
359 break;
360 case utils::OV_2D_VIDEO_ON_PANEL:
361 newov = handle_2D_2DPanel(newState, ov);
362 break;
363 case utils::OV_2D_VIDEO_ON_PANEL_TV:
364 newov = handle_2D_2DTV(newState, ov);
365 break;
366 case utils::OV_3D_VIDEO_ON_2D_PANEL:
367 newov = handle_3D_2DPanel(newState, ov);
368 break;
369 case utils::OV_3D_VIDEO_ON_3D_PANEL:
370 newov = handle_3D_3DPanel(newState, ov);
371 break;
372 case utils::OV_3D_VIDEO_ON_3D_TV:
373 newov = handle_3D_3DTV(newState, ov);
374 break;
375 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
376 newov = handle_3D_2DTV(newState, ov);
377 break;
378 case utils::OV_UI_MIRROR:
379 newov = handle_UI_Mirror(newState, ov);
380 break;
381 case utils::OV_2D_TRUE_UI_MIRROR:
382 newov = handle_2D_trueUI_Mirror(newState, ov);
383 break;
384 case utils::OV_BYPASS_1_LAYER:
385 case utils::OV_BYPASS_2_LAYER:
386 case utils::OV_BYPASS_3_LAYER:
387 newov = handle_bypass(newState, ov);
388 break;
389 default:
390 ALOGE("%s: unknown state=%d", __FUNCTION__, mState);
391 }
392
393 // FIXME, how to communicate bad transition?
394 // Should we have bool returned from transition func?
395
396 return newov;
397}
398
399// Transitions from closed to XXX
400inline OverlayImplBase* OverlayState::handle_closed(utils::eOverlayState s)
401{
402 OverlayImplBase* ov = 0;
403 switch(s)
404 {
405 case utils::OV_CLOSED:
406 // no state change
407 break;
408 case utils::OV_2D_VIDEO_ON_PANEL:
409 ov = handle_closed_to_xxx<utils::OV_2D_VIDEO_ON_PANEL>();
410 break;
411 case utils::OV_2D_VIDEO_ON_PANEL_TV:
412 ov = handle_closed_to_xxx<utils::OV_2D_VIDEO_ON_PANEL_TV>();
413 break;
414 case utils::OV_3D_VIDEO_ON_2D_PANEL:
415 ov = handle_closed_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL>();
416 break;
417 case utils::OV_3D_VIDEO_ON_3D_PANEL:
418 ov = handle_closed_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>();
419 break;
420 case utils::OV_3D_VIDEO_ON_3D_TV:
421 ov = handle_closed_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>();
422 break;
423 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
424 ov = handle_closed_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>();
425 break;
426 case utils::OV_UI_MIRROR:
427 ov = handle_closed_to_xxx<utils::OV_UI_MIRROR>();
428 break;
429 case utils::OV_2D_TRUE_UI_MIRROR:
430 ov = handle_closed_to_xxx<utils::OV_2D_TRUE_UI_MIRROR>();
431 break;
432 case utils::OV_BYPASS_1_LAYER:
433 ov = handle_closed_to_xxx<utils::OV_BYPASS_1_LAYER>();
434 break;
435 case utils::OV_BYPASS_2_LAYER:
436 ov = handle_closed_to_xxx<utils::OV_BYPASS_2_LAYER>();
437 break;
438 case utils::OV_BYPASS_3_LAYER:
439 ov = handle_closed_to_xxx<utils::OV_BYPASS_3_LAYER>();
440 break;
441 default:
442 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
443 }
444 mState = s;
445 return ov;
446}
447
448// Transitions from 2D video on 2D panel to XXX
449inline OverlayImplBase* OverlayState::handle_2D_2DPanel(
450 utils::eOverlayState s,
451 OverlayImplBase* ov)
452{
453 OverlayImplBase* newov = ov;
454 switch(s)
455 {
456 case utils::OV_CLOSED:
457 newov = handle_xxx_to_closed(ov);
458 break;
459 case utils::OV_2D_VIDEO_ON_PANEL:
460 // no state change
461 break;
462 case utils::OV_2D_VIDEO_ON_PANEL_TV:
463 newov = handle_xxx_to_2D_2DTV(ov);
464 break;
465 case utils::OV_3D_VIDEO_ON_2D_PANEL:
466 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL>(ov);
467 break;
468 case utils::OV_3D_VIDEO_ON_3D_PANEL:
469 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
470 break;
471 case utils::OV_3D_VIDEO_ON_3D_TV:
472 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>(ov);
473 break;
474 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
475 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(ov);
476 break;
477 case utils::OV_UI_MIRROR:
478 newov = handle_xxx_to_xxx<utils::OV_UI_MIRROR>(ov);
479 break;
480 case utils::OV_2D_TRUE_UI_MIRROR:
481 newov = handle_xxx_to_2D_trueUI_Mirror(ov);
482 break;
483 case utils::OV_BYPASS_1_LAYER:
484 newov = handle_xxx_to_xxx<utils::OV_BYPASS_1_LAYER>(ov);
485 break;
486 case utils::OV_BYPASS_2_LAYER:
487 newov = handle_xxx_to_xxx<utils::OV_BYPASS_2_LAYER>(ov);
488 break;
489 case utils::OV_BYPASS_3_LAYER:
490 newov = handle_xxx_to_xxx<utils::OV_BYPASS_3_LAYER>(ov);
491 break;
492 default:
493 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
494 }
495 mState = s;
496 return newov;
497}
498
499// Transitions from 2D video on 2D panel and 2D TV to XXX
500inline OverlayImplBase* OverlayState::handle_2D_2DTV(
501 utils::eOverlayState s,
502 OverlayImplBase* ov)
503{
504 OverlayImplBase* newov = ov;
505 switch(s)
506 {
507 case utils::OV_CLOSED:
508 newov = handle_xxx_to_closed(ov);
509 break;
510 case utils::OV_2D_VIDEO_ON_PANEL:
511 newov = handle_xxx_to_2D_2DPanel(ov);
512 break;
513 case utils::OV_2D_VIDEO_ON_PANEL_TV:
514 // no state change
515 break;
516 case utils::OV_3D_VIDEO_ON_2D_PANEL:
517 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL>(ov);
518 break;
519 case utils::OV_3D_VIDEO_ON_3D_PANEL:
520 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
521 break;
522 case utils::OV_3D_VIDEO_ON_3D_TV:
523 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>(ov);
524 break;
525 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
526 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(ov);
527 break;
528 case utils::OV_UI_MIRROR:
529 newov = handle_xxx_to_xxx<utils::OV_UI_MIRROR>(ov);
530 break;
531 case utils::OV_2D_TRUE_UI_MIRROR:
532 newov = handle_xxx_to_2D_trueUI_Mirror(ov);
533 break;
534 case utils::OV_BYPASS_1_LAYER:
535 newov = handle_xxx_to_xxx<utils::OV_BYPASS_1_LAYER>(ov);
536 break;
537 case utils::OV_BYPASS_2_LAYER:
538 newov = handle_xxx_to_xxx<utils::OV_BYPASS_2_LAYER>(ov);
539 break;
540 case utils::OV_BYPASS_3_LAYER:
541 newov = handle_xxx_to_xxx<utils::OV_BYPASS_3_LAYER>(ov);
542 break;
543 default:
544 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
545 }
546 mState = s;
547 return newov;
548}
549
550// Transitions from 3D video on 2D panel to XXX
551inline OverlayImplBase* OverlayState::handle_3D_2DPanel(
552 utils::eOverlayState s,
553 OverlayImplBase* ov)
554{
555 OverlayImplBase* newov = ov;
556 switch(s)
557 {
558 case utils::OV_CLOSED:
559 newov = handle_xxx_to_closed(ov);
560 break;
561 case utils::OV_2D_VIDEO_ON_PANEL:
562 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL>(ov);
563 break;
564 case utils::OV_2D_VIDEO_ON_PANEL_TV:
565 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL_TV>(ov);
566 break;
567 case utils::OV_3D_VIDEO_ON_2D_PANEL:
568 // no state change
569 break;
570 case utils::OV_3D_VIDEO_ON_3D_PANEL:
571 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
572 break;
573 case utils::OV_3D_VIDEO_ON_3D_TV:
574 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>(ov);
575 break;
576 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
577 newov = handle_xxx_to_3D_2DTV(ov);
578 break;
579 case utils::OV_UI_MIRROR:
580 newov = handle_xxx_to_xxx<utils::OV_UI_MIRROR>(ov);
581 break;
582 case utils::OV_2D_TRUE_UI_MIRROR:
583 newov = handle_xxx_to_xxx<utils::OV_2D_TRUE_UI_MIRROR>(ov);
584 break;
585 case utils::OV_BYPASS_1_LAYER:
586 newov = handle_xxx_to_xxx<utils::OV_BYPASS_1_LAYER>(ov);
587 break;
588 case utils::OV_BYPASS_2_LAYER:
589 newov = handle_xxx_to_xxx<utils::OV_BYPASS_2_LAYER>(ov);
590 break;
591 case utils::OV_BYPASS_3_LAYER:
592 newov = handle_xxx_to_xxx<utils::OV_BYPASS_3_LAYER>(ov);
593 break;
594 default:
595 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
596 }
597 mState = s;
598 return newov;
599}
600
601// Transitions from 3D video on 3D panel to XXX
602inline OverlayImplBase* OverlayState::handle_3D_3DPanel(
603 utils::eOverlayState s,
604 OverlayImplBase* ov)
605{
606 OverlayImplBase* newov = ov;
607 switch(s)
608 {
609 case utils::OV_CLOSED:
610 newov = handle_xxx_to_closed(ov);
611 break;
612 case utils::OV_2D_VIDEO_ON_PANEL:
613 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL>(ov);
614 break;
615 case utils::OV_2D_VIDEO_ON_PANEL_TV:
616 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL_TV>(ov);
617 break;
618 case utils::OV_3D_VIDEO_ON_2D_PANEL:
619 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL>(ov);
620 break;
621 case utils::OV_3D_VIDEO_ON_3D_PANEL:
622 // no state change
623 break;
624 case utils::OV_3D_VIDEO_ON_3D_TV:
625 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>(ov);
626 break;
627 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
628 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(ov);
629 break;
630 case utils::OV_UI_MIRROR:
631 newov = handle_xxx_to_xxx<utils::OV_UI_MIRROR>(ov);
632 break;
633 case utils::OV_2D_TRUE_UI_MIRROR:
634 newov = handle_xxx_to_xxx<utils::OV_2D_TRUE_UI_MIRROR>(ov);
635 break;
636 case utils::OV_BYPASS_1_LAYER:
637 newov = handle_xxx_to_xxx<utils::OV_BYPASS_1_LAYER>(ov);
638 break;
639 case utils::OV_BYPASS_2_LAYER:
640 newov = handle_xxx_to_xxx<utils::OV_BYPASS_2_LAYER>(ov);
641 break;
642 case utils::OV_BYPASS_3_LAYER:
643 newov = handle_xxx_to_xxx<utils::OV_BYPASS_3_LAYER>(ov);
644 break;
645 default:
646 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
647 }
648 mState = s;
649 return newov;
650}
651
652// Transitions from 3D video on 3D TV to XXX
653inline OverlayImplBase* OverlayState::handle_3D_3DTV(
654 utils::eOverlayState s,
655 OverlayImplBase* ov)
656{
657 OverlayImplBase* newov = ov;
658 switch(s)
659 {
660 case utils::OV_CLOSED:
661 newov = handle_xxx_to_closed(ov);
662 break;
663 case utils::OV_2D_VIDEO_ON_PANEL:
664 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL>(ov);
665 break;
666 case utils::OV_2D_VIDEO_ON_PANEL_TV:
667 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL_TV>(ov);
668 break;
669 case utils::OV_3D_VIDEO_ON_2D_PANEL:
670 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL>(ov);
671 break;
672 case utils::OV_3D_VIDEO_ON_3D_PANEL:
673 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
674 break;
675 case utils::OV_3D_VIDEO_ON_3D_TV:
676 // no state change
677 break;
678 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
679 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(ov);
680 break;
681 case utils::OV_UI_MIRROR:
682 newov = handle_xxx_to_xxx<utils::OV_UI_MIRROR>(ov);
683 break;
684 case utils::OV_2D_TRUE_UI_MIRROR:
685 newov = handle_xxx_to_xxx<utils::OV_2D_TRUE_UI_MIRROR>(ov);
686 break;
687 case utils::OV_BYPASS_1_LAYER:
688 newov = handle_xxx_to_xxx<utils::OV_BYPASS_1_LAYER>(ov);
689 break;
690 case utils::OV_BYPASS_2_LAYER:
691 newov = handle_xxx_to_xxx<utils::OV_BYPASS_2_LAYER>(ov);
692 break;
693 case utils::OV_BYPASS_3_LAYER:
694 newov = handle_xxx_to_xxx<utils::OV_BYPASS_3_LAYER>(ov);
695 break;
696 default:
697 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
698 }
699 mState = s;
700 return newov;
701}
702
703// Transitions from 3D video on 2D panel and 2D TV to XXX
704inline OverlayImplBase* OverlayState::handle_3D_2DTV(
705 utils::eOverlayState s,
706 OverlayImplBase* ov)
707{
708 OverlayImplBase* newov = ov;
709 switch(s)
710 {
711 case utils::OV_CLOSED:
712 newov = handle_xxx_to_closed(ov);
713 break;
714 case utils::OV_2D_VIDEO_ON_PANEL:
715 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL>(ov);
716 break;
717 case utils::OV_2D_VIDEO_ON_PANEL_TV:
718 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL_TV>(ov);
719 break;
720 case utils::OV_3D_VIDEO_ON_2D_PANEL:
721 newov = handle_xxx_to_3D_2DPanel(ov);
722 break;
723 case utils::OV_3D_VIDEO_ON_3D_PANEL:
724 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
725 break;
726 case utils::OV_3D_VIDEO_ON_3D_TV:
727 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>(ov);
728 break;
729 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
730 // no state change
731 break;
732 case utils::OV_UI_MIRROR:
733 newov = handle_xxx_to_xxx<utils::OV_UI_MIRROR>(ov);
734 break;
735 case utils::OV_2D_TRUE_UI_MIRROR:
736 newov = handle_xxx_to_xxx<utils::OV_2D_TRUE_UI_MIRROR>(ov);
737 break;
738 case utils::OV_BYPASS_1_LAYER:
739 newov = handle_xxx_to_xxx<utils::OV_BYPASS_1_LAYER>(ov);
740 break;
741 case utils::OV_BYPASS_2_LAYER:
742 newov = handle_xxx_to_xxx<utils::OV_BYPASS_2_LAYER>(ov);
743 break;
744 case utils::OV_BYPASS_3_LAYER:
745 newov = handle_xxx_to_xxx<utils::OV_BYPASS_3_LAYER>(ov);
746 break;
747 default:
748 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
749 }
750 mState = s;
751 return newov;
752}
753
754// Transitions from UI mirroring to XXX
755inline OverlayImplBase* OverlayState::handle_UI_Mirror(utils::eOverlayState s,
756 OverlayImplBase* ov)
757{
758 OverlayImplBase* newov = ov;
759 switch(s)
760 {
761 case utils::OV_CLOSED:
762 newov = handle_xxx_to_closed(ov);
763 break;
764 case utils::OV_2D_VIDEO_ON_PANEL:
765 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL>(ov);
766 break;
767 case utils::OV_2D_VIDEO_ON_PANEL_TV:
768 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL_TV>(ov);
769 break;
770 case utils::OV_3D_VIDEO_ON_2D_PANEL:
771 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL>(ov);
772 break;
773 case utils::OV_3D_VIDEO_ON_3D_PANEL:
774 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
775 break;
776 case utils::OV_3D_VIDEO_ON_3D_TV:
777 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>(ov);
778 break;
779 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
780 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(ov);
781 break;
782 case utils::OV_UI_MIRROR:
783 // no state change
784 break;
785 case utils::OV_2D_TRUE_UI_MIRROR:
786 newov = handle_xxx_to_xxx<utils::OV_2D_TRUE_UI_MIRROR>(ov);
787 break;
788 case utils::OV_BYPASS_1_LAYER:
789 newov = handle_xxx_to_xxx<utils::OV_BYPASS_1_LAYER>(ov);
790 break;
791 case utils::OV_BYPASS_2_LAYER:
792 newov = handle_xxx_to_xxx<utils::OV_BYPASS_2_LAYER>(ov);
793 break;
794 case utils::OV_BYPASS_3_LAYER:
795 newov = handle_xxx_to_xxx<utils::OV_BYPASS_3_LAYER>(ov);
796 break;
797 default:
798 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
799 }
800 mState = s;
801 return newov;
802}
803
804// Transitions from 2D video true UI mirroring (2D video + UI) to XXX
805inline OverlayImplBase* OverlayState::handle_2D_trueUI_Mirror(utils::eOverlayState s,
806 OverlayImplBase* ov)
807{
808 OverlayImplBase* newov = ov;
809 switch(s)
810 {
811 case utils::OV_CLOSED:
812 newov = handle_xxx_to_closed(ov);
813 break;
814 case utils::OV_2D_VIDEO_ON_PANEL:
815 newov = handle_xxx_to_2D_2DPanel(ov);
816 break;
817 case utils::OV_2D_VIDEO_ON_PANEL_TV:
818 newov = handle_xxx_to_2D_2DTV(ov);
819 break;
820 case utils::OV_3D_VIDEO_ON_2D_PANEL:
821 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL>(ov);
822 break;
823 case utils::OV_3D_VIDEO_ON_3D_PANEL:
824 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
825 break;
826 case utils::OV_3D_VIDEO_ON_3D_TV:
827 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>(ov);
828 break;
829 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
830 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(ov);
831 break;
832 case utils::OV_UI_MIRROR:
833 newov = handle_xxx_to_xxx<utils::OV_UI_MIRROR>(ov);
834 break;
835 case utils::OV_2D_TRUE_UI_MIRROR:
836 // no state change
837 break;
838 case utils::OV_BYPASS_1_LAYER:
839 newov = handle_xxx_to_xxx<utils::OV_BYPASS_1_LAYER>(ov);
840 break;
841 case utils::OV_BYPASS_2_LAYER:
842 newov = handle_xxx_to_xxx<utils::OV_BYPASS_2_LAYER>(ov);
843 break;
844 case utils::OV_BYPASS_3_LAYER:
845 newov = handle_xxx_to_xxx<utils::OV_BYPASS_3_LAYER>(ov);
846 break;
847 default:
848 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
849 }
850 mState = s;
851 return newov;
852}
853
854// Transitions from composition bypass to XXX
855inline OverlayImplBase* OverlayState::handle_bypass(utils::eOverlayState s,
856 OverlayImplBase* ov)
857{
858 OverlayImplBase* newov = ov;
859 switch(s)
860 {
861 case utils::OV_CLOSED:
862 newov = handle_xxx_to_closed(ov);
863 break;
864 case utils::OV_2D_VIDEO_ON_PANEL:
865 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL>(ov);
866 break;
867 case utils::OV_2D_VIDEO_ON_PANEL_TV:
868 newov = handle_xxx_to_xxx<utils::OV_2D_VIDEO_ON_PANEL_TV>(ov);
869 break;
870 case utils::OV_3D_VIDEO_ON_2D_PANEL:
871 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL>(ov);
872 break;
873 case utils::OV_3D_VIDEO_ON_3D_PANEL:
874 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
875 break;
876 case utils::OV_3D_VIDEO_ON_3D_TV:
877 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_3D_TV>(ov);
878 break;
879 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
880 newov = handle_xxx_to_xxx<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(ov);
881 break;
882 case utils::OV_UI_MIRROR:
883 newov = handle_xxx_to_xxx<utils::OV_UI_MIRROR>(ov);
884 break;
885 case utils::OV_2D_TRUE_UI_MIRROR:
886 newov = handle_xxx_to_xxx<utils::OV_2D_TRUE_UI_MIRROR>(ov);
887 break;
888 case utils::OV_BYPASS_1_LAYER:
889 newov = handle_xxx_to_bypass1(ov);
890 break;
891 case utils::OV_BYPASS_2_LAYER:
892 newov = handle_xxx_to_bypass2(ov);
893 break;
894 case utils::OV_BYPASS_3_LAYER:
895 newov = handle_xxx_to_bypass3(ov);
896 break;
897 default:
898 ALOGE("%s: unknown state=%d", __FUNCTION__, s);
899 }
900 mState = s;
901 return newov;
902}
903
904
905} // overlay
906
907#endif // OVERLAY_STATE_H