FBO/Texture access synchronization for multiple contexts
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-application.h
1 #ifndef DALI_TEST_APPLICATION_H
2 #define DALI_TEST_APPLICATION_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <test-platform-abstraction.h>
23 #include "test-gl-sync-abstraction.h"
24 #include "test-gl-abstraction.h"
25 #include "test-gl-context-helper-abstraction.h"
26 #include "test-render-controller.h"
27 #include "test-render-surface.h"
28 #include <dali/public-api/common/dali-common.h>
29 #include <dali/integration-api/resource-policies.h>
30 #include <dali/integration-api/trace.h>
31 #include <dali/integration-api/scene.h>
32
33 namespace Dali
34 {
35
36 class DALI_CORE_API TestApplication : public ConnectionTracker
37 {
38 public:
39
40   // Default values derived from H2 device.
41   static const uint32_t DEFAULT_SURFACE_WIDTH = 480;
42   static const uint32_t DEFAULT_SURFACE_HEIGHT = 800;
43
44   static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
45   static constexpr uint32_t DEFAULT_VERTICAL_DPI   = 217;
46
47   static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
48
49   static const uint32_t RENDER_FRAME_INTERVAL = 16;
50
51   TestApplication( uint32_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
52                    uint32_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
53                    uint32_t horizontalDpi = DEFAULT_HORIZONTAL_DPI,
54                    uint32_t verticalDpi   = DEFAULT_VERTICAL_DPI,
55                    ResourcePolicy::DataRetention policy = ResourcePolicy::DALI_DISCARDS_ALL_DATA,
56                    bool initialize = true );
57
58   void Initialize();
59   void CreateCore();
60   void CreateScene();
61   void InitializeCore();
62   virtual ~TestApplication();
63   static void LogMessage( Dali::Integration::Log::DebugPriority level, std::string& message );
64   static void LogContext( bool start, const char* tag );
65   Dali::Integration::Core& GetCore();
66   TestPlatformAbstraction& GetPlatform();
67   TestRenderController& GetRenderController();
68   TestGlAbstraction& GetGlAbstraction();
69   TestGlSyncAbstraction& GetGlSyncAbstraction();
70   TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
71   void ProcessEvent(const Integration::Event& event);
72   void SendNotification();
73   bool Render( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL );
74   uint32_t GetUpdateStatus();
75   bool UpdateOnly( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL );
76   bool RenderOnly( );
77   void ResetContext();
78   bool GetRenderNeedsUpdate();
79   uint32_t Wait( uint32_t durationToWait );
80   static void EnableLogging( bool enabled )
81   {
82     mLoggingEnabled = enabled;
83   }
84
85   Integration::Scene GetScene() const
86   {
87     return mScene;
88   }
89
90 private:
91   void DoUpdate( uint32_t intervalMilliseconds, const char* location=NULL );
92
93 protected:
94   TestPlatformAbstraction   mPlatformAbstraction;
95   TestRenderController      mRenderController;
96   TestGlAbstraction         mGlAbstraction;
97   TestGlSyncAbstraction     mGlSyncAbstraction;
98   TestGlContextHelperAbstraction mGlContextHelperAbstraction;
99   TestRenderSurface*        mRenderSurface;
100
101   Integration::UpdateStatus mStatus;
102   Integration::RenderStatus mRenderStatus;
103
104   Integration::Core* mCore;
105   Dali::Integration::Scene mScene;
106
107   uint32_t mSurfaceWidth;
108   uint32_t mSurfaceHeight;
109   uint32_t mFrame;
110
111   struct { uint32_t x; uint32_t y; } mDpi;
112   uint32_t mLastVSyncTime;
113   ResourcePolicy::DataRetention mDataRetentionPolicy;
114   static bool mLoggingEnabled;
115 };
116
117 } // Dali
118
119 #endif // DALI_TEST_APPLICATION_H