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 // EXTERNAL INCLUDES
19 #include <dali/integration-api/adaptor-framework/adaptor.h>
20 #include <dali/internal/adaptor/common/adaptor-impl.h>
21 #include <dali/integration-api/adaptor-framework/native-render-surface.h>
22
23 // INTERNAL INCLUDES
24 #include <dali/internal/offscreen/common/offscreen-window-impl.h>
25 #include <dali/internal/offscreen/common/offscreen-window-factory.h>
26 #include <dali/internal/adaptor/common/thread-controller-interface.h>
27
28 // CLASS HEADER
29 #include <dali/internal/offscreen/common/offscreen-application-impl.h>
30
31 using Dali::Internal::Adaptor::ThreadMode;
32
33 namespace Dali
34 {
35
36 namespace Internal
37 {
38
39 IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
40 {
41   IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent, renderMode );
42   return offscreenApplication;
43 }
44
45 OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
46 {
47   // Generate a default window
48   auto windowFactory = Dali::Internal::GetOffscreenWindowFactory();
49   IntrusivePtr <Internal::OffscreenWindow > windowPtr = windowFactory->CreateOffscreenWindow( width, height, surface, isTranslucent ).release();
50   mDefaultWindow = Dali::OffscreenWindow( windowPtr.Get() );
51
52   mAdaptor = Dali::Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( windowPtr.Get() ), windowPtr->GetSurface(),
53                             Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS, NULL,
54                             renderMode == RenderMode::AUTO ? ThreadMode::NORMAL : ThreadMode::RUN_IF_REQUESTED );
55
56   // Initialize default window
57   windowPtr->Initialize( true );
58 }
59
60 OffscreenApplication::~OffscreenApplication()
61 {
62   delete mAdaptor;
63   mAdaptor = nullptr;
64 }
65
66 void OffscreenApplication::Start()
67 {
68    // Start the adaptor
69    mAdaptor->Start();
70    mInitSignal.Emit();
71    mAdaptor->NotifySceneCreated();
72 }
73
74 void OffscreenApplication::Stop()
75 {
76   // Stop the adaptor
77   mAdaptor->Stop();
78   mTerminateSignal.Emit();
79 }
80
81 Dali::OffscreenWindow OffscreenApplication::GetWindow()
82 {
83   return mDefaultWindow;
84 }
85
86 void OffscreenApplication::RenderOnce()
87 {
88   mAdaptor->RenderOnce();
89 }
90
91 } // namespace Internal
92
93 } // namespace Dali