blob: 061900023be75f66ae9844341150b2fef0ce544f [file] [log] [blame]
zijiehe49c01d72016-08-16 17:33:55 -07001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_
12#define MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_
zijiehe49c01d72016-08-16 17:33:55 -070013
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "modules/desktop_capture/desktop_capture_types.h"
15#include "modules/desktop_capture/desktop_geometry.h"
Yves Gerey665174f2018-06-19 15:03:05 +020016#include "modules/desktop_capture/rgba_color.h"
zijiehe49c01d72016-08-16 17:33:55 -070017
18namespace webrtc {
19
zijiehe6a4607e2016-10-18 18:22:18 -070020// A cross-process lock to ensure only one ScreenDrawer can be used at a certain
21// time.
22class ScreenDrawerLock {
23 public:
24 virtual ~ScreenDrawerLock();
25
26 static std::unique_ptr<ScreenDrawerLock> Create();
27
28 protected:
29 ScreenDrawerLock();
30};
31
zijiehe0f49dac2016-09-07 11:52:25 -070032// A set of basic platform dependent functions to draw various shapes on the
33// screen.
zijiehe49c01d72016-08-16 17:33:55 -070034class ScreenDrawer {
35 public:
zijiehe0f49dac2016-09-07 11:52:25 -070036 // Creates a ScreenDrawer for the current platform, returns nullptr if no
37 // ScreenDrawer implementation available.
zijiehe6a4607e2016-10-18 18:22:18 -070038 // If the implementation cannot guarantee two ScreenDrawer instances won't
39 // impact each other, this function may block current thread until another
40 // ScreenDrawer has been destroyed.
zijiehe49c01d72016-08-16 17:33:55 -070041 static std::unique_ptr<ScreenDrawer> Create();
42
zijiehe6a4607e2016-10-18 18:22:18 -070043 ScreenDrawer();
44 virtual ~ScreenDrawer();
zijiehe49c01d72016-08-16 17:33:55 -070045
zijiehe0f49dac2016-09-07 11:52:25 -070046 // Returns the region inside which DrawRectangle() function are expected to
47 // work, in capturer coordinates (assuming ScreenCapturer::SelectScreen has
48 // not been called). This region may exclude regions of the screen reserved by
Zijie He77b7a1d2017-09-01 15:51:14 -070049 // the OS for things like menu bars or app launchers. The DesktopRect is in
50 // system coordinate, i.e. the primary monitor always starts from (0, 0).
zijiehe49c01d72016-08-16 17:33:55 -070051 virtual DesktopRect DrawableRegion() = 0;
52
zijiehe0f49dac2016-09-07 11:52:25 -070053 // Draws a rectangle to cover |rect| with |color|. Note, rect.bottom() and
54 // rect.right() two lines are not included. The part of |rect| which is out of
55 // DrawableRegion() will be ignored.
56 virtual void DrawRectangle(DesktopRect rect, RgbaColor color) = 0;
zijiehe49c01d72016-08-16 17:33:55 -070057
zijiehe0f49dac2016-09-07 11:52:25 -070058 // Clears all content on the screen by filling the area with black.
zijiehe49c01d72016-08-16 17:33:55 -070059 virtual void Clear() = 0;
zijiehe0f49dac2016-09-07 11:52:25 -070060
61 // Blocks current thread until OS finishes previous DrawRectangle() actions.
62 // ScreenCapturer should be able to capture the changes after this function
63 // finish.
64 virtual void WaitForPendingDraws() = 0;
zijiehe6a4607e2016-10-18 18:22:18 -070065
66 // Returns true if incomplete shapes previous actions required may be drawn on
67 // the screen after a WaitForPendingDraws() call. i.e. Though the complete
68 // shapes will eventually be drawn on the screen, due to some OS limitations,
69 // these shapes may be partially appeared sometimes.
70 virtual bool MayDrawIncompleteShapes() = 0;
Zijie He77b7a1d2017-09-01 15:51:14 -070071
72 // Returns the id of the drawer window. This function returns kNullWindowId if
73 // the implementation does not draw on a window of the system.
74 virtual WindowId window_id() const = 0;
zijiehe49c01d72016-08-16 17:33:55 -070075};
76
77} // namespace webrtc
78
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020079#endif // MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_