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>
28 using Dali::Internal::Adaptor::ThreadMode;
29 using RenderMode = Dali::OffscreenApplication::RenderMode;
37 IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
39 IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent, renderMode );
40 return offscreenApplication;
43 OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
45 // Generate a default window
46 IntrusivePtr< Internal::OffscreenWindow > impl = Internal::OffscreenWindow::New( width, height, surface, isTranslucent );
47 mDefaultWindow = Dali::OffscreenWindow( impl.Get() );
49 mAdaptor.reset( Dali::Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( impl.Get() ), impl->GetSurface(), NULL,
50 renderMode == RenderMode::AUTO ?
51 Dali::Internal::Adaptor::ThreadMode::NORMAL : Dali::Internal::Adaptor::ThreadMode::RUN_IF_REQUESTED ) );
53 // Initialize default window
54 impl->Initialize( true );
57 void OffscreenApplication::Start()
62 mAdaptor->NotifySceneCreated();
65 void OffscreenApplication::Stop()
69 mTerminateSignal.Emit();
72 Dali::OffscreenWindow OffscreenApplication::GetWindow()
74 return mDefaultWindow;
77 void OffscreenApplication::RenderOnce()
79 mAdaptor->RenderOnce();
82 } // namespace Internal