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