Revert "[Tizen] Add GlWindow"
[platform/core/uifw/dali-adaptor.git] / dali / internal / offscreen / common / offscreen-application-impl.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/offscreen/common/offscreen-application-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/adaptor/common/adaptor-impl.h>
23 #include <dali/internal/offscreen/common/offscreen-window-impl.h>
24 #include <dali/internal/adaptor/common/thread-controller-interface.h>
25 #include <dali/integration-api/adaptor-framework/adaptor.h>
26 #include <dali/integration-api/adaptor-framework/native-render-surface.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 using RenderMode = Dali::OffscreenApplication::RenderMode;
35
36 IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
37 {
38   IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent, renderMode );
39   return offscreenApplication;
40 }
41
42 OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
43 {
44   // Generate a default window
45   IntrusivePtr< Internal::OffscreenWindow > impl = Internal::OffscreenWindow::New( width, height, surface, isTranslucent );
46   mDefaultWindow = Dali::OffscreenWindow( impl.Get() );
47
48   mAdaptor.reset( Dali::Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( impl.Get() ), impl->GetSurface(), NULL,
49                             renderMode == RenderMode::AUTO ? Dali::Internal::Adaptor::ThreadMode::NORMAL : Dali::Internal::Adaptor::ThreadMode::RUN_IF_REQUESTED ) );
50
51   // Initialize default window
52   impl->Initialize( true );
53 }
54
55 void OffscreenApplication::Start()
56 {
57   // Start the adaptor
58   mAdaptor->Start();
59
60   Dali::OffscreenApplication handle( this );
61   mInitSignal.Emit();
62   mAdaptor->NotifySceneCreated();
63 }
64
65 void OffscreenApplication::Stop()
66 {
67   // Stop the adaptor
68   mAdaptor->Stop();
69
70   Dali::OffscreenApplication handle( this );
71   mTerminateSignal.Emit();
72 }
73
74 Dali::OffscreenWindow OffscreenApplication::GetWindow()
75 {
76   return mDefaultWindow;
77 }
78
79 void OffscreenApplication::RenderOnce()
80 {
81   mAdaptor->RenderOnce();
82 }
83
84 } // namespace Internal
85
86 } // namespace Dali