OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_ | 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_ |
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_ | 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_ |
13 | 13 |
14 #include <stdint.h> | 14 #include <stdint.h> |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 | 17 |
18 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | 18 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
22 // A set of platform independent functions to draw various of shapes on the | 22 // A set of basic platform dependent functions to draw various shapes on the |
23 // screen. This class is for testing ScreenCapturer* implementations only, and | 23 // screen. |
| 24 // Usually ScreenPainter is preferred, instead of using this class directly. As |
| 25 // ScreenPainter provides more complex shapes by using ScreenDrawer for each |
| 26 // platform. This class is for testing ScreenCapturer* implementations only, and |
24 // should not be used in production logic. | 27 // should not be used in production logic. |
25 class ScreenDrawer { | 28 class ScreenDrawer { |
26 public: | 29 public: |
27 // Creates a ScreenDrawer for the current platform. | 30 // Creates a ScreenDrawer for the current platform, returns nullptr if no |
| 31 // ScreenDrawer implementation available. |
28 static std::unique_ptr<ScreenDrawer> Create(); | 32 static std::unique_ptr<ScreenDrawer> Create(); |
29 | 33 |
30 ScreenDrawer() {} | 34 ScreenDrawer() {} |
31 virtual ~ScreenDrawer() {} | 35 virtual ~ScreenDrawer() {} |
32 | 36 |
33 // Returns a rect, on which this instance can draw. | 37 // Returns a rectangle, on which this instance can draw. Note, this rectangle |
| 38 // does not need to map to a physical monitor or a logic screen. ScreenDrawer |
| 39 // does not guarantee drawing a point at (0, 0) means the point will be placed |
| 40 // at (0, 0) of a monitor or a logic screen. But it guarantees points drawing |
| 41 // at (0, 0) will eventually show up, top-left part of the drawable region |
| 42 // should not be covered by another window, or out of display area. Refer to |
| 43 // CalibrateScreenDrawerPosition() function in screen_capturer_unittest.cc to |
| 44 // see how to calibrate the visible region of a ScreenDrawer. |
34 virtual DesktopRect DrawableRegion() = 0; | 45 virtual DesktopRect DrawableRegion() = 0; |
35 | 46 |
36 // Draws a rectangle to cover |rect| with color |rgba|. Note, rect.bottom() | 47 // Draws a rectangle to cover |rect| with color |bgra|. Note, rect.bottom() |
37 // and rect.right() two lines are not included. | 48 // and rect.right() two lines are not included. |
38 virtual void DrawRectangle(DesktopRect rect, uint32_t rgba) = 0; | 49 virtual void DrawRectangle(DesktopRect rect, uint32_t bgra) = 0; |
39 | 50 |
40 // Clears all content on the screen. | 51 // Blocks current thread until OS finishes previous Draw* actions. |
41 virtual void Clear() = 0; | 52 // ScreenCapturer should be able to capture the changes after this function |
| 53 // finish. |
| 54 virtual void WaitForPendingPaintings() = 0; |
42 }; | 55 }; |
43 | 56 |
44 } // namespace webrtc | 57 } // namespace webrtc |
45 | 58 |
46 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_ | 59 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_ |
OLD | NEW |