When calling RequestResizeToServer, we recalculate the location according to the...
[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) 2021 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 /**
25  * Struct to manage dumping N command buffers. In this file, "frame" really 
26  * means each call to EglGraphicsController::Flush(), and doesn't necessarily
27  * correspond to a complete render frame. 
28  */
29 struct GraphicsFrameDump
30 {
31   using UniqueFilePtr = std::unique_ptr<std::FILE, int (*)(std::FILE*)>;
32   UniqueFilePtr outputStream;
33   FILE*         output{nullptr};
34   bool          dumpingFrame{false};
35   bool          firstBuffer{true};
36   bool          firstFrame{true};
37   int           frameCount{0};
38
39   const int NTH_FRAME{10}; // dump first N "frames"
40
41   // Constructor
42   GraphicsFrameDump();
43
44   void Start();
45   void End();
46   void DumpCommandBuffer(const GLES::CommandBuffer* cmdBuf);
47   bool IsDumpFrame();
48 };
49
50 #if defined(DEBUG_ENABLED) && defined(ENABLE_COMMAND_BUFFER_FRAME_DUMP)
51 #define DUMP_FRAME_INIT() std::unique_ptr<Dali::Graphics::GraphicsFrameDump> gGraphicsFrameDump(new Dali::Graphics::GraphicsFrameDump)
52 #define DUMP_FRAME_START()       \
53   if(gGraphicsFrameDump)         \
54   {                              \
55     gGraphicsFrameDump->Start(); \
56   }
57 #define DUMP_FRAME_COMMAND_BUFFER(cmdBuffer)          \
58   if(gGraphicsFrameDump)                              \
59   {                                                   \
60     gGraphicsFrameDump->DumpCommandBuffer(cmdBuffer); \
61   }
62 #define DUMP_FRAME_END()       \
63   if(gGraphicsFrameDump)       \
64   {                            \
65     gGraphicsFrameDump->End(); \
66   }
67 #else
68 #define DUMP_FRAME_INIT()
69 #define DUMP_FRAME_START()
70 #define DUMP_FRAME_COMMAND_BUFFER(cmdBuffer)
71 #define DUMP_FRAME_END()
72 #endif
73
74 } // namespace Dali::Graphics
75
76 #endif //DALI_GRAPHICS_EGL_GRAPHICS_CONTROLLER_DEBUG_H