Merge "Fix svace issue - Application Destructor & egl controller debug" into devel...
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / egl-graphics-controller-debug.h
1 #ifndef DALI_GRAPHICS_EGL_GRAPHICS_CONTROLLER_DEBUG_H
2 #define DALI_GRAPHICS_EGL_GRAPHICS_CONTROLLER_DEBUG_H
3
4 /*
5  * Copyright (c) 2022 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 #include <dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h>
21
22 namespace Dali::Graphics
23 {
24 #if defined(DEBUG_ENABLED)
25 /**
26  * Struct to manage dumping N command buffers. In this file, "frame" really
27  * means each call to EglGraphicsController::Flush(), and doesn't necessarily
28  * correspond to a complete render frame.
29  */
30 struct GraphicsFrameDump
31 {
32   using UniqueFilePtr = std::unique_ptr<std::FILE, int (*)(std::FILE*)>;
33   UniqueFilePtr outputStream;
34   FILE*         output{nullptr};
35   bool          dumpingFrame{false};
36   bool          firstBuffer{true};
37   bool          firstFrame{true};
38   int           frameCount{0};
39
40   const int NTH_FRAME{10}; // dump first N "frames"
41
42   // Constructor
43   GraphicsFrameDump();
44
45   void Start();
46   void End();
47   void DumpCommandBuffer(const GLES::CommandBuffer* cmdBuf);
48   bool IsDumpFrame();
49 };
50 #endif
51
52 #if defined(DEBUG_ENABLED) && defined(ENABLE_COMMAND_BUFFER_FRAME_DUMP)
53 #define DUMP_FRAME_INIT() std::unique_ptr<Dali::Graphics::GraphicsFrameDump> gGraphicsFrameDump(new Dali::Graphics::GraphicsFrameDump)
54 #define DUMP_FRAME_START()       \
55   if(gGraphicsFrameDump)         \
56   {                              \
57     gGraphicsFrameDump->Start(); \
58   }
59 #define DUMP_FRAME_COMMAND_BUFFER(cmdBuffer)          \
60   if(gGraphicsFrameDump)                              \
61   {                                                   \
62     gGraphicsFrameDump->DumpCommandBuffer(cmdBuffer); \
63   }
64 #define DUMP_FRAME_END()       \
65   if(gGraphicsFrameDump)       \
66   {                            \
67     gGraphicsFrameDump->End(); \
68   }
69 #else
70 #define DUMP_FRAME_INIT()
71 #define DUMP_FRAME_START()
72 #define DUMP_FRAME_COMMAND_BUFFER(cmdBuffer)
73 #define DUMP_FRAME_END()
74 #endif
75
76 } // namespace Dali::Graphics
77
78 #endif //DALI_GRAPHICS_EGL_GRAPHICS_CONTROLLER_DEBUG_H