1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup UI_DFX
18  * @{
19  *
20  * @brief Provides test and analysis capabilities, such as stimulating input events and viewing information about a
21  *        Document Object Model (DOM) tree.
22  *
23  * @since 1.0
24  * @version 1.0
25  */
26 
27 /**
28  * @file ui_screenshot.h
29  *
30  * @brief Declares the screenshot function.
31  *
32  * @since 1.0
33  * @version 1.0
34  */
35 #ifndef GRAPHIC_LITE_UI_SCREENSHOT_H
36 #define GRAPHIC_LITE_UI_SCREENSHOT_H
37 
38 #include "graphic_config.h"
39 
40 #if ENABLE_DEBUG
41 #include "gfx_utils/heap_base.h"
42 
43 namespace OHOS {
44 /**
45  * @brief Provides callback functions for screenshot events.
46  *
47  * @since 1.0
48  * @version 1.0
49  */
50 class UIScreenshotListener;
51 
52 /**
53  * @brief Provides external screenshot functions.
54  *
55  * @since 1.0
56  * @version 1.0
57  */
58 class UIScreenshot : public HeapBase {
59 public:
60     /**
61      * @brief Obtains an instance in singleton pattern.
62      *
63      * @return Returns the screenshot function instance.
64      * @since 1.0
65      * @version 1.0
66      */
67     static UIScreenshot* GetInstance();
68 
69     /**
70      * @brief Takes a screenshot and saves it to a file.
71      *
72      * @param path Indicates the pointer to the path for storing the screenshot file.
73      * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> otherwise.
74      * @since 1.0
75      * @version 1.0
76      */
77     bool ScreenshotToFile(const char* path);
78 
79 private:
80     UIScreenshotListener* screenshotListener_;
81 
UIScreenshot()82     UIScreenshot() : screenshotListener_(nullptr) {}
83     virtual ~UIScreenshot();
84 
85     UIScreenshot(const UIScreenshot&) = delete;
86     UIScreenshot& operator=(const UIScreenshot&) = delete;
87     UIScreenshot(UIScreenshot&&) = delete;
88     UIScreenshot& operator=(UIScreenshot&&) = delete;
89 };
90 } // namespace OHOS
91 #endif // ENABLE_DEBUG
92 #endif // GRAPHIC_LITE_UI_SCREENSHOT_H
93