1 #ifndef DALI_TOOLKIT_SCENE_HOLDER_IMPL_H
2 #define DALI_TOOLKIT_SCENE_HOLDER_IMPL_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
23 #include <dali/integration-api/scene.h>
24 #include <dali/public-api/actors/layer.h>
25 #include <dali/public-api/object/base-object.h>
30 class TestRenderSurface : public Dali::RenderSurfaceInterface
34 TestRenderSurface( PositionSize positionSize ) : mPositionSize(positionSize) {};
36 PositionSize GetPositionSize() const override { return mPositionSize; };
38 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) { dpiHorizontal = dpiVertical = 96; }
40 void InitializeGraphics() override {};
42 void CreateSurface() override {};
44 void DestroySurface() override {};
46 bool ReplaceGraphicsSurface() override { return false; };
48 void MoveResize( Dali::PositionSize positionSize ) override { mPositionSize = positionSize; };
50 void StartRender() override {};
52 bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect ) override { return false; };
58 //void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override {};
60 void StopRender() override {};
62 void ReleaseLock() override {};
64 void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override {};
66 RenderSurfaceInterface::Type GetSurfaceType() override { return RenderSurfaceInterface::WINDOW_RENDER_SURFACE; };
68 void MakeContextCurrent() override {};
70 Integration::DepthBufferAvailable GetDepthBufferRequired() override { return Integration::DepthBufferAvailable::FALSE; };
72 Integration::StencilBufferAvailable GetStencilBufferRequired() override { return Integration::StencilBufferAvailable::FALSE; };
74 int GetSurfaceOrientation() const override {return 0;};
76 int GetScreenOrientation() const override {return 0;};
78 void SetBackgroundColor( Vector4 color ) {};
80 Vector4 GetBackgroundColor() { return Color::WHITE; };
83 PositionSize mPositionSize;
92 class SceneHolder : public Dali::BaseObject
96 SceneHolder( const Dali::Rect<int>& positionSize );
98 virtual ~SceneHolder();
100 void Add( Dali::Actor actor );
102 void Remove( Dali::Actor actor );
104 Dali::Layer GetRootLayer() const;
106 void SetBackgroundColor( Vector4 color );
108 Vector4 GetBackgroundColor() const;
110 void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp );
112 void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
114 void FeedKeyEvent( Dali::KeyEvent& keyEvent );
116 Dali::Integration::SceneHolder::KeyEventSignalType& KeyEventSignal();
118 Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
120 Dali::Integration::SceneHolder::TouchEventSignalType& TouchedSignal();
122 Dali::Integration::SceneHolder::WheelEventSignalType& WheelEventSignal();
124 Dali::Integration::SceneHolder::WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
126 Integration::Scene GetScene();
128 Dali::RenderSurfaceInterface& GetRenderSurface();
130 Dali::RenderTaskList GetRenderTaskList();
134 TestRenderSurface mRenderSurface;
135 Integration::Scene mScene;
138 } // namespace Adaptor
140 } // namespace Internal
142 inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder )
144 DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
145 BaseObject& object = sceneHolder.GetBaseObject();
146 return static_cast<Internal::Adaptor::SceneHolder&>( object );
149 inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder )
151 DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
152 const BaseObject& object = sceneHolder.GetBaseObject();
153 return static_cast<const Internal::Adaptor::SceneHolder&>( object );
158 #endif // DALI_TOOLKIT_SCENE_HOLDER_IMPL_H