1 #ifndef DALI_TEST_GRAPHICS_APPLICATION_H
2 #define DALI_TEST_GRAPHICS_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/core.h>
23 #include <dali/integration-api/resource-policies.h>
24 #include <dali/integration-api/scene.h>
25 #include <dali/integration-api/trace.h>
27 #include <dali/internal/graphics/gles/egl-graphics-controller.h>
28 #include <dali/public-api/common/dali-common.h>
30 #include <test-gl-abstraction.h>
31 #include <test-gl-context-helper-abstraction.h>
32 #include <test-gl-sync-abstraction.h>
33 #include <test-platform-abstraction.h>
34 #include <test-render-controller.h>
38 class DALI_CORE_API TestGraphicsApplication : public ConnectionTracker
41 // Default values derived from H2 device.
42 static const uint32_t DEFAULT_SURFACE_WIDTH = 480;
43 static const uint32_t DEFAULT_SURFACE_HEIGHT = 800;
45 static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
46 static constexpr uint32_t DEFAULT_VERTICAL_DPI = 217;
48 static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
50 static const uint32_t RENDER_FRAME_INTERVAL = 16;
52 TestGraphicsApplication(uint32_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
53 uint32_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
54 uint32_t horizontalDpi = DEFAULT_HORIZONTAL_DPI,
55 uint32_t verticalDpi = DEFAULT_VERTICAL_DPI,
56 bool initialize = true,
57 bool enablePartialUpdate = false);
62 void InitializeCore();
63 ~TestGraphicsApplication() override;
64 static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
65 static void LogContext(bool start, const char* tag);
66 Dali::Integration::Core& GetCore();
67 TestPlatformAbstraction& GetPlatform();
68 TestRenderController& GetRenderController();
69 Graphics::Controller& GetGraphicsController();
71 TestGlAbstraction& GetGlAbstraction();
72 TestGlSyncAbstraction& GetGlSyncAbstraction();
73 TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
75 void ProcessEvent(const Integration::Event& event);
76 void SendNotification();
77 bool Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL);
78 bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
79 bool RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
80 uint32_t GetUpdateStatus();
81 bool UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
84 bool GetRenderNeedsUpdate();
85 bool GetRenderNeedsPostRender();
86 uint32_t Wait(uint32_t durationToWait);
87 static void EnableLogging(bool enabled)
89 mLoggingEnabled = enabled;
92 Integration::Scene GetScene() const
98 void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL);
101 TestPlatformAbstraction mPlatformAbstraction;
102 TestRenderController mRenderController;
103 Graphics::EglGraphicsController mGraphicsController; // Use real controller in Adaptor
104 TestGlAbstraction mGlAbstraction;
105 TestGlSyncAbstraction mGlSyncAbstraction;
106 TestGlContextHelperAbstraction mGlContextHelperAbstraction;
108 Integration::UpdateStatus mStatus;
109 Integration::RenderStatus mRenderStatus;
111 Integration::Core* mCore;
112 Dali::Integration::Scene mScene;
114 uint32_t mSurfaceWidth;
115 uint32_t mSurfaceHeight;
123 uint32_t mLastVSyncTime;
124 bool mPartialUpdateEnabled;
125 static bool mLoggingEnabled;
130 #endif // DALI_TEST_GRAPHICS_APPLICATION_H