This change adds RotateDesktopFrame(), RotateRect(), RotateSize(), ReverseRotate() functions, so an implementation can use these free functions to rotate and copy pixels from one DesktopFrame to another at the same time. This is the first part of the change to support rotation in DirectX capturer. In a coming change, these functions will be used in DxgiOutputDuplicator to do the rotation and copying. Background, DirectX APIs always return unrotated data buffer, so we need to rotate it to match the user-selected rotation. What worse is except for the data buffer, other variables return by these APIs are all rotated, e.g. output size, monitor position. So we will eventually not be able to capture the rotated monitors, because we cannot set their position and size correctly. Though DXGI_OUTDUPL_DESC provides a DXGI_MODE_ROTATION enumeration to indicate the output rotation, it does not provide a simple way to rotate an IDXGIResource, which is the only thing we can get from duplication APIs. A typical user case here is to use a matrix to transform the IDXGIResource and render it to a surface. But since we do not render the IDXGIResource at all, we need to manually rotate it. BUG=314516 Review-Url: https://codereview.webrtc.org/2500883004 Cr-Commit-Position: refs/heads/master@{#15205}
28 lines
971 B
C++
28 lines
971 B
C++
/*
|
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_TEST_UTILS_H_
|
|
#define WEBRTC_MODULES_DESKTOP_CAPTURE_TEST_UTILS_H_
|
|
|
|
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
|
|
|
namespace webrtc {
|
|
|
|
// Clears a DesktopFrame |frame| by setting its data() into 0.
|
|
void ClearDesktopFrame(DesktopFrame* frame);
|
|
|
|
// Compares size() and data() of two DesktopFrames |left| and |right|.
|
|
bool DesktopFrameDataEquals(const DesktopFrame& left,
|
|
const DesktopFrame& right);
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_TEST_UTILS_H_
|