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/integration-api/adaptor-framework/native-render-surface.h>
23 #include <dali/internal/offscreen/common/offscreen-window-impl.h>
24 #include <dali/internal/offscreen/common/offscreen-window-factory.h>
27 #include <dali/internal/offscreen/common/offscreen-application-impl.h>
35 IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent)
37 IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent );
38 return offscreenApplication;
41 OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent )
44 // Generate a default window
45 auto windowFactory = Dali::Internal::GetOffscreenWindowFactory();
46 IntrusivePtr <Internal::OffscreenWindow > windowPtr = windowFactory->CreateOffscreenWindow( width, height, surface, isTranslucent ).release();
47 mDefaultWindow = Dali::OffscreenWindow( windowPtr.Get() );
49 // Generate DALi adaptor
50 NativeRenderSurface* naitveSurface = static_cast<NativeRenderSurface*>( windowPtr->GetSurface() );
52 mAdaptor = &Dali::Adaptor::New( Dali::Integration::SceneHolder( windowPtr.Get() ), *naitveSurface, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
54 // Initialize default window
55 windowPtr->Initialize( this, true );
58 OffscreenApplication::~OffscreenApplication()
64 Dali::Adaptor* OffscreenApplication::GetAdaptor()
69 void OffscreenApplication::Run()
78 mPreInitSignal.Emit();
82 mAdaptor->NotifySceneCreated();
86 void OffscreenApplication::Stop()
88 if( mState != STOPPED )
94 mTerminateSignal.Emit();
98 Dali::OffscreenWindow OffscreenApplication::GetWindow()
100 return mDefaultWindow;
103 } // namespace Internal