blob: d7ec5d186cb7896cb9a16336289b27eb33d1467b [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
11#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_
12#define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_
13
14#include <stdint.h>
15
16#include <memory>
17
zijiehe0f49dac2016-09-07 11:52:25 -070018#include "webrtc/modules/desktop_capture/rgba_color.h"
zijiehe49c01d72016-08-16 17:33:55 -070019#include "webrtc/modules/desktop_capture/desktop_geometry.h"
20
21namespace webrtc {
22
zijiehe0f49dac2016-09-07 11:52:25 -070023// A set of basic platform dependent functions to draw various shapes on the
24// screen.
zijiehe49c01d72016-08-16 17:33:55 -070025class ScreenDrawer {
26 public:
zijiehe0f49dac2016-09-07 11:52:25 -070027 // Creates a ScreenDrawer for the current platform, returns nullptr if no
28 // ScreenDrawer implementation available.
zijiehe49c01d72016-08-16 17:33:55 -070029 static std::unique_ptr<ScreenDrawer> Create();
30
31 ScreenDrawer() {}
32 virtual ~ScreenDrawer() {}
33
zijiehe0f49dac2016-09-07 11:52:25 -070034 // Returns the region inside which DrawRectangle() function are expected to
35 // work, in capturer coordinates (assuming ScreenCapturer::SelectScreen has
36 // not been called). This region may exclude regions of the screen reserved by
37 // the OS for things like menu bars or app launchers.
zijiehe49c01d72016-08-16 17:33:55 -070038 virtual DesktopRect DrawableRegion() = 0;
39
zijiehe0f49dac2016-09-07 11:52:25 -070040 // Draws a rectangle to cover |rect| with |color|. Note, rect.bottom() and
41 // rect.right() two lines are not included. The part of |rect| which is out of
42 // DrawableRegion() will be ignored.
43 virtual void DrawRectangle(DesktopRect rect, RgbaColor color) = 0;
zijiehe49c01d72016-08-16 17:33:55 -070044
zijiehe0f49dac2016-09-07 11:52:25 -070045 // Clears all content on the screen by filling the area with black.
zijiehe49c01d72016-08-16 17:33:55 -070046 virtual void Clear() = 0;
zijiehe0f49dac2016-09-07 11:52:25 -070047
48 // Blocks current thread until OS finishes previous DrawRectangle() actions.
49 // ScreenCapturer should be able to capture the changes after this function
50 // finish.
51 virtual void WaitForPendingDraws() = 0;
zijiehe49c01d72016-08-16 17:33:55 -070052};
53
54} // namespace webrtc
55
56#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_DRAWER_H_