2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_GDI_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_GDI_H_
14 #include "webrtc/modules/desktop_capture/screen_capturer.h"
18 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
19 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
20 #include "webrtc/modules/desktop_capture/win/scoped_thread_desktop.h"
21 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
27 // ScreenCapturerWinGdi captures 32bit RGB using GDI.
29 // ScreenCapturerWinGdi is double-buffered as required by ScreenCapturer.
30 class ScreenCapturerWinGdi : public ScreenCapturer {
32 explicit ScreenCapturerWinGdi(const DesktopCaptureOptions& options);
33 virtual ~ScreenCapturerWinGdi();
35 // Overridden from ScreenCapturer:
36 virtual void Start(Callback* callback) OVERRIDE;
37 virtual void Capture(const DesktopRegion& region) OVERRIDE;
38 virtual bool GetScreenList(ScreenList* screens) OVERRIDE;
39 virtual bool SelectScreen(ScreenId id) OVERRIDE;
42 typedef HRESULT (WINAPI * DwmEnableCompositionFunc)(UINT);
44 // Make sure that the device contexts match the screen configuration.
45 void PrepareCaptureResources();
47 // Captures the current screen contents into the current buffer. Returns true
51 // Capture the current cursor shape.
55 ScreenId current_screen_id_;
56 std::wstring current_device_key_;
58 // A thread-safe list of invalid rectangles, and the size of the most
59 // recently captured screen.
60 ScreenCapturerHelper helper_;
62 ScopedThreadDesktop desktop_;
64 // GDI resources used for screen capture.
68 // Queue of the frames buffers.
69 ScreenCaptureFrameQueue queue_;
71 // Rectangle describing the bounds of the desktop device context, relative to
72 // the primary display's top-left.
73 DesktopRect desktop_dc_rect_;
75 // Class to calculate the difference between two screen bitmaps.
76 scoped_ptr<Differ> differ_;
78 HMODULE dwmapi_library_;
79 DwmEnableCompositionFunc composition_func_;
81 // Used to suppress duplicate logging of SetThreadExecutionState errors.
82 bool set_thread_execution_state_failed_;
84 DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWinGdi);
89 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_GDI_H_