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/internal/offscreen/common/offscreen-application-impl.h>
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>
34 using RenderMode = Dali::OffscreenApplication::RenderMode;
36 IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
38 IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent, renderMode );
39 return offscreenApplication;
42 OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
44 // Generate a default window
45 IntrusivePtr< Internal::OffscreenWindow > impl = Internal::OffscreenWindow::New( width, height, surface, isTranslucent );
46 mDefaultWindow = Dali::OffscreenWindow( impl.Get() );
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 ) );
51 // Initialize default window
52 impl->Initialize( true );
55 void OffscreenApplication::Start()
60 Dali::OffscreenApplication handle( this );
62 mAdaptor->NotifySceneCreated();
65 void OffscreenApplication::Stop()
70 Dali::OffscreenApplication handle( this );
71 mTerminateSignal.Emit();
74 Dali::OffscreenWindow OffscreenApplication::GetWindow()
76 return mDefaultWindow;
79 void OffscreenApplication::RenderOnce()
81 mAdaptor->RenderOnce();
84 } // namespace Internal