blob: e4fbecebedfa8cbd92d477326801e816b303870a [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:
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -070049 /*ctor*/
Naseer Ahmed29a26812012-06-14 00:56:20 -070050 explicit OverlayState();
51
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -070052 /*dtor*/
Naseer Ahmed29a26812012-06-14 00:56:20 -070053 ~OverlayState();
54
55 /* return current state */
56 utils::eOverlayState state() const;
57
Naseer Ahmed29a26812012-06-14 00:56:20 -070058 /* Hard reset to a new state. If the state is the same
59 * as the current one, it would be a no-op */
60 OverlayImplBase* reset(utils::eOverlayState s);
61
62 /* Caller pass the state to the handleEvent function.
63 * The input is the current OverlayImplBase*, and output is
64 * a pointer to (possibly new) instance of OverlayImplBase
65 * The eFormat can be 2D/3D etc. */
66 OverlayImplBase* handleEvent(utils::eOverlayState s,
67 OverlayImplBase* ov);
68
Naseer Ahmed29a26812012-06-14 00:56:20 -070069 /* Dump */
70 void dump() const;
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -070071
Naseer Ahmed29a26812012-06-14 00:56:20 -070072private:
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -070073
74 /* Transitions from a state to a state. Default behavior is to move from an
75 * old state to CLOSED and from CLOSED to a new state. Any impl wishing to
76 * copy pipes should specialize this call */
77 template<utils::eOverlayState FROM_STATE, utils::eOverlayState TO_STATE>
78 OverlayImplBase* handle_from_to(OverlayImplBase* ov);
79
80 /* Just a convenient intermediate function to bring down the number of
81 * combinations arising from multiple states */
82 template<utils::eOverlayState FROM_STATE>
83 OverlayImplBase* handle_from(utils::eOverlayState toState,
84 OverlayImplBase* ov);
85
86 /* Substitues for partially specialized templated handle functions since the
87 * standard doesn't allow partial specialization of functions */
88 template<utils::eOverlayState FROM_STATE>
89 OverlayImplBase* handle_xxx_to_CLOSED(OverlayImplBase* ov);
90
91 template<utils::eOverlayState TO_STATE>
92 OverlayImplBase* handle_CLOSED_to_xxx(OverlayImplBase* ov);
93
Naseer Ahmed29a26812012-06-14 00:56:20 -070094 /* States here */
95 utils::eOverlayState mState;
96};
97
98//------------------------State Traits --------------------------
99
100// primary has nothing
101template <int STATE> struct StateTraits {};
102
103/*
104 * For 3D_xxx we need channel ID besides the FBx since
105 * get crop/position 3D need that to determine pos/crop
106 * info.
107 * */
108
109template <> struct StateTraits<utils::OV_2D_VIDEO_ON_PANEL>
110{
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700111 typedef overlay::GenericPipe<utils::PRIMARY> pipe0; //prim video
Naseer Ahmed29a26812012-06-14 00:56:20 -0700112 typedef overlay::NullPipe pipe1; // place holder
113 typedef overlay::NullPipe pipe2; // place holder
114
115 typedef Rotator rot0;
116 typedef NullRotator rot1;
117 typedef NullRotator rot2;
118
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700119 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700120};
121
122template <> struct StateTraits<utils::OV_2D_VIDEO_ON_PANEL_TV>
123{
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700124 typedef overlay::GenericPipe<utils::PRIMARY> pipe0; //prim video
125 typedef overlay::VideoExtPipe pipe1; //ext video
126 typedef overlay::GenericPipe<utils::EXTERNAL> pipe2; //ext subtitle
Naseer Ahmed29a26812012-06-14 00:56:20 -0700127
128 typedef Rotator rot0;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700129 typedef Rotator rot1;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700130 typedef NullRotator rot2;
131
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700132 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
133};
134
135template <> struct StateTraits<utils::OV_2D_VIDEO_ON_TV>
136{
137 typedef overlay::NullPipe pipe0; //nothing on primary with mdp
138 typedef overlay::VideoExtPipe pipe1; //ext video
139 typedef overlay::GenericPipe<utils::EXTERNAL> pipe2; //ext subtitle
140
141 typedef NullRotator rot0;
142 typedef Rotator rot1;
143 typedef NullRotator rot2;
144
145 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700146};
147
148template <> struct StateTraits<utils::OV_3D_VIDEO_ON_2D_PANEL>
149{
150 typedef overlay::M3DPrimaryPipe<utils::OV_PIPE0> pipe0;
151 typedef overlay::NullPipe pipe1; // place holder
152 typedef overlay::NullPipe pipe2; // place holder
153
154 typedef Rotator rot0;
155 typedef NullRotator rot1;
156 typedef NullRotator rot2;
157
158 typedef overlay::OverlayImpl<pipe0> ovimpl;
159};
160
161template <> struct StateTraits<utils::OV_3D_VIDEO_ON_3D_PANEL>
162{
163 typedef overlay::S3DPrimaryPipe<utils::OV_PIPE0> pipe0;
164 typedef overlay::S3DPrimaryPipe<utils::OV_PIPE1> pipe1;
165 typedef overlay::NullPipe pipe2; // place holder
166
167 typedef Rotator rot0;
168 typedef Rotator rot1;
169 typedef NullRotator rot2;
170
171 typedef overlay::OverlayImpl<pipe0, pipe1> ovimpl;
172};
173
174template <> struct StateTraits<utils::OV_3D_VIDEO_ON_3D_TV>
175{
176 typedef overlay::S3DExtPipe<utils::OV_PIPE0> pipe0;
177 typedef overlay::S3DExtPipe<utils::OV_PIPE1> pipe1;
178 typedef overlay::NullPipe pipe2; // place holder
179
180 typedef NullRotator rot0;
181 typedef NullRotator rot1;
182 typedef NullRotator rot2;
183
184 typedef overlay::OverlayImpl<pipe0, pipe1> ovimpl;
185};
186
187template <> struct StateTraits<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>
188{
189 typedef overlay::M3DPrimaryPipe<utils::OV_PIPE0> pipe0;
190 typedef overlay::M3DExtPipe<utils::OV_PIPE1> pipe1;
191 typedef overlay::NullPipe pipe2; // place holder
192
193 typedef Rotator rot0;
194 typedef NullRotator rot1;
195 typedef NullRotator rot2;
196
197 typedef overlay::OverlayImpl<pipe0, pipe1> ovimpl;
198};
199
200template <> struct StateTraits<utils::OV_UI_MIRROR>
201{
202 typedef overlay::UIMirrorPipe pipe0;
203 typedef overlay::NullPipe pipe1; // place holder
204 typedef overlay::NullPipe pipe2; // place holder
205
206 typedef Rotator rot0;
207 typedef NullRotator rot1;
208 typedef NullRotator rot2;
209
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700210 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700211};
212
213template <> struct StateTraits<utils::OV_2D_TRUE_UI_MIRROR>
214{
215 typedef overlay::GenericPipe<utils::PRIMARY> pipe0;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700216 typedef overlay::VideoExtPipe pipe1;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700217 typedef overlay::UIMirrorPipe pipe2;
218
219 typedef Rotator rot0;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700220 typedef Rotator rot1;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700221 typedef Rotator rot2;
222
223 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
224};
225
226template <> struct StateTraits<utils::OV_BYPASS_1_LAYER>
227{
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700228 typedef overlay::GenericPipe<utils::PRIMARY> pipe0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700229 typedef overlay::NullPipe pipe1; // place holder
230 typedef overlay::NullPipe pipe2; // place holder
231
232 typedef NullRotator rot0;
233 typedef NullRotator rot1;
234 typedef NullRotator rot2;
235
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700236 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700237};
238
239template <> struct StateTraits<utils::OV_BYPASS_2_LAYER>
240{
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700241 typedef overlay::GenericPipe<utils::PRIMARY> pipe0;
242 typedef overlay::GenericPipe<utils::PRIMARY> pipe1;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700243 typedef overlay::NullPipe pipe2; // place holder
244
245 typedef NullRotator rot0;
246 typedef NullRotator rot1;
247 typedef NullRotator rot2;
248
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700249 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700250};
251
252template <> struct StateTraits<utils::OV_BYPASS_3_LAYER>
253{
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700254 typedef overlay::GenericPipe<utils::PRIMARY> pipe0;
255 typedef overlay::GenericPipe<utils::PRIMARY> pipe1;
256 typedef overlay::GenericPipe<utils::PRIMARY> pipe2;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700257
258 typedef NullRotator rot0;
259 typedef NullRotator rot1;
260 typedef NullRotator rot2;
261
262 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
263};
264
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700265template <> struct StateTraits<utils::OV_DUAL_DISP>
266{
267 typedef overlay::GenericPipe<utils::EXTERNAL> pipe0;
Naseer Ahmed4c588a22012-07-31 19:12:17 -0700268 typedef overlay::NullPipe pipe1;
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700269 typedef overlay::NullPipe pipe2;
270
271 typedef NullRotator rot0;
272 typedef NullRotator rot1;
273 typedef NullRotator rot2;
274
275 typedef overlay::OverlayImpl<pipe0, pipe1, pipe2> ovimpl;
276};
277
Naseer Ahmed29a26812012-06-14 00:56:20 -0700278
279//------------------------Inlines --------------------------------
280
Naseer Ahmed29a26812012-06-14 00:56:20 -0700281
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700282inline OverlayState::OverlayState() : mState(utils::OV_CLOSED){}
Naseer Ahmed29a26812012-06-14 00:56:20 -0700283inline OverlayState::~OverlayState() {}
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700284inline utils::eOverlayState OverlayState::state() const { return mState; }
285inline OverlayImplBase* OverlayState::reset(utils::eOverlayState s) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700286 return handleEvent(s, 0);
287}
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700288inline void OverlayState::dump() const {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700289 ALOGE("== Dump state %d start/end ==", mState);
290}
291
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700292inline OverlayImplBase* OverlayState::handleEvent(utils::eOverlayState toState,
293 OverlayImplBase* ov)
Naseer Ahmed29a26812012-06-14 00:56:20 -0700294{
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700295 OverlayImplBase* newov = ov; // at least, we return the same
296 if (mState != toState) {
297 ALOGD_IF(DEBUG_OVERLAY, "%s: state changed %s-->%s",
298 __FUNCTION__, getStateString(mState), getStateString(toState));
299 } else {
300 ALOGD_IF(DEBUG_OVERLAY, "%s: no state change, state=%s",
301 __FUNCTION__, getStateString(toState));
302 return newov;
303 }
304
305 switch(mState)
306 {
307 case utils::OV_CLOSED:
308 newov = handle_from<utils::OV_CLOSED>(toState, ov);
309 break;
310 case utils::OV_2D_VIDEO_ON_PANEL:
311 newov = handle_from<utils::OV_2D_VIDEO_ON_PANEL>(toState, ov);
312 break;
313 case utils::OV_2D_VIDEO_ON_PANEL_TV:
314 newov = handle_from<utils::OV_2D_VIDEO_ON_PANEL_TV>(toState, ov);
315 break;
316 case utils::OV_2D_VIDEO_ON_TV:
317 newov = handle_from<utils::OV_2D_VIDEO_ON_TV>(toState, ov);
318 break;
319 case utils::OV_3D_VIDEO_ON_2D_PANEL:
320 newov = handle_from<utils::OV_3D_VIDEO_ON_2D_PANEL>(toState, ov);
321 break;
322 case utils::OV_3D_VIDEO_ON_3D_PANEL:
323 newov = handle_from<utils::OV_3D_VIDEO_ON_3D_PANEL>(toState, ov);
324 break;
325 case utils::OV_3D_VIDEO_ON_3D_TV:
326 newov = handle_from<utils::OV_3D_VIDEO_ON_3D_TV>(toState, ov);
327 break;
328 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
329 newov = handle_from<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(toState,
330 ov);
331 break;
332 case utils::OV_UI_MIRROR:
333 newov = handle_from<utils::OV_UI_MIRROR>(toState, ov);
334 break;
335 case utils::OV_2D_TRUE_UI_MIRROR:
336 newov = handle_from<utils::OV_2D_TRUE_UI_MIRROR>(toState, ov);
337 break;
338 case utils::OV_BYPASS_1_LAYER:
339 newov = handle_from<utils::OV_BYPASS_1_LAYER>(toState, ov);
340 break;
341 case utils::OV_BYPASS_2_LAYER:
342 newov = handle_from<utils::OV_BYPASS_2_LAYER>(toState, ov);
343 break;
344 case utils::OV_BYPASS_3_LAYER:
345 newov = handle_from<utils::OV_BYPASS_3_LAYER>(toState, ov);
346 break;
347 case utils::OV_DUAL_DISP:
348 newov = handle_from<utils::OV_DUAL_DISP>(toState, ov);
349 break;
350 default:
351 OVASSERT(1 == 0, "%s: unknown state = %d", __FUNCTION__, mState);
352
353 }
354 return newov;
355}
356
357template <utils::eOverlayState FROM_STATE>
358inline OverlayImplBase* OverlayState::handle_from(utils::eOverlayState toState,
359 OverlayImplBase* ov) {
360
361 switch(toState)
362 {
363 case utils::OV_CLOSED:
364 ov = handle_xxx_to_CLOSED<FROM_STATE>(ov);
365 break;
366 case utils::OV_2D_VIDEO_ON_PANEL:
367 ov = handle_from_to<FROM_STATE, utils::OV_2D_VIDEO_ON_PANEL>(ov);
368 break;
369 case utils::OV_2D_VIDEO_ON_PANEL_TV:
370 ov = handle_from_to<FROM_STATE, utils::OV_2D_VIDEO_ON_PANEL_TV>(ov);
371 break;
372 case utils::OV_2D_VIDEO_ON_TV:
373 ov = handle_from_to<FROM_STATE, utils::OV_2D_VIDEO_ON_TV>(ov);
374 break;
375 case utils::OV_3D_VIDEO_ON_2D_PANEL:
376 ov = handle_from_to<FROM_STATE, utils::OV_3D_VIDEO_ON_2D_PANEL>(ov);
377 break;
378 case utils::OV_3D_VIDEO_ON_3D_PANEL:
379 ov = handle_from_to<FROM_STATE, utils::OV_3D_VIDEO_ON_3D_PANEL>(ov);
380 break;
381 case utils::OV_3D_VIDEO_ON_3D_TV:
382 ov = handle_from_to<FROM_STATE, utils::OV_3D_VIDEO_ON_3D_TV>(ov);
383 break;
384 case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
385 ov = handle_from_to<FROM_STATE,
386 utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV>(ov);
387 break;
388 case utils::OV_UI_MIRROR:
389 ov = handle_from_to<FROM_STATE, utils::OV_UI_MIRROR>(ov);
390 break;
391 case utils::OV_2D_TRUE_UI_MIRROR:
392 ov = handle_from_to<FROM_STATE, utils::OV_2D_TRUE_UI_MIRROR>(ov);
393 break;
394 case utils::OV_BYPASS_1_LAYER:
395 ov = handle_from_to<FROM_STATE, utils::OV_BYPASS_1_LAYER>(ov);
396 break;
397 case utils::OV_BYPASS_2_LAYER:
398 ov = handle_from_to<FROM_STATE, utils::OV_BYPASS_2_LAYER>(ov);
399 break;
400 case utils::OV_BYPASS_3_LAYER:
401 ov = handle_from_to<FROM_STATE, utils::OV_BYPASS_3_LAYER>(ov);
402 break;
403 case utils::OV_DUAL_DISP:
404 ov = handle_from_to<FROM_STATE, utils::OV_DUAL_DISP>(ov);
405 break;
406 default:
407 OVASSERT(1 == 0, "%s: unknown state = %d", __FUNCTION__, toState);
408 }
409 mState = toState;
410 return ov;
411}
412
413
414/* Transition default from any to any. Does in two steps.
415 * Moves from OLD to CLOSED and then from CLOSED to NEW
416 */
417template<utils::eOverlayState FROM_STATE, utils::eOverlayState TO_STATE>
418inline OverlayImplBase* OverlayState::handle_from_to(OverlayImplBase* ov) {
419 handle_xxx_to_CLOSED<FROM_STATE>(ov);
420 return handle_CLOSED_to_xxx<TO_STATE>(ov);
421}
422
423//---------------Specializations-------------
424
425
426/* Transition from CLOSED to ANY */
427template<utils::eOverlayState TO_STATE>
428inline OverlayImplBase* OverlayState::handle_CLOSED_to_xxx(
429 OverlayImplBase* /*ignored*/) {
430 //If going from CLOSED to CLOSED, nothing to do.
431 if(TO_STATE == utils::OV_CLOSED) return NULL;
432 ALOGD("FROM_STATE = %s TO_STATE = %s",
433 utils::getStateString(utils::OV_CLOSED),
434 utils::getStateString(TO_STATE));
435 OverlayImplBase* ov = new typename StateTraits<TO_STATE>::ovimpl;
436 RotatorBase* rot0 = new typename StateTraits<TO_STATE>::rot0;
437 RotatorBase* rot1 = new typename StateTraits<TO_STATE>::rot1;
438 RotatorBase* rot2 = new typename StateTraits<TO_STATE>::rot2;
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700439 if(!ov->init(rot0, rot1, rot2)) {
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700440 ALOGE("Overlay failed to init in state %d", TO_STATE);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700441 return 0;
442 }
443 return ov;
444}
445
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700446/* Transition from ANY to CLOSED */
447template<utils::eOverlayState FROM_STATE>
448inline OverlayImplBase* OverlayState::handle_xxx_to_CLOSED(OverlayImplBase* ov)
Naseer Ahmed29a26812012-06-14 00:56:20 -0700449{
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700450 //If going from CLOSED to CLOSED, nothing to do.
451 if(FROM_STATE == utils::OV_CLOSED) return NULL;
452 ALOGD("FROM_STATE = %s TO_STATE = %s",
453 utils::getStateString(FROM_STATE),
454 utils::getStateString(utils::OV_CLOSED));
Naseer Ahmed29a26812012-06-14 00:56:20 -0700455 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700456 if(!ov->close()) {
457 ALOGE("%s: Failed to ov close", __FUNCTION__);
458 }
459 delete ov;
460 ov = 0;
461 return 0;
462}
463
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700464/* Transition from 2D_VIDEO_ON_PANEL to 2D_VIDEO_ON_PANEL_TV */
465template<>
466inline OverlayImplBase* OverlayState::handle_from_to<
467 utils::OV_2D_VIDEO_ON_PANEL,
468 utils::OV_2D_VIDEO_ON_PANEL_TV>(
469 OverlayImplBase* ov) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700470 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700471 ALOGD("FROM_STATE = %s TO_STATE = %s",
472 utils::getStateString(utils::OV_2D_VIDEO_ON_PANEL),
473 utils::getStateString(utils::OV_2D_VIDEO_ON_PANEL_TV));
474 // Create new ovimpl based on new state
475 typedef StateTraits<utils::OV_2D_VIDEO_ON_PANEL_TV> NewState;
476 OverlayImplBase* newov = new NewState::ovimpl;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700477
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700478 //copy pipe0/rot0 (primary video)
479 newov->copyOvPipe(ov, utils::OV_PIPE0);
480 //close old pipe1, create new pipe1
481 ov->closePipe(utils::OV_PIPE1);
482 RotatorBase* rot1 = new NewState::rot1;
483 newov->initPipe(rot1, utils::OV_PIPE1);
484 //close old pipe2, create new pipe2
485 ov->closePipe(utils::OV_PIPE2);
486 RotatorBase* rot2 = new NewState::rot2;
487 newov->initPipe(rot2, utils::OV_PIPE2);
488 // All pipes are copied or deleted so no more need for previous ovimpl
489 delete ov;
490 ov = 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700491 return newov;
492}
493
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700494/* Transition from 2D_VIDEO_ON_PANEL_TV to 2D_VIDEO_ON_PANEL */
495template<>
496inline OverlayImplBase* OverlayState::handle_from_to<
497 utils::OV_2D_VIDEO_ON_PANEL_TV,
498 utils::OV_2D_VIDEO_ON_PANEL>(
499 OverlayImplBase* ov) {
500 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
501 ALOGD("FROM_STATE = %s TO_STATE = %s",
502 utils::getStateString(utils::OV_2D_VIDEO_ON_PANEL_TV),
503 utils::getStateString(utils::OV_2D_VIDEO_ON_PANEL));
Naseer Ahmed29a26812012-06-14 00:56:20 -0700504
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700505 // Create new ovimpl based on new state
506 typedef StateTraits<utils::OV_2D_VIDEO_ON_PANEL> NewState;
507 OverlayImplBase* newov = new NewState::ovimpl;
508
509 //copy pipe0/rot0 (primary video)
510 newov->copyOvPipe(ov, utils::OV_PIPE0);
511 //close old pipe1, create new pipe1
512 ov->closePipe(utils::OV_PIPE1);
513 RotatorBase* rot1 = new NewState::rot1;
514 newov->initPipe(rot1, utils::OV_PIPE1);
515 //close old pipe2, create new pipe2
516 ov->closePipe(utils::OV_PIPE2);
517 RotatorBase* rot2 = new NewState::rot2;
518 newov->initPipe(rot2, utils::OV_PIPE2);
519 // All pipes are copied or deleted so no more need for previous ovimpl
520 delete ov;
521 ov = 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700522 return newov;
523}
524
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700525/* Transition from 2D_VIDEO_ON_PANEL_TV to 2D_VIDEO_ON_TV */
526template<>
527inline OverlayImplBase* OverlayState::handle_from_to<
528 utils::OV_2D_VIDEO_ON_PANEL_TV,
529 utils::OV_2D_VIDEO_ON_TV>(
530 OverlayImplBase* ov) {
531 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
532 ALOGD("FROM_STATE = %s TO_STATE = %s",
533 utils::getStateString(utils::OV_2D_VIDEO_ON_PANEL_TV),
534 utils::getStateString(utils::OV_2D_VIDEO_ON_TV));
535
536 // Create new ovimpl based on new state
537 typedef StateTraits<utils::OV_2D_VIDEO_ON_TV> NewState;
538 OverlayImplBase* newov = new NewState::ovimpl;
539
540 //close old pipe0, create new pipe0
541 ov->closePipe(utils::OV_PIPE0);
542 RotatorBase* rot0 = new NewState::rot0;
543 newov->initPipe(rot0, utils::OV_PIPE0);
544 //copy pipe1/rot1 (ext video)
545 newov->copyOvPipe(ov, utils::OV_PIPE1);
546 //copy pipe2/rot2 (ext cc)
547 newov->copyOvPipe(ov, utils::OV_PIPE2);
548 // All pipes are copied or deleted so no more need for previous ovimpl
549 delete ov;
550 ov = 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700551 return newov;
552}
553
Naseer Ahmed2cc53dd2012-07-31 19:11:48 -0700554/* Transition from 2D_VIDEO_ON_TV to 2D_VIDEO_ON_PANEL_TV */
555template<>
556inline OverlayImplBase* OverlayState::handle_from_to<
557 utils::OV_2D_VIDEO_ON_TV,
558 utils::OV_2D_VIDEO_ON_PANEL_TV>(
559 OverlayImplBase* ov) {
560 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
561 ALOGD("FROM_STATE = %s TO_STATE = %s",
562 utils::getStateString(utils::OV_2D_VIDEO_ON_TV),
563 utils::getStateString(utils::OV_2D_VIDEO_ON_PANEL_TV));
564
565 // Create new ovimpl based on new state
566 typedef StateTraits<utils::OV_2D_VIDEO_ON_PANEL_TV> NewState;
567 OverlayImplBase* newov = new NewState::ovimpl;
568
569 //close old pipe0, create new pipe0
570 ov->closePipe(utils::OV_PIPE0);
571 RotatorBase* rot0 = new NewState::rot0;
572 newov->initPipe(rot0, utils::OV_PIPE0);
573 //copy pipe1/rot1 (ext video)
574 newov->copyOvPipe(ov, utils::OV_PIPE1);
575 //copy pipe2/rot2 (ext cc)
576 newov->copyOvPipe(ov, utils::OV_PIPE2);
577 // All pipes are copied or deleted so no more need for previous ovimpl
578 delete ov;
579 ov = 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700580 return newov;
581}
582
Naseer Ahmed29a26812012-06-14 00:56:20 -0700583} // overlay
584
585#endif // OVERLAY_STATE_H