1 #ifndef DALI_TEST_APPLICATION_H
2 #define DALI_TEST_APPLICATION_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.
22 #include <dali/integration-api/resource-policies.h>
23 #include <dali/integration-api/scene.h>
24 #include <dali/integration-api/trace.h>
26 #include <dali/public-api/common/dali-common.h>
27 #include <test-platform-abstraction.h>
29 #include "test-graphics-controller.h"
30 #include "test-render-controller.h"
34 class DALI_CORE_API TestApplication : public ConnectionTracker
37 // Default values derived from H2 device.
38 static const uint32_t DEFAULT_SURFACE_WIDTH = 480;
39 static const uint32_t DEFAULT_SURFACE_HEIGHT = 800;
41 static const Rect<int> DEFAULT_SURFACE_RECT;
43 static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
44 static constexpr uint32_t DEFAULT_VERTICAL_DPI = 217;
46 static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
48 static const uint32_t RENDER_FRAME_INTERVAL = 16;
50 TestApplication(uint32_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
51 uint32_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
52 uint32_t horizontalDpi = DEFAULT_HORIZONTAL_DPI,
53 uint32_t verticalDpi = DEFAULT_VERTICAL_DPI,
54 bool initialize = true,
55 bool enablePartialUpdate = false);
60 void InitializeCore();
61 ~TestApplication() override;
62 static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
63 static void LogContext(bool start, const char* tag);
64 Dali::Integration::Core& GetCore();
65 TestPlatformAbstraction& GetPlatform();
66 TestRenderController& GetRenderController();
67 TestGraphicsController& GetGraphicsController();
69 TestGlAbstraction& GetGlAbstraction();
70 TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
71 TestGraphicsSyncImplementation& GetGraphicsSyncImpl();
73 void ProcessEvent(const Integration::Event& event);
74 void SendNotification();
75 bool Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL, bool uploadOnly = false);
76 bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
77 bool RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
78 uint32_t GetUpdateStatus();
79 bool UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
82 bool GetRenderNeedsUpdate();
83 bool GetRenderNeedsPostRender();
84 uint32_t Wait(uint32_t durationToWait);
85 static void EnableLogging(bool enabled)
87 mLoggingEnabled = enabled;
90 Integration::Scene GetScene() const
96 void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL, bool uploadOnly = false);
99 TestPlatformAbstraction mPlatformAbstraction;
100 TestRenderController mRenderController;
101 TestGraphicsController mGraphicsController;
103 Integration::UpdateStatus mStatus;
104 Integration::RenderStatus mRenderStatus;
106 Integration::Core* mCore;
107 Dali::Integration::Scene mScene;
109 uint32_t mSurfaceWidth;
110 uint32_t mSurfaceHeight;
113 Graphics::UniquePtr<Graphics::RenderTarget> mRenderTarget;
120 uint32_t mLastVSyncTime;
121 bool mPartialUpdateEnabled;
122 static bool mLoggingEnabled;
127 #endif // DALI_TEST_APPLICATION_H