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/devel-api/adaptor-framework/clipboard.h>
20 #include <dali/devel-api/adaptor-framework/accessibility-adaptor.h>
21 #include <dali/integration-api/adaptor-framework/adaptor.h>
22 #include <dali/integration-api/adaptor-framework/native-render-surface.h>
23 #include <dali/integration-api/adaptor-framework/native-render-surface-factory.h>
24 #include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
25 #include <dali/integration-api/debug.h>
26 #include <dali/public-api/actors/layer.h>
27 #include <tbm_surface.h>
28 #include <tbm_surface_queue.h>
31 #include <dali/internal/offscreen/common/offscreen-application-impl.h>
34 #include <dali/internal/offscreen/tizen/offscreen-window-impl-tizen.h>
42 OffscreenWindowTizen* OffscreenWindowTizen::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent )
44 OffscreenWindowTizen* window = new OffscreenWindowTizen( width, height, surface, isTranslucent );
48 OffscreenWindowTizen::OffscreenWindowTizen( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent )
49 : mRenderNotification(),
50 mIsTranslucent( isTranslucent )
53 if ( surface.Empty() )
55 mSurface = std::unique_ptr< RenderSurfaceInterface >( CreateNativeSurface( SurfaceSize( width, height ), surface, isTranslucent ) );
59 width = static_cast<uint16_t>( tbm_surface_queue_get_width( AnyCast< tbm_surface_queue_h > ( surface ) ) );
60 height = static_cast<uint16_t>( tbm_surface_queue_get_height( AnyCast< tbm_surface_queue_h > ( surface ) ) );
61 mSurface = std::unique_ptr< RenderSurfaceInterface >( CreateNativeSurface( SurfaceSize( width, height ), surface, isTranslucent ) );
65 void OffscreenWindowTizen::Initialize( bool isDefaultWindow )
73 Dali::Integration::SceneHolder sceneHolderHandler = Dali::Integration::SceneHolder( this );
74 Dali::Adaptor::Get().AddWindow( sceneHolderHandler, "", "", mIsTranslucent );
79 void OffscreenWindowTizen::Initialize()
81 // Connect callback to be notified when the surface is rendered
82 TriggerEventFactory triggerEventFactory;
84 mRenderNotification = std::unique_ptr< TriggerEventInterface >( triggerEventFactory.CreateTriggerEvent( MakeCallback( this, &OffscreenWindowTizen::OnPostRender ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ) );
86 NativeRenderSurface* surface = GetNativeRenderSurface();
93 surface->SetRenderNotification( mRenderNotification.get() );
96 OffscreenWindowTizen::~OffscreenWindowTizen()
98 NativeRenderSurface* surface = GetNativeRenderSurface();
102 // To prevent notification triggering in NativeRenderSurface::PostRender while deleting SceneHolder
103 surface->SetRenderNotification( nullptr );
107 uint32_t OffscreenWindowTizen::GetLayerCount() const
109 return mScene.GetLayerCount();
112 Dali::Layer OffscreenWindowTizen::GetLayer( uint32_t depth ) const
114 return mScene.GetLayer( depth );
117 OffscreenWindow::WindowSize OffscreenWindowTizen::GetSize() const
119 Size size = mScene.GetSize();
121 return OffscreenWindow::WindowSize( static_cast<uint16_t>( size.width ), static_cast<uint16_t>( size.height ) );
124 Dali::Any OffscreenWindowTizen::GetNativeHandle() const
126 return GetNativeRenderSurface()->GetNativeHandle();
129 NativeRenderSurface* OffscreenWindowTizen::GetNativeRenderSurface() const
131 return dynamic_cast< NativeRenderSurface* >( mSurface.get() );
134 void OffscreenWindowTizen::OnPostRender()
136 mPostRenderSignal.Emit( Dali::OffscreenWindow( this ), nullptr );
139 OffscreenWindow::PostRenderSignalType& OffscreenWindowTizen::PostRenderSignal()
141 return mPostRenderSignal;
144 } // namespace Internal