blob: 8096ad52af83a22daa88020382dc991d0e4c51fe [file] [log] [blame]
Naseer Ahmed29a26812012-06-14 00:56:20 -07001/*
2* Copyright (c) 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#include "overlayState.h"
31
32namespace overlay {
33
34/*
35 * Transition from any state to 2D video on 2D panel
36 */
37OverlayImplBase* OverlayState::handle_xxx_to_2D_2DPanel(
38 OverlayImplBase* ov)
39{
40 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
41 ALOGE("%s", __FUNCTION__);
42
43 // Create new ovimpl based on new state
44 typedef StateTraits<utils::OV_2D_VIDEO_ON_PANEL> NewState;
Naseer Ahmedf48aef62012-07-20 09:05:53 -070045 OverlayImplBase* newov = new NewState::ovimpl();
Naseer Ahmed29a26812012-06-14 00:56:20 -070046
47 //===========================================================
48 // For each pipe:
49 // - If pipe matches, copy from previous into new ovimpl
Naseer Ahmedf48aef62012-07-20 09:05:53 -070050 // - Otherwise init for new and delete from previous ovimpl
Naseer Ahmed29a26812012-06-14 00:56:20 -070051 //===========================================================
52
53 // pipe0/rot0 (GenericPipe)
54 if (ov->getOvPipeType(utils::OV_PIPE0) == utils::OV_PIPE_TYPE_GENERIC) {
55 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe0 (GenericPipe)", __FUNCTION__);
56 newov->copyOvPipe(ov, utils::OV_PIPE0);
57 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -070058 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe0 (GenericPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -070059 ov->closePipe(utils::OV_PIPE0);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070060 RotatorBase* rot0 = new NewState::rot0;
61 newov->initPipe(rot0, utils::OV_PIPE0);
Naseer Ahmed29a26812012-06-14 00:56:20 -070062 }
63
64 // pipe1/rot1 (NullPipe)
65 if (ov->getOvPipeType(utils::OV_PIPE1) == utils::OV_PIPE_TYPE_NULL) {
66 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe1 (NullPipe)", __FUNCTION__);
67 newov->copyOvPipe(ov, utils::OV_PIPE1);
68 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -070069 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe1 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -070070 ov->closePipe(utils::OV_PIPE1);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070071 RotatorBase* rot1 = new NewState::rot1;
72 newov->initPipe(rot1, utils::OV_PIPE1);
Naseer Ahmed29a26812012-06-14 00:56:20 -070073 }
74
75 // pipe2/rot2 (NullPipe)
76 if (ov->getOvPipeType(utils::OV_PIPE2) == utils::OV_PIPE_TYPE_NULL) {
77 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe2 (NullPipe)", __FUNCTION__);
78 newov->copyOvPipe(ov, utils::OV_PIPE2);
79 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -070080 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe2 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -070081 ov->closePipe(utils::OV_PIPE2);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070082 RotatorBase* rot2 = new NewState::rot2;
83 newov->initPipe(rot2, utils::OV_PIPE2);
Naseer Ahmed29a26812012-06-14 00:56:20 -070084 }
85
86 // All pipes are copied or deleted so no more need for previous ovimpl
87 delete ov;
88 ov = 0;
89
90 return newov;
91}
92
93/*
94 * Transition from any state to 2D video on 2D panel and 2D TV
95 */
96OverlayImplBase* OverlayState::handle_xxx_to_2D_2DTV(
97 OverlayImplBase* ov)
98{
99 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
100 ALOGE("%s", __FUNCTION__);
101
102 // Create new ovimpl based on new state
103 typedef StateTraits<utils::OV_2D_VIDEO_ON_PANEL_TV> NewState;
104 OverlayImplBase* newov = new NewState::ovimpl;
105
106 //===========================================================
107 // For each pipe:
108 // - If pipe matches, copy from previous into new ovimpl
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700109 // - Otherwise init for new and delete from previous ovimpl
Naseer Ahmed29a26812012-06-14 00:56:20 -0700110 //===========================================================
111
112 // pipe0/rot0 (GenericPipe)
113 if (ov->getOvPipeType(utils::OV_PIPE0) == utils::OV_PIPE_TYPE_GENERIC) {
114 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe0 (GenericPipe)", __FUNCTION__);
115 newov->copyOvPipe(ov, utils::OV_PIPE0);
116 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700117 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe0 (GenericPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700118 RotatorBase* rot0 = new NewState::rot0;
119 ov->closePipe(utils::OV_PIPE0);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700120 newov->initPipe(rot0, utils::OV_PIPE0);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700121 }
122
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700123 // pipe1/rot1 (VideoExtPipe)
124 if (ov->getOvPipeType(utils::OV_PIPE1) == utils::OV_PIPE_TYPE_VIDEO_EXT) {
125 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe1 (VideoExtPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700126 newov->copyOvPipe(ov, utils::OV_PIPE1);
127 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700128 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe1 (VideoExtPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700129 RotatorBase* rot1 = new NewState::rot1;
130 ov->closePipe(utils::OV_PIPE1);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700131 newov->initPipe(rot1, utils::OV_PIPE1);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700132 }
133
134 // pipe2/rot2 (NullPipe)
135 if (ov->getOvPipeType(utils::OV_PIPE2) == utils::OV_PIPE_TYPE_NULL) {
136 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe2 (NullPipe)", __FUNCTION__);
137 newov->copyOvPipe(ov, utils::OV_PIPE2);
138 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700139 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe2 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700140 RotatorBase* rot2 = new NewState::rot2;
141 ov->closePipe(utils::OV_PIPE2);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700142 newov->initPipe(rot2, utils::OV_PIPE2);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700143 }
144
145 // All pipes are copied or deleted so no more need for previous ovimpl
146 delete ov;
147 ov = 0;
148
149 return newov;
150}
151
152/*
153 * Transition from any state to 3D video on 2D panel
154 */
155OverlayImplBase* OverlayState::handle_xxx_to_3D_2DPanel(
156 OverlayImplBase* ov)
157{
158 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
159 ALOGE("%s", __FUNCTION__);
160
161 // Create new ovimpl based on new state
162 typedef StateTraits<utils::OV_3D_VIDEO_ON_2D_PANEL> NewState;
163 OverlayImplBase* newov = new NewState::ovimpl;
164
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700165 //=================================================================
Naseer Ahmed29a26812012-06-14 00:56:20 -0700166 // For each pipe:
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700167 // - If pipe matches, copy from previous into new ovimpl.
168 // (which also makes previous pipe ref 0, so nobody can use)
169 // - Otherwise init pipe for new ovimpl and delete from previous
170 //=================================================================
Naseer Ahmed29a26812012-06-14 00:56:20 -0700171
172 // pipe0/rot0 (M3DPrimaryPipe)
173 if (ov->getOvPipeType(utils::OV_PIPE0) == utils::OV_PIPE_TYPE_M3D_PRIMARY) {
174 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe0 (M3DPrimaryPipe)", __FUNCTION__);
175 newov->copyOvPipe(ov, utils::OV_PIPE0);
176 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700177 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe0 (M3DPrimaryPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700178 RotatorBase* rot0 = new NewState::rot0;
179 ov->closePipe(utils::OV_PIPE0);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700180 newov->initPipe(rot0, utils::OV_PIPE0);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700181 }
182
183 // pipe1/rot1 (NullPipe)
184 if (ov->getOvPipeType(utils::OV_PIPE1) == utils::OV_PIPE_TYPE_NULL) {
185 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe1 (NullPipe)", __FUNCTION__);
186 newov->copyOvPipe(ov, utils::OV_PIPE1);
187 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700188 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe1 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700189 RotatorBase* rot1 = new NewState::rot1;
190 ov->closePipe(utils::OV_PIPE1);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700191 newov->initPipe(rot1, utils::OV_PIPE1);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700192 }
193
194 // pipe2/rot2 (NullPipe)
195 if (ov->getOvPipeType(utils::OV_PIPE2) == utils::OV_PIPE_TYPE_NULL) {
196 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe2 (NullPipe)", __FUNCTION__);
197 newov->copyOvPipe(ov, utils::OV_PIPE2);
198 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700199 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe2 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700200 RotatorBase* rot2 = new NewState::rot2;
201 ov->closePipe(utils::OV_PIPE2);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700202 newov->initPipe(rot2, utils::OV_PIPE2);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700203 }
204
205 // All pipes are copied or deleted so no more need for previous ovimpl
206 delete ov;
207 ov = 0;
208
209 return newov;
210}
211
212/*
213 * Transition from any state to 3D video on 2D panel and 2D TV
214 */
215OverlayImplBase* OverlayState::handle_xxx_to_3D_2DTV(
216 OverlayImplBase* ov)
217{
218 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
219 ALOGE("%s", __FUNCTION__);
220
221 // Create new ovimpl based on new state
222 typedef StateTraits<utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV> NewState;
223 OverlayImplBase* newov = new NewState::ovimpl;
224
225 //===========================================================
226 // For each pipe:
227 // - If pipe matches, copy from previous into new ovimpl
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700228 // - Otherwise init for new and delete from previous ovimpl
Naseer Ahmed29a26812012-06-14 00:56:20 -0700229 //===========================================================
230
231 // pipe0/rot0 (M3DPrimaryPipe)
232 if (ov->getOvPipeType(utils::OV_PIPE0) == utils::OV_PIPE_TYPE_M3D_PRIMARY) {
233 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe0 (M3DPrimaryPipe)", __FUNCTION__);
234 newov->copyOvPipe(ov, utils::OV_PIPE0);
235 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700236 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe0 (M3DPrimaryPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700237 RotatorBase* rot0 = new NewState::rot0;
238 ov->closePipe(utils::OV_PIPE0);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700239 newov->initPipe(rot0, utils::OV_PIPE0);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700240 }
241
242 // pipe1/rot1 (M3DExtPipe)
243 if (ov->getOvPipeType(utils::OV_PIPE1) == utils::OV_PIPE_TYPE_M3D_EXTERNAL) {
244 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe1 (M3DExtPipe)", __FUNCTION__);
245 newov->copyOvPipe(ov, utils::OV_PIPE1);
246 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700247 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe1 (M3DExtPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700248 RotatorBase* rot1 = new NewState::rot1;
249 ov->closePipe(utils::OV_PIPE1);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700250 newov->initPipe(rot1, utils::OV_PIPE1);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700251 }
252
253 // pipe2/rot2 (NullPipe)
254 if (ov->getOvPipeType(utils::OV_PIPE2) == utils::OV_PIPE_TYPE_NULL) {
255 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe2 (NullPipe)", __FUNCTION__);
256 newov->copyOvPipe(ov, utils::OV_PIPE2);
257 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700258 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe2 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700259 RotatorBase* rot2 = new NewState::rot2;
260 ov->closePipe(utils::OV_PIPE2);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700261 newov->initPipe(rot2, utils::OV_PIPE2);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700262 }
263
264 // All pipes are copied or deleted so no more need for previous ovimpl
265 delete ov;
266 ov = 0;
267
268 return newov;
269}
270
271/*
272 * Transition from any state to 2D true UI mirroring (2D video + UI)
273 */
274OverlayImplBase* OverlayState::handle_xxx_to_2D_trueUI_Mirror(
275 OverlayImplBase* ov)
276{
277 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
278 ALOGE("%s", __FUNCTION__);
279
280 // Create new ovimpl based on new state
281 typedef StateTraits<utils::OV_2D_TRUE_UI_MIRROR> NewState;
282 OverlayImplBase* newov = new NewState::ovimpl;
283
284 //===========================================================
285 // For each pipe:
286 // - If pipe matches, copy from previous into new ovimpl
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700287 // - Otherwise init for new and delete from previous ovimpl
Naseer Ahmed29a26812012-06-14 00:56:20 -0700288 //===========================================================
289
290 // pipe0/rot0 (GenericPipe)
291 if (ov->getOvPipeType(utils::OV_PIPE0) == utils::OV_PIPE_TYPE_GENERIC) {
292 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe0 (GenericPipe)", __FUNCTION__);
293 newov->copyOvPipe(ov, utils::OV_PIPE0);
294 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700295 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe0 (GenericPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700296 RotatorBase* rot0 = new NewState::rot0;
297 ov->closePipe(utils::OV_PIPE0);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700298 newov->initPipe(rot0, utils::OV_PIPE0);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700299 }
300
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700301 // pipe1/rot1 (VideoExtPipe)
302 if (ov->getOvPipeType(utils::OV_PIPE1) == utils::OV_PIPE_TYPE_VIDEO_EXT) {
303 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe1 (VideoExtPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700304 newov->copyOvPipe(ov, utils::OV_PIPE1);
305 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700306 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe1 (VideoExtPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700307 RotatorBase* rot1 = new NewState::rot1;
308 ov->closePipe(utils::OV_PIPE1);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700309 newov->initPipe(rot1, utils::OV_PIPE1);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700310 }
311
312 // pipe2/rot2 (UIMirrorPipe)
313 if (ov->getOvPipeType(utils::OV_PIPE2) == utils::OV_PIPE_TYPE_UI_MIRROR) {
314 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe2 (UIMirrorPipe)", __FUNCTION__);
315 newov->copyOvPipe(ov, utils::OV_PIPE2);
316 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700317 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe2 (UIMirrorPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700318 RotatorBase* rot2 = new NewState::rot2;
319 ov->closePipe(utils::OV_PIPE2);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700320 newov->initPipe(rot2, utils::OV_PIPE2);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700321 }
322
323 // All pipes are copied or deleted so no more need for previous ovimpl
324 delete ov;
325 ov = 0;
326
327 return newov;
328}
329
330/*
331 * Transitions from any state to 1 layer composition bypass
332 */
333OverlayImplBase* OverlayState::handle_xxx_to_bypass1(OverlayImplBase* ov)
334{
335 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
336 ALOGE("%s", __FUNCTION__);
337
338 // Create new ovimpl based on new state
339 typedef StateTraits<utils::OV_BYPASS_1_LAYER> NewState;
340 OverlayImplBase* newov = new NewState::ovimpl;
341
342 //===========================================================
343 // For each pipe:
344 // - If pipe matches, copy from previous into new ovimpl
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700345 // - Otherwise init for new and delete from previous ovimpl
Naseer Ahmed29a26812012-06-14 00:56:20 -0700346 //===========================================================
347
348 // pipe0/rot0 (BypassPipe)
349 if (ov->getOvPipeType(utils::OV_PIPE0) == utils::OV_PIPE_TYPE_BYPASS) {
350 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe0 (BypassPipe)", __FUNCTION__);
351 newov->copyOvPipe(ov, utils::OV_PIPE0);
352 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700353 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe0 (BypassPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700354 RotatorBase* rot0 = new NewState::rot0;
355 ov->closePipe(utils::OV_PIPE0);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700356 newov->initPipe(rot0, utils::OV_PIPE0);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700357 }
358
359 // pipe1/rot1 (NullPipe)
360 if (ov->getOvPipeType(utils::OV_PIPE1) == utils::OV_PIPE_TYPE_NULL) {
361 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe1 (NullPipe)", __FUNCTION__);
362 newov->copyOvPipe(ov, utils::OV_PIPE1);
363 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700364 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe1 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700365 RotatorBase* rot1 = new NewState::rot1;
366 ov->closePipe(utils::OV_PIPE1);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700367 newov->initPipe(rot1, utils::OV_PIPE1);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700368 }
369
370 // pipe2/rot2 (NullPipe)
371 if (ov->getOvPipeType(utils::OV_PIPE2) == utils::OV_PIPE_TYPE_NULL) {
372 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe2 (NullPipe)", __FUNCTION__);
373 newov->copyOvPipe(ov, utils::OV_PIPE2);
374 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700375 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe2 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700376 RotatorBase* rot2 = new NewState::rot2;
377 ov->closePipe(utils::OV_PIPE2);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700378 newov->initPipe(rot2, utils::OV_PIPE2);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700379 }
380
381 // All pipes are copied or deleted so no more need for previous ovimpl
382 delete ov;
383 ov = 0;
384
385 return newov;
386}
387
388/*
389 * Transitions from any state to 2 layers composition bypass
390 */
391OverlayImplBase* OverlayState::handle_xxx_to_bypass2(OverlayImplBase* ov)
392{
393 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
394 ALOGE("%s", __FUNCTION__);
395
396 // Create new ovimpl based on new state
397 typedef StateTraits<utils::OV_BYPASS_2_LAYER> NewState;
398 OverlayImplBase* newov = new NewState::ovimpl;
399
400 //===========================================================
401 // For each pipe:
402 // - If pipe matches, copy from previous into new ovimpl
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700403 // - Otherwise init for new and delete from previous ovimpl
Naseer Ahmed29a26812012-06-14 00:56:20 -0700404 //===========================================================
405
406 // pipe0/rot0 (BypassPipe)
407 if (ov->getOvPipeType(utils::OV_PIPE0) == utils::OV_PIPE_TYPE_BYPASS) {
408 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe0 (BypassPipe)", __FUNCTION__);
409 newov->copyOvPipe(ov, utils::OV_PIPE0);
410 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700411 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe0 (BypassPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700412 RotatorBase* rot0 = new NewState::rot0;
413 ov->closePipe(utils::OV_PIPE0);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700414 newov->initPipe(rot0, utils::OV_PIPE0);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700415 }
416
417 // pipe1/rot1 (BypassPipe)
418 if (ov->getOvPipeType(utils::OV_PIPE1) == utils::OV_PIPE_TYPE_BYPASS) {
419 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe1 (BypassPipe)", __FUNCTION__);
420 newov->copyOvPipe(ov, utils::OV_PIPE1);
421 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700422 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe1 (BypassPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700423 RotatorBase* rot1 = new NewState::rot1;
424 ov->closePipe(utils::OV_PIPE1);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700425 newov->initPipe(rot1, utils::OV_PIPE1);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700426 }
427
428 // pipe2/rot2 (NullPipe)
429 if (ov->getOvPipeType(utils::OV_PIPE2) == utils::OV_PIPE_TYPE_NULL) {
430 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe2 (NullPipe)", __FUNCTION__);
431 newov->copyOvPipe(ov, utils::OV_PIPE2);
432 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700433 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe2 (NullPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700434 RotatorBase* rot2 = new NewState::rot2;
435 ov->closePipe(utils::OV_PIPE2);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700436 newov->initPipe(rot2, utils::OV_PIPE2);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700437 }
438
439 // All pipes are copied or deleted so no more need for previous ovimpl
440 delete ov;
441 ov = 0;
442
443 return newov;
444}
445
446/*
447 * Transitions from any state to 3 layers composition bypass
448 */
449OverlayImplBase* OverlayState::handle_xxx_to_bypass3(OverlayImplBase* ov)
450{
451 OVASSERT(ov, "%s: ov is null", __FUNCTION__);
452 ALOGE("%s", __FUNCTION__);
453
454 // Create new ovimpl based on new state
455 typedef StateTraits<utils::OV_BYPASS_3_LAYER> NewState;
456 OverlayImplBase* newov = new NewState::ovimpl;
457
458 //===========================================================
459 // For each pipe:
460 // - If pipe matches, copy from previous into new ovimpl
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700461 // - Otherwise init for new and delete from previous ovimpl
Naseer Ahmed29a26812012-06-14 00:56:20 -0700462 //===========================================================
463
464 // pipe0/rot0 (BypassPipe)
465 if (ov->getOvPipeType(utils::OV_PIPE0) == utils::OV_PIPE_TYPE_BYPASS) {
466 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe0 (BypassPipe)", __FUNCTION__);
467 newov->copyOvPipe(ov, utils::OV_PIPE0);
468 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700469 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe0 (BypassPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700470 RotatorBase* rot0 = new NewState::rot0;
471 ov->closePipe(utils::OV_PIPE0);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700472 newov->initPipe(rot0, utils::OV_PIPE0);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700473 }
474
475 // pipe1/rot1 (BypassPipe)
476 if (ov->getOvPipeType(utils::OV_PIPE1) == utils::OV_PIPE_TYPE_BYPASS) {
477 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe1 (BypassPipe)", __FUNCTION__);
478 newov->copyOvPipe(ov, utils::OV_PIPE1);
479 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700480 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe1 (BypassPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700481 RotatorBase* rot1 = new NewState::rot1;
482 ov->closePipe(utils::OV_PIPE1);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700483 newov->initPipe(rot1, utils::OV_PIPE1);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700484 }
485
486 // pipe2/rot2 (BypassPipe)
487 if (ov->getOvPipeType(utils::OV_PIPE2) == utils::OV_PIPE_TYPE_BYPASS) {
488 ALOGE_IF(DEBUG_OVERLAY, "%s: Copy pipe2 (BypassPipe)", __FUNCTION__);
489 newov->copyOvPipe(ov, utils::OV_PIPE2);
490 } else {
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700491 ALOGE_IF(DEBUG_OVERLAY, "%s: init pipe2 (BypassPipe)", __FUNCTION__);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700492 RotatorBase* rot2 = new NewState::rot2;
493 ov->closePipe(utils::OV_PIPE2);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700494 newov->initPipe(rot2, utils::OV_PIPE2);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700495 }
496
497 // All pipes are copied or deleted so no more need for previous ovimpl
498 delete ov;
499 ov = 0;
500
501 return newov;
502}
503
504} // overlay