2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
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>
29 #include <dali/internal/offscreen/common/offscreen-application-impl.h>
31 using Dali::Internal::Adaptor::ThreadMode;
39 IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
41 IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent, renderMode );
42 return offscreenApplication;
45 OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
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() );
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 );
56 // Initialize default window
57 windowPtr->Initialize( true );
60 OffscreenApplication::~OffscreenApplication()
66 void OffscreenApplication::Start()
71 mAdaptor->NotifySceneCreated();
74 void OffscreenApplication::Stop()
78 mTerminateSignal.Emit();
81 Dali::OffscreenWindow OffscreenApplication::GetWindow()
83 return mDefaultWindow;
86 void OffscreenApplication::RenderOnce()
88 mAdaptor->RenderOnce();
91 } // namespace Internal