Reformat the WebRTC code base

Running clang-format with chromium's style guide.

The goal is n-fold:
 * providing consistency and readability (that's what code guidelines are for)
 * preventing noise with presubmit checks and git cl format
 * building on the previous point: making it easier to automatically fix format issues
 * you name it

Please consider using git-hyper-blame to ignore this commit.

Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -22,8 +22,7 @@ namespace webrtc {
BlankDetectorDesktopCapturerWrapper::BlankDetectorDesktopCapturerWrapper(
std::unique_ptr<DesktopCapturer> capturer,
RgbaColor blank_pixel)
: capturer_(std::move(capturer)),
blank_pixel_(blank_pixel) {
: capturer_(std::move(capturer)), blank_pixel_(blank_pixel) {
RTC_DCHECK(capturer_);
}

View File

@ -49,7 +49,7 @@ class BlankDetectorDesktopCapturerWrapperTest
};
BlankDetectorDesktopCapturerWrapperTest::
BlankDetectorDesktopCapturerWrapperTest() {
BlankDetectorDesktopCapturerWrapperTest() {
frame_generator_.size()->set(frame_width_, frame_height_);
frame_generator_.set_desktop_frame_painter(&painter_);
std::unique_ptr<DesktopCapturer> capturer(new FakeDesktopCapturer());
@ -63,7 +63,7 @@ BlankDetectorDesktopCapturerWrapperTest() {
}
BlankDetectorDesktopCapturerWrapperTest::
~BlankDetectorDesktopCapturerWrapperTest() = default;
~BlankDetectorDesktopCapturerWrapperTest() = default;
void BlankDetectorDesktopCapturerWrapperTest::OnCaptureResult(
DesktopCapturer::Result result,

View File

@ -20,13 +20,12 @@ namespace webrtc {
CaptureResultDesktopCapturerWrapper::CaptureResultDesktopCapturerWrapper(
std::unique_ptr<DesktopCapturer> base_capturer,
ResultObserver* observer)
: DesktopCapturerWrapper(std::move(base_capturer)),
observer_(observer) {
: DesktopCapturerWrapper(std::move(base_capturer)), observer_(observer) {
RTC_DCHECK(observer_);
}
CaptureResultDesktopCapturerWrapper::
~CaptureResultDesktopCapturerWrapper() = default;
CaptureResultDesktopCapturerWrapper::~CaptureResultDesktopCapturerWrapper() =
default;
void CaptureResultDesktopCapturerWrapper::Start(Callback* callback) {
if ((callback_ == nullptr) != (callback == nullptr)) {

View File

@ -21,9 +21,8 @@ namespace webrtc {
// A DesktopCapturerWrapper implementation to capture the result of
// |base_capturer|. Derived classes are expected to provide a ResultObserver
// implementation to observe the DesktopFrame returned by |base_capturer_|.
class CaptureResultDesktopCapturerWrapper
: public DesktopCapturerWrapper,
public DesktopCapturer::Callback {
class CaptureResultDesktopCapturerWrapper : public DesktopCapturerWrapper,
public DesktopCapturer::Callback {
public:
using Callback = DesktopCapturer::Callback;

View File

@ -27,4 +27,3 @@ std::unique_ptr<DesktopFrame> CreateCroppedDesktopFrame(
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_CROPPED_DESKTOP_FRAME_H_

View File

@ -32,15 +32,16 @@ TEST(CroppedDesktopFrameTest, DoNotCreateWrapperIfSizeIsNotChanged) {
}
TEST(CroppedDesktopFrameTest, ReturnNullptrIfSizeIsNotSufficient) {
ASSERT_EQ(nullptr, CreateCroppedDesktopFrame(
CreateTestFrame(), DesktopRect::MakeWH(11, 10)));
ASSERT_EQ(nullptr, CreateCroppedDesktopFrame(CreateTestFrame(),
DesktopRect::MakeWH(11, 10)));
}
TEST(CroppedDesktopFrameTest, ReturnNullIfCropRegionIsOutOfBounds) {
std::unique_ptr<DesktopFrame> frame = CreateTestFrame();
frame->set_top_left(DesktopVector(100, 200));
ASSERT_EQ(nullptr, CreateCroppedDesktopFrame(std::move(frame),
DesktopRect::MakeLTRB(101, 203, 109, 218)));
ASSERT_EQ(nullptr,
CreateCroppedDesktopFrame(
std::move(frame), DesktopRect::MakeLTRB(101, 203, 109, 218)));
}
TEST(CroppedDesktopFrameTest, CropASubArea) {
@ -56,7 +57,7 @@ TEST(CroppedDesktopFrameTest, SetTopLeft) {
std::unique_ptr<DesktopFrame> frame = CreateTestFrame();
frame->set_top_left(DesktopVector(100, 200));
frame = CreateCroppedDesktopFrame(std::move(frame),
DesktopRect::MakeLTRB(1, 3, 9, 18));
DesktopRect::MakeLTRB(1, 3, 9, 18));
ASSERT_EQ(frame->size().width(), 8);
ASSERT_EQ(frame->size().height(), 15);
ASSERT_EQ(frame->top_left().x(), 101);

View File

@ -13,8 +13,8 @@
#include <memory>
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
namespace webrtc {
@ -76,4 +76,3 @@ class CroppingWindowCapturer : public DesktopCapturer,
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_CROPPING_WINDOW_CAPTURER_H_

View File

@ -147,8 +147,7 @@ BOOL CALLBACK TopWindowVerifier(HWND hwnd, LPARAM param) {
class CroppingWindowCapturerWin : public CroppingWindowCapturer {
public:
CroppingWindowCapturerWin(
const DesktopCaptureOptions& options)
CroppingWindowCapturerWin(const DesktopCaptureOptions& options)
: CroppingWindowCapturer(options) {}
private:
@ -216,8 +215,8 @@ bool CroppingWindowCapturerWin::ShouldUseScreenCapturer() {
if (region_type == SIMPLEREGION) {
// The |region_rect| returned from GetRgnBox() is always in window
// coordinate.
region_rect.Translate(
window_region_rect_.left(), window_region_rect_.top());
region_rect.Translate(window_region_rect_.left(),
window_region_rect_.top());
// MSDN: The window region determines the area *within* the window where the
// system permits drawing.
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd144950(v=vs.85).aspx.

View File

@ -28,8 +28,10 @@ namespace {
// Helper function that blends one image into another. Source image must be
// pre-multiplied with the alpha channel. Destination is assumed to be opaque.
void AlphaBlend(uint8_t* dest, int dest_stride,
const uint8_t* src, int src_stride,
void AlphaBlend(uint8_t* dest,
int dest_stride,
const uint8_t* src,
int src_stride,
const DesktopSize& size) {
for (int y = 0; y < size.height(); ++y) {
for (int x = 0; x < size.width(); ++x) {
@ -111,8 +113,7 @@ DesktopFrameWithCursor::DesktopFrameWithCursor(
cursor.image()->data() +
origin_shift.y() * cursor.image()->stride() +
origin_shift.x() * DesktopFrame::kBytesPerPixel,
cursor.image()->stride(),
target_rect.size());
cursor.image()->stride(), target_rect.size());
}
DesktopFrameWithCursor::~DesktopFrameWithCursor() {

View File

@ -11,8 +11,8 @@
#include <memory>
#include "modules/desktop_capture/desktop_and_cursor_composer.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/mouse_cursor.h"
#include "modules/desktop_capture/shared_desktop_frame.h"
@ -30,9 +30,15 @@ const int kCursorHeight = 10;
const int kTestCursorSize = 3;
const uint32_t kTestCursorData[kTestCursorSize][kTestCursorSize] = {
{ 0xffffffff, 0x99990000, 0xaa222222, },
{ 0x88008800, 0xaa0000aa, 0xaa333333, },
{ 0x00000000, 0xaa0000aa, 0xaa333333, },
{
0xffffffff, 0x99990000, 0xaa222222,
},
{
0x88008800, 0xaa0000aa, 0xaa333333,
},
{
0x00000000, 0xaa0000aa, 0xaa333333,
},
};
uint32_t GetFakeFramePixelValue(const DesktopVector& p) {
@ -197,19 +203,11 @@ TEST_F(DesktopAndCursorComposerTest, CursorShouldBeIgnoredIfNoFrameCaptured) {
int hotspot_x, hotspot_y;
bool inside;
} tests[] = {
{0, 0, 0, 0, true},
{50, 50, 0, 0, true},
{100, 50, 0, 0, true},
{50, 100, 0, 0, true},
{100, 100, 0, 0, true},
{0, 0, 2, 5, true},
{1, 1, 2, 5, true},
{50, 50, 2, 5, true},
{100, 100, 2, 5, true},
{0, 0, 5, 2, true},
{50, 50, 5, 2, true},
{100, 100, 5, 2, true},
{0, 0, 0, 0, false},
{0, 0, 0, 0, true}, {50, 50, 0, 0, true}, {100, 50, 0, 0, true},
{50, 100, 0, 0, true}, {100, 100, 0, 0, true}, {0, 0, 2, 5, true},
{1, 1, 2, 5, true}, {50, 50, 2, 5, true}, {100, 100, 2, 5, true},
{0, 0, 5, 2, true}, {50, 50, 5, 2, true}, {100, 100, 5, 2, true},
{0, 0, 0, 0, false},
};
for (size_t i = 0; i < arraysize(tests); i++) {
@ -245,19 +243,9 @@ TEST_F(DesktopAndCursorComposerTest,
int x;
int y;
} tests[] = {
{ 0, 0 },
{ 50, 50 },
{ 50, 150 },
{ 100, 150 },
{ 50, 200 },
{ 99, 200 },
{ 100, 199 },
{ 200, 300 },
{ 200, 299 },
{ 199, 300 },
{ -1, -1 },
{ -10000, -10000 },
{ 10000, 10000 },
{0, 0}, {50, 50}, {50, 150}, {100, 150}, {50, 200},
{99, 200}, {100, 199}, {200, 300}, {200, 299}, {199, 300},
{-1, -1}, {-10000, -10000}, {10000, 10000},
};
for (size_t i = 0; i < arraysize(tests); i++) {
SCOPED_TRACE(i);
@ -281,12 +269,7 @@ TEST_F(DesktopAndCursorComposerTest, IsOccludedShouldBeConsidered) {
int x;
int y;
} tests[] = {
{ 100, 200 },
{ 101, 200 },
{ 100, 201 },
{ 101, 201 },
{ 150, 250 },
{ 199, 299 },
{100, 200}, {101, 200}, {100, 201}, {101, 201}, {150, 250}, {199, 299},
};
fake_screen_->set_is_occluded(true);
for (size_t i = 0; i < arraysize(tests); i++) {
@ -311,12 +294,7 @@ TEST_F(DesktopAndCursorComposerTest, CursorIncluded) {
int x;
int y;
} tests[] = {
{ 100, 200 },
{ 101, 200 },
{ 100, 201 },
{ 101, 201 },
{ 150, 250 },
{ 199, 299 },
{100, 200}, {101, 200}, {100, 201}, {101, 201}, {150, 250}, {199, 299},
};
for (size_t i = 0; i < arraysize(tests); i++) {
SCOPED_TRACE(i);

View File

@ -108,9 +108,7 @@ class DesktopCaptureOptions {
}
// Allowing directx based capturer or not, this capturer works on windows 7
// with platform update / windows 8 or upper.
bool allow_directx_capturer() const {
return allow_directx_capturer_;
}
bool allow_directx_capturer() const { return allow_directx_capturer_; }
void set_allow_directx_capturer(bool enabled) {
allow_directx_capturer_ = enabled;
}

View File

@ -41,17 +41,14 @@ const ScreenId kInvalidScreenId = -2;
// An integer to attach to each DesktopFrame to differentiate the generator of
// the frame.
namespace DesktopCapturerId {
constexpr uint32_t CreateFourCC(char a, char b, char c, char d) {
return ((static_cast<uint32_t>(a)) |
(static_cast<uint32_t>(b) << 8) |
(static_cast<uint32_t>(c) << 16) |
(static_cast<uint32_t>(d) << 24));
}
constexpr uint32_t CreateFourCC(char a, char b, char c, char d) {
return ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) |
(static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24));
}
constexpr uint32_t kUnknown = 0;
constexpr uint32_t kScreenCapturerWinGdi = CreateFourCC('G', 'D', 'I', ' ');
constexpr uint32_t kScreenCapturerWinDirectx =
CreateFourCC('D', 'X', 'G', 'I');
constexpr uint32_t kUnknown = 0;
constexpr uint32_t kScreenCapturerWinGdi = CreateFourCC('G', 'D', 'I', ' ');
constexpr uint32_t kScreenCapturerWinDirectx = CreateFourCC('D', 'X', 'G', 'I');
} // namespace DesktopCapturerId
} // namespace webrtc

View File

@ -19,8 +19,8 @@
#include <type_traits>
#include <vector>
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/shared_memory.h"
namespace webrtc {
@ -152,4 +152,3 @@ class DesktopCapturer {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_

View File

@ -122,8 +122,8 @@ void ExecuteDifferWrapperCase(BlackWhiteDesktopFramePainter* frame_painter,
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_))
.Times(1)
.WillOnce(testing::Invoke([&updated_region, check_result, exactly_match](
DesktopCapturer::Result result,
std::unique_ptr<DesktopFrame>* frame) {
DesktopCapturer::Result result,
std::unique_ptr<DesktopFrame>* frame) {
ASSERT_EQ(result, DesktopCapturer::Result::SUCCESS);
if (check_result) {
if (exactly_match) {

View File

@ -36,7 +36,8 @@ DesktopFrame::DesktopFrame(DesktopSize size,
DesktopFrame::~DesktopFrame() = default;
void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer, int src_stride,
void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer,
int src_stride,
const DesktopRect& dest_rect) {
RTC_CHECK(DesktopRect::MakeSize(size()).ContainsRect(dest_rect));
@ -51,11 +52,12 @@ void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer, int src_stride,
void DesktopFrame::CopyPixelsFrom(const DesktopFrame& src_frame,
const DesktopVector& src_pos,
const DesktopRect& dest_rect) {
RTC_CHECK(DesktopRect::MakeSize(src_frame.size()).ContainsRect(
DesktopRect::MakeOriginSize(src_pos, dest_rect.size())));
RTC_CHECK(DesktopRect::MakeSize(src_frame.size())
.ContainsRect(
DesktopRect::MakeOriginSize(src_pos, dest_rect.size())));
CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos),
src_frame.stride(), dest_rect);
CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos), src_frame.stride(),
dest_rect);
}
DesktopRect DesktopFrame::rect() const {
@ -94,7 +96,8 @@ void DesktopFrame::MoveFrameInfoFrom(DesktopFrame* other) {
}
BasicDesktopFrame::BasicDesktopFrame(DesktopSize size)
: DesktopFrame(size, kBytesPerPixel * size.width(),
: DesktopFrame(size,
kBytesPerPixel * size.width(),
new uint8_t[kBytesPerPixel * size.width() * size.height()],
nullptr) {}
@ -142,9 +145,7 @@ SharedMemoryDesktopFrame::SharedMemoryDesktopFrame(
DesktopSize size,
int stride,
std::unique_ptr<SharedMemory> shared_memory)
: SharedMemoryDesktopFrame(size,
stride,
shared_memory.release()) {}
: SharedMemoryDesktopFrame(size, stride, shared_memory.release()) {}
SharedMemoryDesktopFrame::~SharedMemoryDesktopFrame() {
delete shared_memory_;

View File

@ -90,9 +90,7 @@ class DesktopFrame {
// Not all DesktopCapturer implementations set this field; it's set to
// kUnknown by default.
uint32_t capturer_id() const { return capturer_id_; }
void set_capturer_id(uint32_t capturer_id) {
capturer_id_ = capturer_id;
}
void set_capturer_id(uint32_t capturer_id) { capturer_id_ = capturer_id; }
// Copies various information from |other|. Anything initialized in
// constructor are not copied.
@ -193,4 +191,3 @@ class SharedMemoryDesktopFrame : public DesktopFrame {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_

View File

@ -12,8 +12,8 @@
#include <string.h>
#include "third_party/libyuv/include/libyuv/rotate_argb.h"
#include "rtc_base/checks.h"
#include "third_party/libyuv/include/libyuv/rotate_argb.h"
namespace webrtc {
@ -109,10 +109,10 @@ void RotateDesktopFrame(const DesktopFrame& source,
}
int result = libyuv::ARGBRotate(
source.GetFrameDataAtPos(source_rect.top_left()), source.stride(),
target->GetFrameDataAtPos(target_rect.top_left()), target->stride(),
source_rect.width(), source_rect.height(),
ToLibyuvRotationMode(rotation));
source.GetFrameDataAtPos(source_rect.top_left()), source.stride(),
target->GetFrameDataAtPos(target_rect.top_left()), target->stride(),
source_rect.width(), source_rect.height(),
ToLibyuvRotationMode(rotation));
RTC_DCHECK_EQ(result, 0);
}

View File

@ -39,8 +39,8 @@ ArrayDesktopFrame::~ArrayDesktopFrame() = default;
TEST(DesktopFrameRotationTest, CopyRect3x4) {
// A DesktopFrame of 4-pixel width by 3-pixel height.
static uint32_t frame_pixels[] = {
0, 1, 2, 3, //
4, 5, 6, 7, //
0, 1, 2, 3, //
4, 5, 6, 7, //
8, 9, 10, 11, //
};
ArrayDesktopFrame frame(DesktopSize(4, 3), frame_pixels);
@ -55,8 +55,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x4) {
// After Rotating clock-wise 90 degree
{
static uint32_t expected_pixels[] = {
8, 4, 0, //
9, 5, 1, //
8, 4, 0, //
9, 5, 1, //
10, 6, 2, //
11, 7, 3, //
};
@ -72,8 +72,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x4) {
{
static uint32_t expected_pixels[] = {
11, 10, 9, 8, //
7, 6, 5, 4, //
3, 2, 1, 0, //
7, 6, 5, 4, //
3, 2, 1, 0, //
};
ArrayDesktopFrame expected(DesktopSize(4, 3), expected_pixels);
@ -88,8 +88,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x4) {
static uint32_t expected_pixels[] = {
3, 7, 11, //
2, 6, 10, //
1, 5, 9, //
0, 4, 8, //
1, 5, 9, //
0, 4, 8, //
};
ArrayDesktopFrame expected(DesktopSize(3, 4), expected_pixels);
@ -103,8 +103,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x4) {
TEST(DesktopFrameRotationTest, CopyRect3x5) {
// A DesktopFrame of 5-pixel width by 3-pixel height.
static uint32_t frame_pixels[] = {
0, 1, 2, 3, 4, //
5, 6, 7, 8, 9, //
0, 1, 2, 3, 4, //
5, 6, 7, 8, 9, //
10, 11, 12, 13, 14, //
};
ArrayDesktopFrame frame(DesktopSize(5, 3), frame_pixels);
@ -135,10 +135,10 @@ TEST(DesktopFrameRotationTest, CopyRect3x5) {
// After Rotating clock-wise 180 degree
{
static uint32_t expected_pixels[] {
static uint32_t expected_pixels[]{
14, 13, 12, 11, 10, //
9, 8, 7, 6, 5, //
4, 3, 2, 1, 0, //
9, 8, 7, 6, 5, //
4, 3, 2, 1, 0, //
};
ArrayDesktopFrame expected(DesktopSize(5, 3), expected_pixels);
@ -169,8 +169,8 @@ TEST(DesktopFrameRotationTest, CopyRect3x5) {
TEST(DesktopFrameRotationTest, PartialCopyRect3x5) {
// A DesktopFrame of 5-pixel width by 3-pixel height.
static uint32_t frame_pixels[] = {
0, 1, 2, 3, 4, //
5, 6, 7, 8, 9, //
0, 1, 2, 3, 4, //
5, 6, 7, 8, 9, //
10, 11, 12, 13, 14, //
};
ArrayDesktopFrame frame(DesktopSize(5, 3), frame_pixels);
@ -225,11 +225,11 @@ TEST(DesktopFrameRotationTest, PartialCopyRect3x5) {
{
static uint32_t expected_pixels[] = {
0, 0, 0, //
0, 0, 0, //
11, 6, 0, //
12, 7, 0, //
13, 8, 0, //
0, 0, 0, //
0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(3, 5), expected_pixels);
@ -259,8 +259,8 @@ TEST(DesktopFrameRotationTest, PartialCopyRect3x5) {
{
static uint32_t expected_pixels[] = {
0, 13, 12, 11, 0, //
0, 8, 7, 6, 0, //
0, 0, 0, 0, 0, //
0, 8, 7, 6, 0, //
0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(5, 3), expected_pixels);
@ -310,20 +310,20 @@ TEST(DesktopFrameRotationTest, PartialCopyRect3x5) {
TEST(DesktopFrameRotationTest, WithOffset) {
// A DesktopFrame of 4-pixel width by 3-pixel height.
static uint32_t frame_pixels[] = {
0, 1, 2, 3, //
4, 5, 6, 7, //
0, 1, 2, 3, //
4, 5, 6, 7, //
8, 9, 10, 11, //
};
ArrayDesktopFrame frame(DesktopSize(4, 3), frame_pixels);
{
static uint32_t expected_pixels[] = {
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 1, 2, 3, 0, 0, 0, //
0, 4, 5, 6, 7, 0, 0, 0, //
0, 8, 9, 10, 11, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 1, 2, 3, 0, 0, 0, //
0, 4, 5, 6, 7, 0, 0, 0, //
0, 8, 9, 10, 11, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(8, 6), expected_pixels);
@ -339,12 +339,12 @@ TEST(DesktopFrameRotationTest, WithOffset) {
{
static uint32_t expected_pixels[] = {
0, 0, 0, 0, 0, 0, 0, 0, //
0, 11, 10, 9, 8, 0, 0, 0, //
0, 7, 6, 5, 4, 0, 0, 0, //
0, 3, 2, 1, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 11, 10, 9, 8, 0, 0, 0, //
0, 7, 6, 5, 4, 0, 0, 0, //
0, 3, 2, 1, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(8, 6), expected_pixels);
@ -360,14 +360,14 @@ TEST(DesktopFrameRotationTest, WithOffset) {
{
static uint32_t expected_pixels[] = {
0, 0, 0, 0, 0, 0, //
0, 8, 4, 0, 0, 0, //
0, 9, 5, 1, 0, 0, //
0, 10, 6, 2, 0, 0, //
0, 11, 7, 3, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 8, 4, 0, 0, 0, //
0, 9, 5, 1, 0, 0, //
0, 10, 6, 2, 0, 0, //
0, 11, 7, 3, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(6, 8), expected_pixels);
@ -383,14 +383,14 @@ TEST(DesktopFrameRotationTest, WithOffset) {
{
static uint32_t expected_pixels[] = {
0, 0, 0, 0, 0, 0, //
0, 3, 7, 11, 0, 0, //
0, 2, 6, 10, 0, 0, //
0, 1, 5, 9, 0, 0, //
0, 0, 4, 8, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 3, 7, 11, 0, 0, //
0, 2, 6, 10, 0, 0, //
0, 1, 5, 9, 0, 0, //
0, 0, 4, 8, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(6, 8), expected_pixels);

View File

@ -53,8 +53,8 @@ std::unique_ptr<DesktopFrameWin> DesktopFrameWin::Create(
section_handle = shared_memory->handle();
}
void* data = nullptr;
HBITMAP bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &data,
section_handle, 0);
HBITMAP bitmap =
CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &data, section_handle, 0);
if (!bitmap) {
RTC_LOG(LS_WARNING) << "Failed to allocate new window frame "
<< GetLastError();

View File

@ -48,4 +48,3 @@ class DesktopFrameWin : public DesktopFrame {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_WIN_H_

View File

@ -15,8 +15,8 @@
namespace webrtc {
bool DesktopRect::Contains(const DesktopVector& point) const {
return point.x() >= left() && point.x() < right() &&
point.y() >= top() && point.y() < bottom();
return point.x() >= left() && point.x() < right() && point.y() >= top() &&
point.y() < bottom();
}
bool DesktopRect::ContainsRect(const DesktopRect& rect) const {
@ -76,4 +76,3 @@ void DesktopRect::Scale(double horizontal, double vertical) {
}
} // namespace webrtc

View File

@ -51,9 +51,7 @@ class DesktopVector {
class DesktopSize {
public:
DesktopSize() : width_(0), height_(0) {}
DesktopSize(int32_t width, int32_t height)
: width_(width), height_(height) {
}
DesktopSize(int32_t width, int32_t height) : width_(width), height_(height) {}
int32_t width() const { return width_; }
int32_t height() const { return height_; }
@ -83,12 +81,16 @@ class DesktopRect {
static DesktopRect MakeWH(int32_t width, int32_t height) {
return DesktopRect(0, 0, width, height);
}
static DesktopRect MakeXYWH(int32_t x, int32_t y,
int32_t width, int32_t height) {
static DesktopRect MakeXYWH(int32_t x,
int32_t y,
int32_t width,
int32_t height) {
return DesktopRect(x, y, x + width, y + height);
}
static DesktopRect MakeLTRB(int32_t left, int32_t top,
int32_t right, int32_t bottom) {
static DesktopRect MakeLTRB(int32_t left,
int32_t top,
int32_t right,
int32_t bottom) {
return DesktopRect(left, top, right, bottom);
}
static DesktopRect MakeOriginSize(const DesktopVector& origin,
@ -115,7 +117,7 @@ class DesktopRect {
bool equals(const DesktopRect& other) const {
return left_ == other.left_ && top_ == other.top_ &&
right_ == other.right_ && bottom_ == other.bottom_;
right_ == other.right_ && bottom_ == other.bottom_;
}
// Returns true if |point| lies within the rectangle boundaries.
@ -151,8 +153,7 @@ class DesktopRect {
private:
DesktopRect(int32_t left, int32_t top, int32_t right, int32_t bottom)
: left_(left), top_(top), right_(right), bottom_(bottom) {
}
: left_(left), top_(top), right_(right), bottom_(bottom) {}
int32_t left_;
int32_t top_;
@ -163,4 +164,3 @@ class DesktopRect {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_GEOMETRY_H_

View File

@ -17,15 +17,13 @@
namespace webrtc {
DesktopRegion::RowSpan::RowSpan(int32_t left, int32_t right)
: left(left), right(right) {
}
: left(left), right(right) {}
DesktopRegion::Row::Row(const Row&) = default;
DesktopRegion::Row::Row(Row&&) = default;
DesktopRegion::Row::Row(int32_t top, int32_t bottom)
: top(top), bottom(bottom) {
}
: top(top), bottom(bottom) {}
DesktopRegion::Row::~Row() {}
@ -63,8 +61,7 @@ bool DesktopRegion::Equals(const DesktopRegion& region) const {
Rows::const_iterator it1 = rows_.begin();
Rows::const_iterator it2 = region.rows_.begin();
while (it1 != rows_.end()) {
if (it2 == region.rows_.end() ||
it1->first != it2->first ||
if (it2 == region.rows_.end() || it1->first != it2->first ||
it1->second->top != it2->second->top ||
it1->second->bottom != it2->second->bottom ||
it1->second->spans != it2->second->spans) {
@ -100,14 +97,13 @@ void DesktopRegion::AddRect(const DesktopRect& rect) {
// necessary.
Rows::iterator row = rows_.upper_bound(top);
while (top < rect.bottom()) {
if (row == rows_.end() || top < row->second->top) {
if (row == rows_.end() || top < row->second->top) {
// If |top| is above the top of the current |row| then add a new row above
// the current one.
int32_t bottom = rect.bottom();
if (row != rows_.end() && row->second->top < bottom)
bottom = row->second->top;
row = rows_.insert(
row, Rows::value_type(bottom, new Row(top, bottom)));
row = rows_.insert(row, Rows::value_type(bottom, new Row(top, bottom)));
} else if (top > row->second->top) {
// If the |top| falls in the middle of the |row| then split |row| into
// two, at |top|, and leave |row| referring to the lower of the two,
@ -421,9 +417,8 @@ void DesktopRegion::AddSpanToRow(Row* row, int left, int right) {
}
// Find the first span that ends at or after |left|.
RowSpanSet::iterator start =
std::lower_bound(row->spans.begin(), row->spans.end(), left,
CompareSpanRight);
RowSpanSet::iterator start = std::lower_bound(
row->spans.begin(), row->spans.end(), left, CompareSpanRight);
assert(start < row->spans.end());
// Find the first span that starts after |right|.
@ -462,9 +457,8 @@ void DesktopRegion::AddSpanToRow(Row* row, int left, int right) {
bool DesktopRegion::IsSpanInRow(const Row& row, const RowSpan& span) {
// Find the first span that starts at or after |span.left| and then check if
// it's the same span.
RowSpanSet::const_iterator it =
std::lower_bound(row.spans.begin(), row.spans.end(), span.left,
CompareSpanLeft);
RowSpanSet::const_iterator it = std::lower_bound(
row.spans.begin(), row.spans.end(), span.left, CompareSpanLeft);
return it != row.spans.end() && *it == span;
}

View File

@ -166,4 +166,3 @@ class DesktopRegion {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_REGION_H_

View File

@ -23,7 +23,8 @@ int RadmonInt(int max) {
}
void CompareRegion(const DesktopRegion& region,
const DesktopRect rects[], int rects_size) {
const DesktopRect rects[],
int rects_size) {
DesktopRegion::Iterator it(region);
for (int i = 0; i < rects_size; ++i) {
SCOPED_TRACE(i);
@ -31,8 +32,8 @@ void CompareRegion(const DesktopRegion& region,
EXPECT_TRUE(it.rect().equals(rects[i]))
<< it.rect().left() << "-" << it.rect().right() << "."
<< it.rect().top() << "-" << it.rect().bottom() << " "
<< rects[i].left() << "-" << rects[i].right() << "."
<< rects[i].top() << "-" << rects[i].bottom();
<< rects[i].left() << "-" << rects[i].right() << "." << rects[i].top()
<< "-" << rects[i].bottom();
it.Advance();
}
EXPECT_TRUE(it.IsAtEnd());
@ -68,22 +69,27 @@ TEST(DesktopRegionTest, NonOverlappingRects) {
int count;
DesktopRect rects[4];
} cases[] = {
{ 1, { DesktopRect::MakeXYWH(10, 10, 10, 10) } },
{ 2, { DesktopRect::MakeXYWH(10, 10, 10, 10),
DesktopRect::MakeXYWH(30, 10, 10, 15) } },
{ 2, { DesktopRect::MakeXYWH(10, 10, 10, 10),
DesktopRect::MakeXYWH(10, 30, 10, 5) } },
{ 3, { DesktopRect::MakeXYWH(10, 10, 10, 9),
DesktopRect::MakeXYWH(30, 10, 15, 10),
DesktopRect::MakeXYWH(10, 30, 8, 10) } },
{ 4, { DesktopRect::MakeXYWH(0, 0, 30, 10),
DesktopRect::MakeXYWH(40, 0, 10, 30),
DesktopRect::MakeXYWH(0, 20, 10, 30),
DesktopRect::MakeXYWH(20, 40, 30, 10) } },
{ 4, { DesktopRect::MakeXYWH(0, 0, 10, 100),
DesktopRect::MakeXYWH(20, 10, 30, 10),
DesktopRect::MakeXYWH(20, 30, 30, 10),
DesktopRect::MakeXYWH(20, 50, 30, 10) } },
{1, {DesktopRect::MakeXYWH(10, 10, 10, 10)}},
{2,
{DesktopRect::MakeXYWH(10, 10, 10, 10),
DesktopRect::MakeXYWH(30, 10, 10, 15)}},
{2,
{DesktopRect::MakeXYWH(10, 10, 10, 10),
DesktopRect::MakeXYWH(10, 30, 10, 5)}},
{3,
{DesktopRect::MakeXYWH(10, 10, 10, 9),
DesktopRect::MakeXYWH(30, 10, 15, 10),
DesktopRect::MakeXYWH(10, 30, 8, 10)}},
{4,
{DesktopRect::MakeXYWH(0, 0, 30, 10),
DesktopRect::MakeXYWH(40, 0, 10, 30),
DesktopRect::MakeXYWH(0, 20, 10, 30),
DesktopRect::MakeXYWH(20, 40, 30, 10)}},
{4,
{DesktopRect::MakeXYWH(0, 0, 10, 100),
DesktopRect::MakeXYWH(20, 10, 30, 10),
DesktopRect::MakeXYWH(20, 30, 30, 10),
DesktopRect::MakeXYWH(20, 50, 30, 10)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@ -114,81 +120,97 @@ TEST(DesktopRegionTest, TwoRects) {
int expected_count;
DesktopRect expected_rects[3];
} cases[] = {
// Touching rectangles that merge into one.
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 100, 100, 200),
1, { DesktopRect::MakeLTRB(0, 100, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(100, 0, 200, 100),
1, { DesktopRect::MakeLTRB(100, 0, 200, 200) } },
// Touching rectangles that merge into one.
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 100, 100, 200),
1,
{DesktopRect::MakeLTRB(0, 100, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(100, 0, 200, 100),
1,
{DesktopRect::MakeLTRB(100, 0, 200, 200)}},
// Rectangles touching on the vertical edge.
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 150, 100, 250),
3, { DesktopRect::MakeLTRB(100, 100, 200, 150),
DesktopRect::MakeLTRB(0, 150, 200, 200),
DesktopRect::MakeLTRB(0, 200, 100, 250) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 50, 100, 150),
3, { DesktopRect::MakeLTRB(0, 50, 100, 100),
DesktopRect::MakeLTRB(0, 100, 200, 150),
DesktopRect::MakeLTRB(100, 150, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 120, 100, 180),
3, { DesktopRect::MakeLTRB(100, 100, 200, 120),
DesktopRect::MakeLTRB(0, 120, 200, 180),
DesktopRect::MakeLTRB(100, 180, 200, 200) } },
// Rectangles touching on the vertical edge.
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 150, 100, 250),
3,
{DesktopRect::MakeLTRB(100, 100, 200, 150),
DesktopRect::MakeLTRB(0, 150, 200, 200),
DesktopRect::MakeLTRB(0, 200, 100, 250)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 50, 100, 150),
3,
{DesktopRect::MakeLTRB(0, 50, 100, 100),
DesktopRect::MakeLTRB(0, 100, 200, 150),
DesktopRect::MakeLTRB(100, 150, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 120, 100, 180),
3,
{DesktopRect::MakeLTRB(100, 100, 200, 120),
DesktopRect::MakeLTRB(0, 120, 200, 180),
DesktopRect::MakeLTRB(100, 180, 200, 200)}},
// Rectangles touching on the horizontal edge.
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(150, 0, 250, 100),
2, { DesktopRect::MakeLTRB(150, 0, 250, 100),
DesktopRect::MakeLTRB(100, 100, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 0, 150, 100),
2, { DesktopRect::MakeLTRB(50, 0, 150, 100),
DesktopRect::MakeLTRB(100, 100, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(120, 0, 180, 100),
2, { DesktopRect::MakeLTRB(120, 0, 180, 100),
DesktopRect::MakeLTRB(100, 100, 200, 200) } },
// Rectangles touching on the horizontal edge.
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(150, 0, 250, 100),
2,
{DesktopRect::MakeLTRB(150, 0, 250, 100),
DesktopRect::MakeLTRB(100, 100, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 0, 150, 100),
2,
{DesktopRect::MakeLTRB(50, 0, 150, 100),
DesktopRect::MakeLTRB(100, 100, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(120, 0, 180, 100),
2,
{DesktopRect::MakeLTRB(120, 0, 180, 100),
DesktopRect::MakeLTRB(100, 100, 200, 200)}},
// Overlapping rectangles.
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 50, 150, 150),
3, { DesktopRect::MakeLTRB(50, 50, 150, 100),
DesktopRect::MakeLTRB(50, 100, 200, 150),
DesktopRect::MakeLTRB(100, 150, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(150, 50, 250, 150),
3, { DesktopRect::MakeLTRB(150, 50, 250, 100),
DesktopRect::MakeLTRB(100, 100, 250, 150),
DesktopRect::MakeLTRB(100, 150, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 120, 150, 180),
3, { DesktopRect::MakeLTRB(100, 100, 200, 120),
DesktopRect::MakeLTRB(0, 120, 200, 180),
DesktopRect::MakeLTRB(100, 180, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(120, 0, 180, 150),
2, { DesktopRect::MakeLTRB(120, 0, 180, 100),
DesktopRect::MakeLTRB(100, 100, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 0, 200, 300),
DesktopRect::MakeLTRB(0, 100, 300, 200),
3, { DesktopRect::MakeLTRB(100, 0, 200, 100),
DesktopRect::MakeLTRB(0, 100, 300, 200),
DesktopRect::MakeLTRB(100, 200, 200, 300)} },
// Overlapping rectangles.
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 50, 150, 150),
3,
{DesktopRect::MakeLTRB(50, 50, 150, 100),
DesktopRect::MakeLTRB(50, 100, 200, 150),
DesktopRect::MakeLTRB(100, 150, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(150, 50, 250, 150),
3,
{DesktopRect::MakeLTRB(150, 50, 250, 100),
DesktopRect::MakeLTRB(100, 100, 250, 150),
DesktopRect::MakeLTRB(100, 150, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 120, 150, 180),
3,
{DesktopRect::MakeLTRB(100, 100, 200, 120),
DesktopRect::MakeLTRB(0, 120, 200, 180),
DesktopRect::MakeLTRB(100, 180, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(120, 0, 180, 150),
2,
{DesktopRect::MakeLTRB(120, 0, 180, 100),
DesktopRect::MakeLTRB(100, 100, 200, 200)}},
{DesktopRect::MakeLTRB(100, 0, 200, 300),
DesktopRect::MakeLTRB(0, 100, 300, 200),
3,
{DesktopRect::MakeLTRB(100, 0, 200, 100),
DesktopRect::MakeLTRB(0, 100, 300, 200),
DesktopRect::MakeLTRB(100, 200, 200, 300)}},
// One rectangle enclosing another.
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(150, 150, 180, 180),
1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(100, 100, 180, 180),
1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } },
{ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(150, 150, 200, 200),
1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } },
// One rectangle enclosing another.
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(150, 150, 180, 180),
1,
{DesktopRect::MakeLTRB(100, 100, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(100, 100, 180, 180),
1,
{DesktopRect::MakeLTRB(100, 100, 200, 200)}},
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(150, 150, 200, 200),
1,
{DesktopRect::MakeLTRB(100, 100, 200, 200)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@ -219,7 +241,9 @@ TEST(DesktopRegionTest, SameRow) {
const int kLastRectSizes[] = {3, 27};
DesktopRegion base_region;
bool base_map[kMapWidth] = { false, };
bool base_map[kMapWidth] = {
false,
};
base_region.AddRect(DesktopRect::MakeXYWH(5, 0, 5, 1));
std::fill_n(base_map + 5, 5, true);
@ -239,13 +263,15 @@ TEST(DesktopRegionTest, SameRow) {
SCOPED_TRACE(x);
DesktopRegion r = base_region;
r.AddRect(DesktopRect::MakeXYWH(x, 0, last_rect_size, 1));
r.AddRect(DesktopRect::MakeXYWH(x, 0, last_rect_size, 1));
bool expected_map[kMapWidth];
std::copy(base_map, base_map + kMapWidth, expected_map);
std::fill_n(expected_map + x, last_rect_size, true);
bool map[kMapWidth] = { false, };
bool map[kMapWidth] = {
false,
};
int pos = -1;
for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) {
@ -266,32 +292,42 @@ TEST(DesktopRegionTest, ComplexRegions) {
int expected_count;
DesktopRect expected_rects[6];
} cases[] = {
{ 3, { DesktopRect::MakeLTRB(100, 100, 200, 200),
{3,
{
DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 100, 100, 200),
DesktopRect::MakeLTRB(310, 110, 320, 120), },
2, { DesktopRect::MakeLTRB(0, 100, 200, 200),
DesktopRect::MakeLTRB(310, 110, 320, 120) } },
{ 3, { DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 50, 150, 150),
DesktopRect::MakeLTRB(300, 125, 350, 175) },
4, { DesktopRect::MakeLTRB(50, 50, 150, 100),
DesktopRect::MakeLTRB(50, 100, 200, 150),
DesktopRect::MakeLTRB(300, 125, 350, 175),
DesktopRect::MakeLTRB(100, 150, 200, 200) } },
{ 4, { DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50),
DesktopRect::MakeLTRB(50, 0, 65, 15) },
6, { DesktopRect::MakeLTRB(0, 0, 30, 10),
DesktopRect::MakeLTRB(50, 0, 65, 15),
DesktopRect::MakeLTRB(0, 10, 40, 20),
DesktopRect::MakeLTRB(0, 20, 50, 30),
DesktopRect::MakeLTRB(10, 30, 50, 40),
DesktopRect::MakeLTRB(20, 40, 50, 50) } },
{ 3, { DesktopRect::MakeLTRB(10, 10, 40, 20),
DesktopRect::MakeLTRB(10, 30, 40, 40),
DesktopRect::MakeLTRB(10, 20, 40, 30) },
1, { DesktopRect::MakeLTRB(10, 10, 40, 40) } },
DesktopRect::MakeLTRB(310, 110, 320, 120),
},
2,
{DesktopRect::MakeLTRB(0, 100, 200, 200),
DesktopRect::MakeLTRB(310, 110, 320, 120)}},
{3,
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 50, 150, 150),
DesktopRect::MakeLTRB(300, 125, 350, 175)},
4,
{DesktopRect::MakeLTRB(50, 50, 150, 100),
DesktopRect::MakeLTRB(50, 100, 200, 150),
DesktopRect::MakeLTRB(300, 125, 350, 175),
DesktopRect::MakeLTRB(100, 150, 200, 200)}},
{4,
{DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50),
DesktopRect::MakeLTRB(50, 0, 65, 15)},
6,
{DesktopRect::MakeLTRB(0, 0, 30, 10),
DesktopRect::MakeLTRB(50, 0, 65, 15),
DesktopRect::MakeLTRB(0, 10, 40, 20),
DesktopRect::MakeLTRB(0, 20, 50, 30),
DesktopRect::MakeLTRB(10, 30, 50, 40),
DesktopRect::MakeLTRB(20, 40, 50, 50)}},
{3,
{DesktopRect::MakeLTRB(10, 10, 40, 20),
DesktopRect::MakeLTRB(10, 30, 40, 40),
DesktopRect::MakeLTRB(10, 20, 40, 30)},
1,
{DesktopRect::MakeLTRB(10, 10, 40, 40)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@ -316,44 +352,62 @@ TEST(DesktopRegionTest, Equals) {
DesktopRect rects[4];
int id;
} regions[] = {
// Same region with one of the rectangles 1 pixel wider/taller.
{ 2, { DesktopRect::MakeLTRB(0, 100, 200, 200),
DesktopRect::MakeLTRB(310, 110, 320, 120) }, 0 },
{ 2, { DesktopRect::MakeLTRB(0, 100, 201, 200),
DesktopRect::MakeLTRB(310, 110, 320, 120) }, 1 },
{ 2, { DesktopRect::MakeLTRB(0, 100, 200, 201),
DesktopRect::MakeLTRB(310, 110, 320, 120) }, 2 },
// Same region with one of the rectangles 1 pixel wider/taller.
{2,
{DesktopRect::MakeLTRB(0, 100, 200, 200),
DesktopRect::MakeLTRB(310, 110, 320, 120)},
0},
{2,
{DesktopRect::MakeLTRB(0, 100, 201, 200),
DesktopRect::MakeLTRB(310, 110, 320, 120)},
1},
{2,
{DesktopRect::MakeLTRB(0, 100, 200, 201),
DesktopRect::MakeLTRB(310, 110, 320, 120)},
2},
// Same region with one of the rectangles shifted horizontally and
// vertically.
{ 4, { DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50),
DesktopRect::MakeLTRB(50, 0, 65, 15) }, 3 },
{ 4, { DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50),
DesktopRect::MakeLTRB(50, 1, 65, 16) }, 4 },
{ 4, { DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50),
DesktopRect::MakeLTRB(51, 0, 66, 15) }, 5 },
// Same region with one of the rectangles shifted horizontally and
// vertically.
{4,
{DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50),
DesktopRect::MakeLTRB(50, 0, 65, 15)},
3},
{4,
{DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50),
DesktopRect::MakeLTRB(50, 1, 65, 16)},
4},
{4,
{DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50),
DesktopRect::MakeLTRB(51, 0, 66, 15)},
5},
// Same region defined by a different set of rectangles - one of the
// rectangle is split horizontally into two.
{ 3, { DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 50, 150, 150),
DesktopRect::MakeLTRB(300, 125, 350, 175) }, 6 },
{ 4, { DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 50, 100, 150),
DesktopRect::MakeLTRB(100, 50, 150, 150),
DesktopRect::MakeLTRB(300, 125, 350, 175) }, 6 },
// Same region defined by a different set of rectangles - one of the
// rectangle is split horizontally into two.
{3,
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 50, 150, 150),
DesktopRect::MakeLTRB(300, 125, 350, 175)},
6},
{4,
{DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(50, 50, 100, 150),
DesktopRect::MakeLTRB(100, 50, 150, 150),
DesktopRect::MakeLTRB(300, 125, 350, 175)},
6},
// Rectangle region defined by a set of rectangles that merge into one.
{ 3, { DesktopRect::MakeLTRB(10, 10, 40, 20),
DesktopRect::MakeLTRB(10, 30, 40, 40),
DesktopRect::MakeLTRB(10, 20, 40, 30) }, 7 },
{ 1, { DesktopRect::MakeLTRB(10, 10, 40, 40) }, 7 },
// Rectangle region defined by a set of rectangles that merge into one.
{3,
{DesktopRect::MakeLTRB(10, 10, 40, 20),
DesktopRect::MakeLTRB(10, 30, 40, 40),
DesktopRect::MakeLTRB(10, 20, 40, 30)},
7},
{1, {DesktopRect::MakeLTRB(10, 10, 40, 40)}, 7},
};
int kTotalRegions = sizeof(regions) / sizeof(Region);
@ -379,15 +433,18 @@ TEST(DesktopRegionTest, Translate) {
int expected_count;
DesktopRect expected_rects[5];
} cases[] = {
{ 3, { DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50) },
3, 5,
5, { DesktopRect::MakeLTRB(3, 5, 33, 15),
DesktopRect::MakeLTRB(3, 15, 43, 25),
DesktopRect::MakeLTRB(3, 25, 53, 35),
DesktopRect::MakeLTRB(13, 35, 53, 45),
DesktopRect::MakeLTRB(23, 45, 53, 55) } },
{3,
{DesktopRect::MakeLTRB(0, 0, 30, 30),
DesktopRect::MakeLTRB(10, 10, 40, 40),
DesktopRect::MakeLTRB(20, 20, 50, 50)},
3,
5,
5,
{DesktopRect::MakeLTRB(3, 5, 33, 15),
DesktopRect::MakeLTRB(3, 15, 43, 25),
DesktopRect::MakeLTRB(3, 25, 53, 35),
DesktopRect::MakeLTRB(13, 35, 53, 45),
DesktopRect::MakeLTRB(23, 45, 53, 55)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@ -408,27 +465,42 @@ TEST(DesktopRegionTest, Intersect) {
int expected_count;
DesktopRect expected_rects[5];
} cases[] = {
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(50, 50, 150, 150) },
1, { DesktopRect::MakeLTRB(50, 50, 100, 100) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(50, 50, 150, 150)},
1,
{DesktopRect::MakeLTRB(50, 50, 100, 100)}},
{ 1, { DesktopRect::MakeLTRB(100, 0, 200, 300) },
1, { DesktopRect::MakeLTRB(0, 100, 300, 200) },
1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } },
{1,
{DesktopRect::MakeLTRB(100, 0, 200, 300)},
1,
{DesktopRect::MakeLTRB(0, 100, 300, 200)},
1,
{DesktopRect::MakeLTRB(100, 100, 200, 200)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
2, { DesktopRect::MakeLTRB(50, 10, 150, 30),
DesktopRect::MakeLTRB(50, 30, 160, 50) },
1, { DesktopRect::MakeLTRB(50, 10, 100, 50) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
2,
{DesktopRect::MakeLTRB(50, 10, 150, 30),
DesktopRect::MakeLTRB(50, 30, 160, 50)},
1,
{DesktopRect::MakeLTRB(50, 10, 100, 50)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
2, { DesktopRect::MakeLTRB(50, 10, 150, 30),
DesktopRect::MakeLTRB(50, 30, 90, 50) },
2, { DesktopRect::MakeLTRB(50, 10, 100, 30),
DesktopRect::MakeLTRB(50, 30, 90, 50) } },
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(100, 50, 200, 200) },
0, {} },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
2,
{DesktopRect::MakeLTRB(50, 10, 150, 30),
DesktopRect::MakeLTRB(50, 30, 90, 50)},
2,
{DesktopRect::MakeLTRB(50, 10, 100, 30),
DesktopRect::MakeLTRB(50, 30, 90, 50)}},
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(100, 50, 200, 200)},
0,
{}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@ -453,81 +525,123 @@ TEST(DesktopRegionTest, Subtract) {
int expected_count;
DesktopRect expected_rects[5];
} cases[] = {
// Subtract one rect from another.
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(50, 50, 150, 150) },
2, { DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 50, 100) } },
// Subtract one rect from another.
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(50, 50, 150, 150)},
2,
{DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 50, 100)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(-50, -50, 50, 50) },
2, { DesktopRect::MakeLTRB(50, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 100, 100) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(-50, -50, 50, 50)},
2,
{DesktopRect::MakeLTRB(50, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 100, 100)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(-50, 50, 50, 150) },
2, { DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(50, 50, 100, 100) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(-50, 50, 50, 150)},
2,
{DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(50, 50, 100, 100)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(50, 50, 150, 70) },
3, { DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 50, 70),
DesktopRect::MakeLTRB(0, 70, 100, 100) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(50, 50, 150, 70)},
3,
{DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 50, 70),
DesktopRect::MakeLTRB(0, 70, 100, 100)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(50, 50, 70, 70) },
4, { DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 50, 70),
DesktopRect::MakeLTRB(70, 50, 100, 70),
DesktopRect::MakeLTRB(0, 70, 100, 100) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(50, 50, 70, 70)},
4,
{DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 50, 70),
DesktopRect::MakeLTRB(70, 50, 100, 70),
DesktopRect::MakeLTRB(0, 70, 100, 100)}},
// Empty result.
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
0, {} },
// Empty result.
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
0,
{}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(-10, -10, 110, 110) },
0, {} },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(-10, -10, 110, 110)},
0,
{}},
{ 2, { DesktopRect::MakeLTRB(0, 0, 100, 100),
DesktopRect::MakeLTRB(50, 50, 150, 150) },
2, { DesktopRect::MakeLTRB(0, 0, 100, 100),
DesktopRect::MakeLTRB(50, 50, 150, 150) },
0, {} },
{2,
{DesktopRect::MakeLTRB(0, 0, 100, 100),
DesktopRect::MakeLTRB(50, 50, 150, 150)},
2,
{DesktopRect::MakeLTRB(0, 0, 100, 100),
DesktopRect::MakeLTRB(50, 50, 150, 150)},
0,
{}},
// One rect out of disjoint set.
{ 3, { DesktopRect::MakeLTRB(0, 0, 10, 10),
DesktopRect::MakeLTRB(20, 20, 30, 30),
DesktopRect::MakeLTRB(40, 0, 50, 10) },
1, { DesktopRect::MakeLTRB(20, 20, 30, 30) },
2, { DesktopRect::MakeLTRB(0, 0, 10, 10),
DesktopRect::MakeLTRB(40, 0, 50, 10) } },
// One rect out of disjoint set.
{3,
{DesktopRect::MakeLTRB(0, 0, 10, 10),
DesktopRect::MakeLTRB(20, 20, 30, 30),
DesktopRect::MakeLTRB(40, 0, 50, 10)},
1,
{DesktopRect::MakeLTRB(20, 20, 30, 30)},
2,
{DesktopRect::MakeLTRB(0, 0, 10, 10),
DesktopRect::MakeLTRB(40, 0, 50, 10)}},
// Row merging.
{ 3, { DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 150, 70),
DesktopRect::MakeLTRB(0, 70, 100, 100) },
1, { DesktopRect::MakeLTRB(100, 50, 150, 70) },
1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
// Row merging.
{3,
{DesktopRect::MakeLTRB(0, 0, 100, 50),
DesktopRect::MakeLTRB(0, 50, 150, 70),
DesktopRect::MakeLTRB(0, 70, 100, 100)},
1,
{DesktopRect::MakeLTRB(100, 50, 150, 70)},
1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)}},
// No-op subtraction.
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(100, 0, 200, 100) },
1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
// No-op subtraction.
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(100, 0, 200, 100)},
1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(-100, 0, 0, 100) },
1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(-100, 0, 0, 100)},
1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(0, 100, 0, 200) },
1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(0, 100, 0, 200)},
1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)}},
{ 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
1, { DesktopRect::MakeLTRB(0, -100, 100, 0) },
1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
{1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)},
1,
{DesktopRect::MakeLTRB(0, -100, 100, 0)},
1,
{DesktopRect::MakeLTRB(0, 0, 100, 100)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@ -552,19 +666,21 @@ TEST(DesktopRegionTest, SubtractRectOnSameRow) {
struct SpanSet {
int count;
struct Range {
int start;
int end;
int start;
int end;
} spans[3];
} span_sets[] = {
{1, { {0, 3} } },
{1, { {0, 5} } },
{1, { {0, 7} } },
{1, { {0, 12} } },
{2, { {0, 3}, {4, 5}, {6, 16} } },
{1, {{0, 3}}},
{1, {{0, 5}}},
{1, {{0, 7}}},
{1, {{0, 12}}},
{2, {{0, 3}, {4, 5}, {6, 16}}},
};
DesktopRegion base_region;
bool base_map[kMapWidth] = { false, };
bool base_map[kMapWidth] = {
false,
};
base_region.AddRect(DesktopRect::MakeXYWH(5, 0, 5, 1));
std::fill_n(base_map + 5, 5, true);
@ -599,7 +715,9 @@ TEST(DesktopRegionTest, SubtractRectOnSameRow) {
}
r.Subtract(region2);
bool map[kMapWidth] = { false, };
bool map[kMapWidth] = {
false,
};
int pos = -1;
for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) {
@ -623,19 +741,21 @@ TEST(DesktopRegionTest, SubtractRectOnSameCol) {
struct SpanSet {
int count;
struct Range {
int start;
int end;
int start;
int end;
} spans[3];
} span_sets[] = {
{1, { {0, 3} } },
{1, { {0, 5} } },
{1, { {0, 7} } },
{1, { {0, 12} } },
{2, { {0, 3}, {4, 5}, {6, 16} } },
{1, {{0, 3}}},
{1, {{0, 5}}},
{1, {{0, 7}}},
{1, {{0, 12}}},
{2, {{0, 3}, {4, 5}, {6, 16}}},
};
DesktopRegion base_region;
bool base_map[kMapHeight] = { false, };
bool base_map[kMapHeight] = {
false,
};
base_region.AddRect(DesktopRect::MakeXYWH(0, 5, 1, 5));
std::fill_n(base_map + 5, 5, true);
@ -670,7 +790,9 @@ TEST(DesktopRegionTest, SubtractRectOnSameCol) {
}
r.Subtract(region2);
bool map[kMapHeight] = { false, };
bool map[kMapHeight] = {
false,
};
int pos = -1;
for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) {
@ -686,19 +808,18 @@ TEST(DesktopRegionTest, SubtractRectOnSameCol) {
}
}
TEST(DesktopRegionTest, DISABLED_Performance) {
for (int c = 0; c < 1000; ++c) {
DesktopRegion r;
for (int i = 0; i < 10; ++i) {
r.AddRect(DesktopRect::MakeXYWH(
RadmonInt(1000), RadmonInt(1000), 200, 200));
r.AddRect(
DesktopRect::MakeXYWH(RadmonInt(1000), RadmonInt(1000), 200, 200));
}
for (int i = 0; i < 1000; ++i) {
r.AddRect(DesktopRect::MakeXYWH(
RadmonInt(1000), RadmonInt(1000),
5 + RadmonInt(10) * 5, 5 + RadmonInt(10) * 5));
r.AddRect(DesktopRect::MakeXYWH(RadmonInt(1000), RadmonInt(1000),
5 + RadmonInt(10) * 5,
5 + RadmonInt(10) * 5));
}
// Iterate over the rectangles.

View File

@ -12,9 +12,9 @@
#include <string.h>
#include "typedefs.h" // NOLINT(build/include)
#include "modules/desktop_capture/differ_vector_sse2.h"
#include "system_wrappers/include/cpu_features_wrapper.h"
#include "typedefs.h" // NOLINT(build/include)
namespace webrtc {

View File

@ -35,9 +35,7 @@ bool BlockDifference(const uint8_t* image1,
// Low level function to compare 2 blocks of pixels of size
// (kBlockSize, kBlockSize). Returns whether the blocks differ.
bool BlockDifference(const uint8_t* image1,
const uint8_t* image2,
int stride);
bool BlockDifference(const uint8_t* image1, const uint8_t* image2, int stride);
} // namespace webrtc

View File

@ -27,9 +27,9 @@ static void GenerateData(uint8_t* data, int size) {
static const int kSizeOfBlock = kBlockSize * kBlockSize * kBytesPerPixel;
uint8_t block_buffer[kSizeOfBlock * 2 + 16];
void PrepareBuffers(uint8_t* &block1, uint8_t* &block2) {
block1 = reinterpret_cast<uint8_t*>
((reinterpret_cast<uintptr_t>(&block_buffer[0]) + 15) & ~15);
void PrepareBuffers(uint8_t*& block1, uint8_t*& block2) {
block1 = reinterpret_cast<uint8_t*>(
(reinterpret_cast<uintptr_t>(&block_buffer[0]) + 15) & ~15);
GenerateData(block1, kSizeOfBlock);
block2 = block1 + kSizeOfBlock;
memcpy(block2, block1, kSizeOfBlock);
@ -51,7 +51,7 @@ TEST(BlockDifferenceTestLast, BlockDifference) {
uint8_t* block1;
uint8_t* block2;
PrepareBuffers(block1, block2);
block2[kSizeOfBlock-2] += 1;
block2[kSizeOfBlock - 2] += 1;
for (int i = 0; i < kTimesToRun; ++i) {
int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel);
@ -63,7 +63,7 @@ TEST(BlockDifferenceTestMid, BlockDifference) {
uint8_t* block1;
uint8_t* block2;
PrepareBuffers(block1, block2);
block2[kSizeOfBlock/2+1] += 1;
block2[kSizeOfBlock / 2 + 1] += 1;
for (int i = 0; i < kTimesToRun; ++i) {
int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel);

View File

@ -13,8 +13,8 @@
#if defined(_MSC_VER)
#include <intrin.h>
#else
#include <mmintrin.h>
#include <emmintrin.h>
#include <mmintrin.h>
#endif
namespace webrtc {

View File

@ -13,8 +13,8 @@
#include <memory>
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame_generator.h"
#include "modules/desktop_capture/shared_memory.h"

View File

@ -51,16 +51,16 @@ SharedMemoryFactoryProxy::SharedMemoryFactoryProxy(
}
// static
std::unique_ptr<SharedMemoryFactory>
SharedMemoryFactoryProxy::Create(SharedMemoryFactory* factory) {
std::unique_ptr<SharedMemoryFactory> SharedMemoryFactoryProxy::Create(
SharedMemoryFactory* factory) {
return std::unique_ptr<SharedMemoryFactory>(
new SharedMemoryFactoryProxy(factory));
}
SharedMemoryFactoryProxy::~SharedMemoryFactoryProxy() = default;
std::unique_ptr<SharedMemory>
SharedMemoryFactoryProxy::CreateSharedMemory(size_t size) {
std::unique_ptr<SharedMemory> SharedMemoryFactoryProxy::CreateSharedMemory(
size_t size) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return factory_->CreateSharedMemory(size);
}

View File

@ -13,8 +13,8 @@
#include <memory>
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/shared_memory.h"

View File

@ -180,8 +180,8 @@ TEST_F(FallbackDesktopCapturerWrapperTest, BothFailed) {
}
TEST_F(FallbackDesktopCapturerWrapperTest, WithSharedMemory) {
wrapper_->SetSharedMemoryFactory(std::unique_ptr<SharedMemoryFactory>(
new FakeSharedMemoryFactory()));
wrapper_->SetSharedMemoryFactory(
std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory()));
wrapper_->CaptureFrame();
main_capturer_->set_result(DesktopCapturer::Result::ERROR_TEMPORARY);
wrapper_->CaptureFrame();

View File

@ -14,8 +14,8 @@
#include <ApplicationServices/ApplicationServices.h>
#include <vector>
#include "typedefs.h" // NOLINT(build/include)
#include "modules/desktop_capture/desktop_geometry.h"
#include "typedefs.h" // NOLINT(build/include)
namespace webrtc {

View File

@ -43,7 +43,7 @@ DesktopConfigurationMonitor::~DesktopConfigurationMonitor() {
void DesktopConfigurationMonitor::Lock() {
if (!display_configuration_capture_event_->Wait(
kDisplayConfigurationEventTimeoutMs)) {
kDisplayConfigurationEventTimeoutMs)) {
RTC_LOG_F(LS_ERROR) << "Event wait timed out.";
abort();
}
@ -57,7 +57,7 @@ void DesktopConfigurationMonitor::Unlock() {
void DesktopConfigurationMonitor::DisplaysReconfiguredCallback(
CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags,
void *user_parameter) {
void* user_parameter) {
DesktopConfigurationMonitor* monitor =
reinterpret_cast<DesktopConfigurationMonitor*>(user_parameter);
monitor->DisplaysReconfigured(display, flags);

View File

@ -45,7 +45,7 @@ class DesktopConfigurationMonitor : public rtc::RefCountedBase {
private:
static void DisplaysReconfiguredCallback(CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags,
void *user_parameter);
void* user_parameter);
void DisplaysReconfigured(CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags);

View File

@ -27,7 +27,7 @@ const int64_t kUpdateIntervalMs = 500;
std::string GetWindowTitle(CGWindowID id) {
CFArrayRef window_id_array =
CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL);
CFArrayCreate(NULL, reinterpret_cast<const void**>(&id), 1, NULL);
CFArrayRef window_array =
CGWindowListCreateDescriptionFromArray(window_id_array);
std::string title;
@ -35,7 +35,7 @@ std::string GetWindowTitle(CGWindowID id) {
if (window_array && CFArrayGetCount(window_array)) {
CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
CFArrayGetValueAtIndex(window_array, 0));
CFStringRef title_ref = reinterpret_cast<CFStringRef>(
CFStringRef title_ref = reinterpret_cast<CFStringRef>(
CFDictionaryGetValue(window, kCGWindowName));
if (title_ref)
@ -49,7 +49,7 @@ std::string GetWindowTitle(CGWindowID id) {
int GetWindowOwnerPid(CGWindowID id) {
CFArrayRef window_id_array =
CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL);
CFArrayCreate(NULL, reinterpret_cast<const void**>(&id), 1, NULL);
CFArrayRef window_array =
CGWindowListCreateDescriptionFromArray(window_id_array);
int pid = 0;
@ -57,7 +57,7 @@ int GetWindowOwnerPid(CGWindowID id) {
if (window_array && CFArrayGetCount(window_array)) {
CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
CFArrayGetValueAtIndex(window_array, 0));
CFNumberRef pid_ref = reinterpret_cast<CFNumberRef>(
CFNumberRef pid_ref = reinterpret_cast<CFNumberRef>(
CFDictionaryGetValue(window, kCGWindowOwnerPID));
if (pid_ref)
@ -97,7 +97,7 @@ CGWindowID FindFullScreenWindowWithSamePidAndTitle(CGWindowID id) {
CFDictionaryGetValue(window, kCGWindowName));
CFNumberRef window_id_ref = reinterpret_cast<CFNumberRef>(
CFDictionaryGetValue(window, kCGWindowNumber));
CFNumberRef window_pid_ref = reinterpret_cast<CFNumberRef>(
CFNumberRef window_pid_ref = reinterpret_cast<CFNumberRef>(
CFDictionaryGetValue(window, kCGWindowOwnerPID));
if (!window_title_ref || !window_id_ref || !window_pid_ref)
@ -170,8 +170,8 @@ CGWindowID FullScreenChromeWindowDetector::FindFullScreenWindow(
void FullScreenChromeWindowDetector::UpdateWindowListIfNeeded(
CGWindowID original_window) {
if (IsChromeWindow(original_window) &&
(rtc::TimeNanos() - last_update_time_ns_) / rtc::kNumNanosecsPerMillisec
> kUpdateIntervalMs) {
(rtc::TimeNanos() - last_update_time_ns_) / rtc::kNumNanosecsPerMillisec >
kUpdateIntervalMs) {
previous_window_list_.clear();
previous_window_list_.swap(current_window_list_);

View File

@ -19,9 +19,9 @@
#include "rtc_base/checks.h"
#include "rtc_base/macutils.h"
static_assert(
static_cast<webrtc::WindowId>(kCGNullWindowID) == webrtc::kNullWindowId,
"kNullWindowId needs to equal to kCGNullWindowID.");
static_assert(static_cast<webrtc::WindowId>(kCGNullWindowID) ==
webrtc::kNullWindowId,
"kNullWindowId needs to equal to kCGNullWindowID.");
namespace webrtc {
@ -69,8 +69,8 @@ bool GetWindowList(rtc::FunctionView<bool(CFDictionaryRef)> on_window,
// Only get on screen, non-desktop windows.
// According to
// https://developer.apple.com/documentation/coregraphics/cgwindowlistoption/1454105-optiononscreenonly ,
// when kCGWindowListOptionOnScreenOnly is used, the order of windows are in
// https://developer.apple.com/documentation/coregraphics/cgwindowlistoption/1454105-optiononscreenonly
// , when kCGWindowListOptionOnScreenOnly is used, the order of windows are in
// decreasing z-order.
CFArrayRef window_array = CGWindowListCopyWindowInfo(
kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements,
@ -143,7 +143,7 @@ bool GetWindowList(DesktopCapturer::SourceList* windows,
WindowId id = GetWindowId(window);
std::string title = GetWindowTitle(window);
if (id != kNullWindowId && !title.empty()) {
windows->push_back(DesktopCapturer::Source{ id, title });
windows->push_back(DesktopCapturer::Source{id, title});
}
return true;
},
@ -151,9 +151,8 @@ bool GetWindowList(DesktopCapturer::SourceList* windows,
}
// Returns true if the window is occupying a full screen.
bool IsWindowFullScreen(
const MacDesktopConfiguration& desktop_config,
CFDictionaryRef window) {
bool IsWindowFullScreen(const MacDesktopConfiguration& desktop_config,
CFDictionaryRef window) {
bool fullscreen = false;
CFDictionaryRef bounds_ref = reinterpret_cast<CFDictionaryRef>(
CFDictionaryGetValue(window, kCGWindowBounds));
@ -164,10 +163,9 @@ bool IsWindowFullScreen(
for (MacDisplayConfigurations::const_iterator it =
desktop_config.displays.begin();
it != desktop_config.displays.end(); it++) {
if (it->bounds.equals(DesktopRect::MakeXYWH(bounds.origin.x,
bounds.origin.y,
bounds.size.width,
bounds.size.height))) {
if (it->bounds.equals(
DesktopRect::MakeXYWH(bounds.origin.x, bounds.origin.y,
bounds.size.width, bounds.size.height))) {
fullscreen = true;
break;
}
@ -185,10 +183,9 @@ bool IsWindowOnScreen(CFDictionaryRef window) {
bool IsWindowOnScreen(CGWindowID id) {
bool on_screen;
if (GetWindowRef(id,
[&on_screen](CFDictionaryRef window) {
on_screen = IsWindowOnScreen(window);
})) {
if (GetWindowRef(id, [&on_screen](CFDictionaryRef window) {
on_screen = IsWindowOnScreen(window);
})) {
return on_screen;
}
return false;
@ -265,18 +262,16 @@ DesktopRect GetWindowBounds(CFDictionaryRef window) {
return DesktopRect();
}
return DesktopRect::MakeXYWH(gc_window_rect.origin.x,
gc_window_rect.origin.y,
return DesktopRect::MakeXYWH(gc_window_rect.origin.x, gc_window_rect.origin.y,
gc_window_rect.size.width,
gc_window_rect.size.height);
}
DesktopRect GetWindowBounds(CGWindowID id) {
DesktopRect result;
if (GetWindowRef(id,
[&result](CFDictionaryRef window) {
result = GetWindowBounds(window);
})) {
if (GetWindowRef(id, [&result](CFDictionaryRef window) {
result = GetWindowBounds(window);
})) {
return result;
}
return DesktopRect();

View File

@ -19,8 +19,7 @@ namespace webrtc {
MouseCursor::MouseCursor() {}
MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot)
: image_(image),
hotspot_(hotspot) {
: image_(image), hotspot_(hotspot) {
assert(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width());
assert(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height());
}

View File

@ -34,7 +34,7 @@ class MouseCursor {
void set_image(DesktopFrame* image) { image_.reset(image); }
const DesktopFrame* image() const { return image_.get(); }
void set_hotspot(const DesktopVector& hotspot ) { hotspot_ = hotspot; }
void set_hotspot(const DesktopVector& hotspot) { hotspot_ = hotspot; }
const DesktopVector& hotspot() const { return hotspot_; }
private:

View File

@ -110,4 +110,3 @@ class MouseCursorMonitor {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_MOUSE_CURSOR_MONITOR_H_

View File

@ -10,11 +10,11 @@
#include <memory>
#include "modules/desktop_capture/mouse_cursor_monitor.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/mouse_cursor.h"
#include "modules/desktop_capture/mouse_cursor_monitor.h"
#include "test/gtest.h"
namespace webrtc {
@ -22,9 +22,7 @@ namespace webrtc {
class MouseCursorMonitorTest : public testing::Test,
public MouseCursorMonitor::Callback {
public:
MouseCursorMonitorTest()
: position_received_(false) {
}
MouseCursorMonitorTest() : position_received_(false) {}
// MouseCursorMonitor::Callback interface
void OnMouseCursor(MouseCursor* cursor_image) override {

View File

@ -31,8 +31,7 @@ namespace {
bool IsSameCursorShape(const CURSORINFO& left, const CURSORINFO& right) {
// If the cursors are not showing, we do not care the hCursor handle.
return left.flags == right.flags &&
(left.flags != CURSOR_SHOWING ||
left.hCursor == right.hCursor);
(left.flags != CURSOR_SHOWING || left.hCursor == right.hCursor);
}
} // namespace
@ -152,8 +151,9 @@ void MouseCursorMonitorWin::Capture() {
} else {
if (inside) {
HWND windowUnderCursor = WindowFromPoint(cursor_info.ptScreenPos);
inside = windowUnderCursor ?
(window_ == GetAncestor(windowUnderCursor, GA_ROOT)) : false;
inside = windowUnderCursor
? (window_ == GetAncestor(windowUnderCursor, GA_ROOT))
: false;
}
position = position.subtract(cropped_rect.top_left());
}
@ -171,11 +171,10 @@ void MouseCursorMonitorWin::Capture() {
DesktopRect MouseCursorMonitorWin::GetScreenRect() {
assert(screen_ != kInvalidScreenId);
if (screen_ == kFullDesktopScreenId) {
return DesktopRect::MakeXYWH(
GetSystemMetrics(SM_XVIRTUALSCREEN),
GetSystemMetrics(SM_YVIRTUALSCREEN),
GetSystemMetrics(SM_CXVIRTUALSCREEN),
GetSystemMetrics(SM_CYVIRTUALSCREEN));
return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN),
GetSystemMetrics(SM_YVIRTUALSCREEN),
GetSystemMetrics(SM_CXVIRTUALSCREEN),
GetSystemMetrics(SM_CYVIRTUALSCREEN));
}
DISPLAY_DEVICE device;
device.cb = sizeof(device);
@ -186,19 +185,19 @@ DesktopRect MouseCursorMonitorWin::GetScreenRect() {
DEVMODE device_mode;
device_mode.dmSize = sizeof(device_mode);
device_mode.dmDriverExtra = 0;
result = EnumDisplaySettingsEx(
device.DeviceName, ENUM_CURRENT_SETTINGS, &device_mode, 0);
result = EnumDisplaySettingsEx(device.DeviceName, ENUM_CURRENT_SETTINGS,
&device_mode, 0);
if (!result)
return DesktopRect();
return DesktopRect::MakeXYWH(device_mode.dmPosition.x,
device_mode.dmPosition.y,
device_mode.dmPelsWidth,
device_mode.dmPelsHeight);
return DesktopRect::MakeXYWH(
device_mode.dmPosition.x, device_mode.dmPosition.y,
device_mode.dmPelsWidth, device_mode.dmPelsHeight);
}
MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(
const DesktopCaptureOptions& options, WindowId window) {
const DesktopCaptureOptions& options,
WindowId window) {
return new MouseCursorMonitorWin(reinterpret_cast<HWND>(window));
}

View File

@ -12,9 +12,9 @@
#include "modules/desktop_capture/mouse_cursor_monitor.h"
#include <X11/extensions/Xfixes.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xfixes.h>
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capture_types.h"
@ -35,7 +35,7 @@ Window GetTopLevelWindow(Display* display, Window window) {
while (true) {
// If the window is in WithdrawnState then look at all of its children.
::Window root, parent;
::Window *children;
::Window* children;
unsigned int num_children;
if (!XQueryTree(display, window, &root, &parent, &children,
&num_children)) {
@ -104,12 +104,9 @@ MouseCursorMonitorX11::MouseCursorMonitorX11(
std::unique_ptr<DesktopFrame> default_cursor(
new BasicDesktopFrame(DesktopSize(kSize, kSize)));
const uint8_t pixels[kSize * kSize] = {
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00
};
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t* ptr = default_cursor->data();
for (int y = 0; y < kSize; ++y) {
for (int x = 0; x < kSize; ++x) {
@ -228,11 +225,11 @@ void MouseCursorMonitorX11::CaptureCursor() {
XErrorTrap error_trap(display());
img = XFixesGetCursorImage(display());
if (!img || error_trap.GetLastErrorAndDisable() != 0)
return;
}
return;
}
std::unique_ptr<DesktopFrame> image(
new BasicDesktopFrame(DesktopSize(img->width, img->height)));
std::unique_ptr<DesktopFrame> image(
new BasicDesktopFrame(DesktopSize(img->width, img->height)));
// Xlib stores 32-bit data in longs, even if longs are 64-bits long.
unsigned long* src = img->pixels;
@ -252,7 +249,8 @@ void MouseCursorMonitorX11::CaptureCursor() {
// static
MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(
const DesktopCaptureOptions& options, WindowId window) {
const DesktopCaptureOptions& options,
WindowId window) {
if (!options.x_display())
return NULL;
window = GetTopLevelWindow(options.x_display()->display(), window);

View File

@ -16,10 +16,9 @@
#include "rtc_base/constructormagic.h"
// TODO(zijiehe): These headers are not used in this file, but to avoid build
// break in remoting/host. We should add headers in each individual files.
#include "modules/desktop_capture/desktop_frame.h" // Remove
#include "modules/desktop_capture/desktop_frame.h" // Remove
#include "modules/desktop_capture/shared_desktop_frame.h" // Remove
namespace webrtc {
// Represents a queue of reusable video frames. Provides access to the 'current'
@ -43,9 +42,7 @@ class ScreenCaptureFrameQueue {
// Moves to the next frame in the queue, moving the 'current' frame to become
// the 'previous' one.
void MoveToNextFrame() {
current_ = (current_ + 1) % kQueueLength;
}
void MoveToNextFrame() { current_ = (current_ + 1) % kQueueLength; }
// Replaces the current frame with a new one allocated by the caller. The
// existing frame (if any) is destroyed. Takes ownership of |frame|.
@ -62,9 +59,7 @@ class ScreenCaptureFrameQueue {
current_ = 0;
}
FrameType* current_frame() const {
return frames_[current_].get();
}
FrameType* current_frame() const { return frames_[current_].get(); }
FrameType* previous_frame() const {
return frames_[(current_ + kQueueLength - 1) % kQueueLength].get();

View File

@ -16,12 +16,9 @@
namespace webrtc {
ScreenCapturerHelper::ScreenCapturerHelper()
: invalid_region_lock_(RWLockWrapper::CreateRWLock()),
log_grid_size_(0) {
}
: invalid_region_lock_(RWLockWrapper::CreateRWLock()), log_grid_size_(0) {}
ScreenCapturerHelper::~ScreenCapturerHelper() {
}
ScreenCapturerHelper::~ScreenCapturerHelper() {}
void ScreenCapturerHelper::ClearInvalidRegion() {
WriteLockScoped scoped_invalid_region_lock(*invalid_region_lock_);
@ -39,8 +36,7 @@ void ScreenCapturerHelper::InvalidateScreen(const DesktopSize& size) {
invalid_region_.AddRect(DesktopRect::MakeSize(size));
}
void ScreenCapturerHelper::TakeInvalidRegion(
DesktopRegion* invalid_region) {
void ScreenCapturerHelper::TakeInvalidRegion(DesktopRegion* invalid_region) {
invalid_region->Clear();
{
@ -65,8 +61,7 @@ const DesktopSize& ScreenCapturerHelper::size_most_recent() const {
return size_most_recent_;
}
void ScreenCapturerHelper::set_size_most_recent(
const DesktopSize& size) {
void ScreenCapturerHelper::set_size_most_recent(const DesktopSize& size) {
size_most_recent_ = size;
}

View File

@ -55,8 +55,7 @@ TEST_F(ScreenCapturerHelperTest, InvalidateScreen) {
TEST_F(ScreenCapturerHelperTest, SizeMostRecent) {
EXPECT_TRUE(capturer_helper_.size_most_recent().is_empty());
capturer_helper_.set_size_most_recent(DesktopSize(12, 34));
EXPECT_TRUE(
DesktopSize(12, 34).equals(capturer_helper_.size_most_recent()));
EXPECT_TRUE(DesktopSize(12, 34).equals(capturer_helper_.size_most_recent()));
}
TEST_F(ScreenCapturerHelperTest, SetLogGridSize) {
@ -103,7 +102,8 @@ TEST_F(ScreenCapturerHelperTest, SetLogGridSize) {
EXPECT_TRUE(DesktopRegion(DesktopRect::MakeXYWH(7, 7, 1, 1)).Equals(region));
}
void TestExpandRegionToGrid(const DesktopRegion& region, int log_grid_size,
void TestExpandRegionToGrid(const DesktopRegion& region,
int log_grid_size,
const DesktopRegion& expanded_region_expected) {
DesktopRegion expanded_region1;
ScreenCapturerHelper::ExpandToGrid(region, log_grid_size, &expanded_region1);
@ -115,9 +115,15 @@ void TestExpandRegionToGrid(const DesktopRegion& region, int log_grid_size,
EXPECT_TRUE(expanded_region1.Equals(expanded_region2));
}
void TestExpandRectToGrid(int l, int t, int r, int b, int log_grid_size,
int lExpanded, int tExpanded,
int rExpanded, int bExpanded) {
void TestExpandRectToGrid(int l,
int t,
int r,
int b,
int log_grid_size,
int lExpanded,
int tExpanded,
int rExpanded,
int bExpanded) {
TestExpandRegionToGrid(DesktopRegion(DesktopRect::MakeLTRB(l, t, r, b)),
log_grid_size,
DesktopRegion(DesktopRect::MakeLTRB(
@ -131,23 +137,23 @@ TEST_F(ScreenCapturerHelperTest, ExpandToGrid) {
int x = i * kGridSize;
for (int j = -2; j <= 2; j++) {
int y = j * kGridSize;
TestExpandRectToGrid(x + 0, y + 0, x + 1, y + 1, kLogGridSize,
x + 0, y + 0, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x + 0, y + 0, x + 1, y + 1, kLogGridSize, x + 0,
y + 0, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x + 0, y + kGridSize - 1, x + 1, y + kGridSize,
kLogGridSize,
x + 0, y + 0, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x + kGridSize - 1, y + kGridSize - 1,
x + kGridSize, y + kGridSize, kLogGridSize,
x + 0, y + 0, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x + kGridSize - 1, y + 0,
x + kGridSize, y + 1, kLogGridSize,
x + 0, y + 0, x + kGridSize, y + kGridSize);
kLogGridSize, x + 0, y + 0, x + kGridSize,
y + kGridSize);
TestExpandRectToGrid(x + kGridSize - 1, y + kGridSize - 1, x + kGridSize,
y + kGridSize, kLogGridSize, x + 0, y + 0,
x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x + kGridSize - 1, y + 0, x + kGridSize, y + 1,
kLogGridSize, x + 0, y + 0, x + kGridSize,
y + kGridSize);
TestExpandRectToGrid(x - 1, y + 0, x + 1, y + 1, kLogGridSize,
x - kGridSize, y + 0, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x - 1, y - 1, x + 1, y + 0, kLogGridSize,
x - kGridSize, y - kGridSize, x + kGridSize, y);
TestExpandRectToGrid(x + 0, y - 1, x + 1, y + 1, kLogGridSize,
x, y - kGridSize, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x + 0, y - 1, x + 1, y + 1, kLogGridSize, x,
y - kGridSize, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x - 1, y - 1, x + 0, y + 1, kLogGridSize,
x - kGridSize, y - kGridSize, x, y + kGridSize);
@ -164,18 +170,18 @@ TEST_F(ScreenCapturerHelperTest, ExpandToGrid) {
}
if (q != 1) {
region.AddRect(DesktopRect::MakeXYWH(x, y - 1, 1, 1));
expanded_region_expected.AddRect(DesktopRect::MakeXYWH(
x, y - kGridSize, kGridSize, kGridSize));
expanded_region_expected.AddRect(
DesktopRect::MakeXYWH(x, y - kGridSize, kGridSize, kGridSize));
}
if (q != 2) {
region.AddRect(DesktopRect::MakeXYWH(x - 1, y, 1, 1));
expanded_region_expected.AddRect(DesktopRect::MakeXYWH(
x - kGridSize, y, kGridSize, kGridSize));
expanded_region_expected.AddRect(
DesktopRect::MakeXYWH(x - kGridSize, y, kGridSize, kGridSize));
}
if (q != 3) {
region.AddRect(DesktopRect::MakeXYWH(x, y, 1, 1));
expanded_region_expected.AddRect(DesktopRect::MakeXYWH(
x, y, kGridSize, kGridSize));
expanded_region_expected.AddRect(
DesktopRect::MakeXYWH(x, y, kGridSize, kGridSize));
}
TestExpandRegionToGrid(region, kLogGridSize, expanded_region_expected);

View File

@ -89,8 +89,8 @@ class ScreenCapturerIntegrationTest : public testing::Test {
void TestCaptureUpdatedRegion(
std::initializer_list<DesktopCapturer*> capturers) {
RTC_DCHECK(capturers.size() > 0);
// A large enough area for the tests, which should be able to be fulfilled
// by most systems.
// A large enough area for the tests, which should be able to be fulfilled
// by most systems.
#if defined(WEBRTC_WIN)
// On Windows, an interesting warning window may pop up randomly. The root
// cause is still under investigation, so reduce the test area to work
@ -212,8 +212,8 @@ class ScreenCapturerIntegrationTest : public testing::Test {
return;
}
if (ArePixelsColoredBy(
*frame, rect, color, drawer->MayDrawIncompleteShapes())) {
if (ArePixelsColoredBy(*frame, rect, color,
drawer->MayDrawIncompleteShapes())) {
capturers[j] = nullptr;
succeeded_capturers++;
}
@ -222,17 +222,15 @@ class ScreenCapturerIntegrationTest : public testing::Test {
// been resolved.
else if (i == wait_capture_round - 1) {
std::string result;
rtc::Base64::EncodeFromArray(frame->data(),
frame->size().height() * frame->stride(),
&result);
rtc::Base64::EncodeFromArray(
frame->data(), frame->size().height() * frame->stride(), &result);
std::cout << frame->size().width() << " x " << frame->size().height()
<< std::endl;
// Split the entire string (can be over 4M) into several lines to
// avoid browser from sticking.
static const size_t kLineLength = 32768;
const char* result_end = result.c_str() + result.length();
for (const char* it = result.c_str();
it < result_end;
for (const char* it = result.c_str(); it < result_end;
it += kLineLength) {
const size_t max_length = result_end - it;
std::cout << std::string(it, std::min(kLineLength, max_length))

View File

@ -13,8 +13,8 @@
#include <memory>
#include <ostream>
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/desktop_region.h"

View File

@ -73,12 +73,9 @@ class ScreenCapturerTest : public testing::Test {
class FakeSharedMemory : public SharedMemory {
public:
FakeSharedMemory(char* buffer, size_t size)
: SharedMemory(buffer, size, 0, kTestSharedMemoryId),
buffer_(buffer) {
}
virtual ~FakeSharedMemory() {
delete[] buffer_;
}
: SharedMemory(buffer, size, 0, kTestSharedMemoryId), buffer_(buffer) {}
virtual ~FakeSharedMemory() { delete[] buffer_; }
private:
char* buffer_;
RTC_DISALLOW_COPY_AND_ASSIGN(FakeSharedMemory);

View File

@ -12,8 +12,8 @@
#include <utility>
#include "modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/fallback_desktop_capturer_wrapper.h"
#include "modules/desktop_capture/rgba_color.h"
#include "modules/desktop_capture/win/screen_capturer_win_directx.h"
@ -25,8 +25,7 @@ namespace webrtc {
namespace {
std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx() {
std::unique_ptr<DesktopCapturer> capturer(
new ScreenCapturerWinDirectx());
std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinDirectx());
capturer.reset(new BlankDetectorDesktopCapturerWrapper(
std::move(capturer), RgbaColor(0, 0, 0, 0)));
return capturer;

View File

@ -14,10 +14,10 @@
#include <set>
#include <utility>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xfixes.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xfixes.h>
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
@ -128,8 +128,8 @@ ScreenCapturerLinux::ScreenCapturerLinux() {
ScreenCapturerLinux::~ScreenCapturerLinux() {
options_.x_display()->RemoveEventHandler(ConfigureNotify, this);
if (use_damage_) {
options_.x_display()->RemoveEventHandler(
damage_event_base_ + XDamageNotify, this);
options_.x_display()->RemoveEventHandler(damage_event_base_ + XDamageNotify,
this);
}
DeinitXlib();
}
@ -197,8 +197,8 @@ void ScreenCapturerLinux::InitXDamage() {
// properly.
// Request notifications every time the screen becomes damaged.
damage_handle_ = XDamageCreate(display(), root_window_,
XDamageReportNonEmpty);
damage_handle_ =
XDamageCreate(display(), root_window_, XDamageReportNonEmpty);
if (!damage_handle_) {
RTC_LOG(LS_ERROR) << "Unable to initialize XDamage.";
return;
@ -212,8 +212,8 @@ void ScreenCapturerLinux::InitXDamage() {
return;
}
options_.x_display()->AddEventHandler(
damage_event_base_ + XDamageNotify, this);
options_.x_display()->AddEventHandler(damage_event_base_ + XDamageNotify,
this);
use_damage_ = true;
RTC_LOG(LS_INFO) << "Using XDamage extension.";
@ -240,10 +240,10 @@ void ScreenCapturerLinux::CaptureFrame() {
// reinitializes |x_server_pixel_buffer_|. Check if the pixel buffer is still
// in a good shape.
if (!x_server_pixel_buffer_.is_initialized()) {
// We failed to initialize pixel buffer.
RTC_LOG(LS_ERROR) << "Pixel buffer is not initialized.";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
// We failed to initialize pixel buffer.
RTC_LOG(LS_ERROR) << "Pixel buffer is not initialized.";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
// If the current frame is from an older generation then allocate a new one.
@ -336,8 +336,8 @@ std::unique_ptr<DesktopFrame> ScreenCapturerLinux::CaptureScreen() {
updated_region->IntersectWith(
DesktopRect::MakeSize(x_server_pixel_buffer_.window_size()));
for (DesktopRegion::Iterator it(*updated_region);
!it.IsAtEnd(); it.Advance()) {
for (DesktopRegion::Iterator it(*updated_region); !it.IsAtEnd();
it.Advance()) {
if (!x_server_pixel_buffer_.CaptureRect(it.rect(), frame.get()))
return nullptr;
}
@ -379,8 +379,8 @@ void ScreenCapturerLinux::SynchronizeFrame() {
DesktopFrame* current = queue_.current_frame();
DesktopFrame* last = queue_.previous_frame();
RTC_DCHECK(current != last);
for (DesktopRegion::Iterator it(last_invalid_region_);
!it.IsAtEnd(); it.Advance()) {
for (DesktopRegion::Iterator it(last_invalid_region_); !it.IsAtEnd();
it.Advance()) {
current->CopyPixelsFrom(*last, it.rect().top_left(), it.rect());
}
}

View File

@ -15,9 +15,9 @@
#include <memory>
#include "modules/desktop_capture/rgba_color.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/rgba_color.h"
namespace webrtc {

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <string.h>
#include <X11/Xlib.h>
#include <string.h>
#include <memory>

View File

@ -10,15 +10,15 @@
#include "modules/desktop_capture/screen_drawer.h"
#include <atomic>
#include <stdint.h>
#include <atomic>
#include "rtc_base/checks.h"
#include "rtc_base/function_view.h"
#include "rtc_base/logging.h"
#include "rtc_base/random.h"
#include "rtc_base/platform_thread.h"
#include "rtc_base/ptr_util.h"
#include "rtc_base/random.h"
#include "rtc_base/timeutils.h"
#include "system_wrappers/include/sleep.h"
#include "test/gtest.h"
@ -45,9 +45,7 @@ void TestScreenDrawerLock(
Task(std::atomic<bool>* created,
const std::atomic<bool>& ready,
rtc::FunctionView<std::unique_ptr<ScreenDrawerLock>()> ctor)
: created_(created),
ready_(ready),
ctor_(ctor) {}
: created_(created), ready_(ready), ctor_(ctor) {}
~Task() = default;
@ -85,7 +83,8 @@ void TestScreenDrawerLock(
// Wait for the first lock in Task::RunTask() to be created.
// TODO(zijiehe): Find a better solution to wait for the creation of the first
// lock. See https://chromium-review.googlesource.com/c/607688/13/webrtc/modules/desktop_capture/screen_drawer_unittest.cc
// lock. See
// https://chromium-review.googlesource.com/c/607688/13/webrtc/modules/desktop_capture/screen_drawer_unittest.cc
while (!created.load()) {
SleepMs(1);
}
@ -152,9 +151,7 @@ TEST(ScreenDrawerTest, TwoScreenDrawerLocks) {
return rtc::MakeUnique<ScreenDrawerLockPosix>(semaphore_name);
});
#elif defined(WEBRTC_WIN)
TestScreenDrawerLock([]() {
return ScreenDrawerLock::Create();
});
TestScreenDrawerLock([]() { return ScreenDrawerLock::Create(); });
#endif
}

View File

@ -19,10 +19,6 @@ const SharedMemory::Handle SharedMemory::kInvalidHandle = -1;
#endif
SharedMemory::SharedMemory(void* data, size_t size, Handle handle, int id)
: data_(data),
size_(size),
handle_(handle),
id_(id) {
}
: data_(data), size_(size), handle_(handle), id_(id) {}
} // namespace webrtc

View File

@ -80,4 +80,3 @@ class SharedMemoryFactory {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_SHARED_MEMORY_H_

View File

@ -34,8 +34,7 @@ bool DesktopFrameDataEquals(const DesktopFrame& left,
const uint8_t* left_array = left.data();
const uint8_t* right_array = right.data();
for (int i = 0; i < left.size().height(); i++) {
if (memcmp(left_array,
right_array,
if (memcmp(left_array, right_array,
DesktopFrame::kBytesPerPixel * left.size().width()) != 0) {
return false;
}

View File

@ -26,19 +26,15 @@ namespace {
#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
#define RGBA(r, g, b, a) \
((((a) << 24) & 0xff000000) | \
(((b) << 16) & 0xff0000) | \
(((g) << 8) & 0xff00) | \
((r) & 0xff))
#define RGBA(r, g, b, a) \
((((a) << 24) & 0xff000000) | (((b) << 16) & 0xff0000) | \
(((g) << 8) & 0xff00) | ((r)&0xff))
#else // !defined(WEBRTC_ARCH_LITTLE_ENDIAN)
#define RGBA(r, g, b, a) \
((((r) << 24) & 0xff000000) | \
(((g) << 16) & 0xff0000) | \
(((b) << 8) & 0xff00) | \
((a) & 0xff))
#define RGBA(r, g, b, a) \
((((r) << 24) & 0xff000000) | (((g) << 16) & 0xff0000) | \
(((b) << 8) & 0xff00) | ((a)&0xff))
#endif // !defined(WEBRTC_ARCH_LITTLE_ENDIAN)
@ -149,13 +145,8 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) {
bmi.bV5AlphaMask = 0xff000000;
bmi.bV5CSType = LCS_WINDOWS_COLOR_SPACE;
bmi.bV5Intent = LCS_GM_BUSINESS;
if (!GetDIBits(dc,
scoped_mask,
0,
height,
mask_data.get(),
reinterpret_cast<BITMAPINFO*>(&bmi),
DIB_RGB_COLORS)) {
if (!GetDIBits(dc, scoped_mask, 0, height, mask_data.get(),
reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS)) {
RTC_LOG_F(LS_ERROR) << "Unable to get bitmap bits. Error = "
<< GetLastError();
return NULL;
@ -169,13 +160,8 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) {
if (is_color) {
image.reset(new BasicDesktopFrame(DesktopSize(width, height)));
// Get the pixels from the color bitmap.
if (!GetDIBits(dc,
scoped_color,
0,
height,
image->data(),
reinterpret_cast<BITMAPINFO*>(&bmi),
DIB_RGB_COLORS)) {
if (!GetDIBits(dc, scoped_color, 0, height, image->data(),
reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS)) {
RTC_LOG_F(LS_ERROR) << "Unable to get bitmap bits. Error = "
<< GetLastError();
return NULL;
@ -194,8 +180,8 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) {
image.reset(new BasicDesktopFrame(DesktopSize(width, height)));
// The XOR mask becomes the color bitmap.
memcpy(
image->data(), mask_plane + (width * height), image->stride() * height);
memcpy(image->data(), mask_plane + (width * height),
image->stride() * height);
}
// Reconstruct transparency from the mask if the color image does not has
@ -232,8 +218,8 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) {
}
}
if (add_outline) {
AddCursorOutline(
width, height, reinterpret_cast<uint32_t*>(image->data()));
AddCursorOutline(width, height,
reinterpret_cast<uint32_t*>(image->data()));
}
}
@ -241,8 +227,7 @@ MouseCursor* CreateMouseCursorFromHCursor(HDC dc, HCURSOR cursor) {
// images.
AlphaMul(reinterpret_cast<uint32_t*>(image->data()), width, height);
return new MouseCursor(
image.release(), DesktopVector(hotspot_x, hotspot_y));
return new MouseCursor(image.release(), DesktopVector(hotspot_x, hotspot_y));
}
} // namespace webrtc

View File

@ -74,17 +74,17 @@ bool ConvertToMouseShapeAndCompare(unsigned left, unsigned right) {
} // namespace
TEST(MouseCursorTest, MatchCursors) {
EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR1_24BPP,
IDD_CURSOR1_32BPP));
EXPECT_TRUE(
ConvertToMouseShapeAndCompare(IDD_CURSOR1_24BPP, IDD_CURSOR1_32BPP));
EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR1_8BPP,
IDD_CURSOR1_32BPP));
EXPECT_TRUE(
ConvertToMouseShapeAndCompare(IDD_CURSOR1_8BPP, IDD_CURSOR1_32BPP));
EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR2_1BPP,
IDD_CURSOR2_32BPP));
EXPECT_TRUE(
ConvertToMouseShapeAndCompare(IDD_CURSOR2_1BPP, IDD_CURSOR2_32BPP));
EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR3_4BPP,
IDD_CURSOR3_32BPP));
EXPECT_TRUE(
ConvertToMouseShapeAndCompare(IDD_CURSOR3_4BPP, IDD_CURSOR3_32BPP));
}
} // namespace webrtc

View File

@ -11,14 +11,14 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_
#define MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_
#define IDD_CURSOR1_24BPP 101
#define IDD_CURSOR1_32BPP 102
#define IDD_CURSOR1_8BPP 103
#define IDD_CURSOR1_24BPP 101
#define IDD_CURSOR1_32BPP 102
#define IDD_CURSOR1_8BPP 103
#define IDD_CURSOR2_1BPP 104
#define IDD_CURSOR2_32BPP 105
#define IDD_CURSOR2_1BPP 104
#define IDD_CURSOR2_32BPP 105
#define IDD_CURSOR3_4BPP 106
#define IDD_CURSOR3_32BPP 107
#define IDD_CURSOR3_4BPP 106
#define IDD_CURSOR3_32BPP 107
#endif // MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_

View File

@ -69,8 +69,9 @@ bool D3dDevice::Initialize(const ComPtr<IDXGIAdapter>& adapter) {
// static
std::vector<D3dDevice> D3dDevice::EnumDevices() {
ComPtr<IDXGIFactory1> factory;
_com_error error = CreateDXGIFactory1(__uuidof(IDXGIFactory1),
reinterpret_cast<void**>(factory.GetAddressOf()));
_com_error error =
CreateDXGIFactory1(__uuidof(IDXGIFactory1),
reinterpret_cast<void**>(factory.GetAddressOf()));
if (error.Error() != S_OK || !factory) {
RTC_LOG(LS_WARNING) << "Cannot create IDXGIFactory1.";
return std::vector<D3dDevice>();

View File

@ -11,10 +11,10 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_
#define MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_
#include <comdef.h>
#include <wrl/client.h>
#include <D3D11.h>
#include <DXGI.h>
#include <comdef.h>
#include <wrl/client.h>
#include <vector>

View File

@ -16,8 +16,7 @@
namespace webrtc {
Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) {
}
Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) {}
Desktop::~Desktop() {
if (own_ && desktop_ != NULL) {
@ -72,10 +71,10 @@ bool Desktop::SetThreadDesktop() const {
}
Desktop* Desktop::GetDesktop(const WCHAR* desktop_name) {
ACCESS_MASK desired_access =
DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE |
DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP | GENERIC_WRITE;
ACCESS_MASK desired_access = DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP | GENERIC_WRITE;
HDESK desktop = OpenDesktop(desktop_name, 0, FALSE, desired_access);
if (desktop == NULL) {
RTC_LOG(LS_ERROR) << "Failed to open the desktop '" << desktop_name

View File

@ -10,8 +10,8 @@
#include "modules/desktop_capture/win/dxgi_adapter_duplicator.h"
#include <comdef.h>
#include <DXGI.h>
#include <comdef.h>
#include <algorithm>

View File

@ -14,8 +14,8 @@
namespace webrtc {
DxgiAdapterContext::DxgiAdapterContext() = default;
DxgiAdapterContext::DxgiAdapterContext(
const DxgiAdapterContext& context) = default;
DxgiAdapterContext::DxgiAdapterContext(const DxgiAdapterContext& context) =
default;
DxgiAdapterContext::~DxgiAdapterContext() = default;
DxgiFrameContext::DxgiFrameContext() = default;

View File

@ -67,8 +67,7 @@ bool DxgiDuplicatorController::IsCurrentSessionSupported() {
return session_id != 0;
}
DxgiDuplicatorController::DxgiDuplicatorController()
: refcount_(0) {}
DxgiDuplicatorController::DxgiDuplicatorController() : refcount_(0) {}
void DxgiDuplicatorController::AddRef() {
int refcount = (++refcount_);
@ -104,13 +103,14 @@ bool DxgiDuplicatorController::RetrieveD3dInfo(D3dInfo* info) {
return result;
}
DxgiDuplicatorController::Result
DxgiDuplicatorController::Duplicate(DxgiFrame* frame) {
DxgiDuplicatorController::Result DxgiDuplicatorController::Duplicate(
DxgiFrame* frame) {
return DoDuplicate(frame, -1);
}
DxgiDuplicatorController::Result
DxgiDuplicatorController::DuplicateMonitor(DxgiFrame* frame, int monitor_id) {
DxgiDuplicatorController::Result DxgiDuplicatorController::DuplicateMonitor(
DxgiFrame* frame,
int monitor_id) {
RTC_DCHECK_GE(monitor_id, 0);
return DoDuplicate(frame, monitor_id);
}
@ -141,8 +141,9 @@ bool DxgiDuplicatorController::GetDeviceNames(
return false;
}
DxgiDuplicatorController::Result
DxgiDuplicatorController::DoDuplicate(DxgiFrame* frame, int monitor_id) {
DxgiDuplicatorController::Result DxgiDuplicatorController::DoDuplicate(
DxgiFrame* frame,
int monitor_id) {
RTC_DCHECK(frame);
rtc::CritScope lock(&lock_);
@ -443,8 +444,8 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context,
// |fallback_frame|.
shared_frame = target;
} else {
fallback_frame = SharedDesktopFrame::Wrap(std::unique_ptr<DesktopFrame>(
new BasicDesktopFrame(desktop_size())));
fallback_frame = SharedDesktopFrame::Wrap(
std::unique_ptr<DesktopFrame>(new BasicDesktopFrame(desktop_size())));
shared_frame = fallback_frame.get();
}
@ -454,8 +455,7 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context,
if (GetNumFramesCaptured() > 0) {
// Sleep |ms_per_frame| before capturing next frame to ensure the screen
// has been updated by the video adapter.
webrtc::SleepMs(
ms_per_frame - (rtc::TimeMillis() - last_frame_start_ms));
webrtc::SleepMs(ms_per_frame - (rtc::TimeMillis() - last_frame_start_ms));
}
last_frame_start_ms = rtc::TimeMillis();
if (!DoDuplicateAll(context, shared_frame)) {

View File

@ -21,8 +21,7 @@
namespace webrtc {
DxgiFrame::DxgiFrame(SharedMemoryFactory* factory)
: factory_(factory) {}
DxgiFrame::DxgiFrame(SharedMemoryFactory* factory) : factory_(factory) {}
DxgiFrame::~DxgiFrame() = default;

View File

@ -14,8 +14,8 @@
#include <memory>
#include <vector>
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/resolution_tracker.h"
#include "modules/desktop_capture/shared_desktop_frame.h"

View File

@ -12,10 +12,10 @@
#include <string.h>
#include <unknwn.h>
#include <DXGI.h>
#include <DXGIFormat.h>
#include <Windows.h>
#include <unknwn.h>
#include <algorithm>
@ -177,9 +177,7 @@ bool DxgiOutputDuplicator::Duplicate(Context* context,
// context here. The |updated_region| always starts from (0, 0).
DesktopRegion updated_region;
updated_region.Swap(&context->updated_region);
if (error.Error() == S_OK &&
frame_info.AccumulatedFrames > 0 &&
resource) {
if (error.Error() == S_OK && frame_info.AccumulatedFrames > 0 && resource) {
DetectUpdatedRegion(frame_info, &context->updated_region);
SpreadContextChange(context);
if (!texture_->CopyFrom(frame_info, resource.Get())) {
@ -195,8 +193,8 @@ bool DxgiOutputDuplicator::Duplicate(Context* context,
it.Advance()) {
// The |updated_region| returned by Windows is rotated, but the |source|
// frame is not. So we need to rotate it reversely.
const DesktopRect source_rect = RotateRect(
it.rect(), desktop_size(), ReverseRotation(rotation_));
const DesktopRect source_rect =
RotateRect(it.rect(), desktop_size(), ReverseRotation(rotation_));
RotateDesktopFrame(source, source_rect, rotation_, offset, target);
}
} else {

View File

@ -11,10 +11,10 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_DXGI_OUTPUT_DUPLICATOR_H_
#define MODULES_DESKTOP_CAPTURE_WIN_DXGI_OUTPUT_DUPLICATOR_H_
#include <comdef.h>
#include <wrl/client.h>
#include <DXGI.h>
#include <DXGI1_2.h>
#include <comdef.h>
#include <wrl/client.h>
#include <memory>
#include <string>

View File

@ -10,9 +10,9 @@
#include "modules/desktop_capture/win/dxgi_texture.h"
#include <D3D11.h>
#include <comdef.h>
#include <wrl/client.h>
#include <D3D11.h>
#include "modules/desktop_capture/desktop_region.h"
#include "rtc_base/checks.h"

View File

@ -10,9 +10,9 @@
#include "modules/desktop_capture/win/dxgi_texture_mapping.h"
#include <comdef.h>
#include <DXGI.h>
#include <DXGI1_2.h>
#include <comdef.h>
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"

View File

@ -10,10 +10,10 @@
#include "modules/desktop_capture/win/dxgi_texture_staging.h"
#include <comdef.h>
#include <unknwn.h>
#include <DXGI.h>
#include <DXGI1_2.h>
#include <comdef.h>
#include <unknwn.h>
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
@ -45,8 +45,8 @@ bool DxgiTextureStaging::InitializeStage(ID3D11Texture2D* texture) {
AssertStageAndSurfaceAreSameObject();
D3D11_TEXTURE2D_DESC current_desc;
stage_->GetDesc(&current_desc);
const bool recreate_needed = (
memcmp(&desc, &current_desc, sizeof(D3D11_TEXTURE2D_DESC)) != 0);
const bool recreate_needed =
(memcmp(&desc, &current_desc, sizeof(D3D11_TEXTURE2D_DESC)) != 0);
RTC_HISTOGRAM_BOOLEAN("WebRTC.DesktopCapture.StagingTextureRecreate",
recreate_needed);
if (!recreate_needed) {

View File

@ -11,9 +11,9 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_STAGING_H_
#define MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_STAGING_H_
#include <wrl/client.h>
#include <D3D11.h>
#include <DXGI1_2.h>
#include <wrl/client.h>
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/desktop_region.h"

View File

@ -20,19 +20,15 @@ namespace webrtc {
namespace win {
// Scoper for GDI objects.
template<class T, class Traits>
template <class T, class Traits>
class ScopedGDIObject {
public:
ScopedGDIObject() : handle_(NULL) {}
explicit ScopedGDIObject(T object) : handle_(object) {}
~ScopedGDIObject() {
Traits::Close(handle_);
}
~ScopedGDIObject() { Traits::Close(handle_); }
T Get() {
return handle_;
}
T Get() { return handle_; }
void Set(T object) {
if (handle_ && object != handle_)

View File

@ -15,8 +15,7 @@
namespace webrtc {
ScopedThreadDesktop::ScopedThreadDesktop()
: initial_(Desktop::GetThreadDesktop()) {
}
: initial_(Desktop::GetThreadDesktop()) {}
ScopedThreadDesktop::~ScopedThreadDesktop() {
Revert();

View File

@ -95,15 +95,14 @@ DesktopRect GetScreenRect(DesktopCapturer::SourceId screen,
DEVMODE device_mode;
device_mode.dmSize = sizeof(device_mode);
device_mode.dmDriverExtra = 0;
result = EnumDisplaySettingsEx(
device.DeviceName, ENUM_CURRENT_SETTINGS, &device_mode, 0);
result = EnumDisplaySettingsEx(device.DeviceName, ENUM_CURRENT_SETTINGS,
&device_mode, 0);
if (!result)
return DesktopRect();
return DesktopRect::MakeXYWH(device_mode.dmPosition.x,
device_mode.dmPosition.y,
device_mode.dmPelsWidth,
device_mode.dmPelsHeight);
return DesktopRect::MakeXYWH(
device_mode.dmPosition.x, device_mode.dmPosition.y,
device_mode.dmPelsWidth, device_mode.dmPelsHeight);
}
} // namespace webrtc

View File

@ -11,8 +11,8 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_
#define MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_
#include <vector>
#include <string>
#include <vector>
#include "modules/desktop_capture/desktop_capturer.h"

View File

@ -10,8 +10,8 @@
#include "modules/desktop_capture/win/screen_capture_utils.h"
#include <vector>
#include <string>
#include <vector>
#include "modules/desktop_capture/desktop_capturer.h"
#include "test/gtest.h"

View File

@ -65,14 +65,13 @@ bool ScreenCapturerWinDirectx::GetScreenListFromDeviceNames(
}
for (const auto& device_name : device_names) {
const auto it = std::find(
gdi_names.begin(), gdi_names.end(), device_name);
const auto it = std::find(gdi_names.begin(), gdi_names.end(), device_name);
if (it == gdi_names.end()) {
// devices_names[i] has not been found in gdi_names, so use max_screen_id.
max_screen_id++;
screens->push_back({ max_screen_id });
screens->push_back({max_screen_id});
} else {
screens->push_back({ gdi_screens[it - gdi_names.begin()] });
screens->push_back({gdi_screens[it - gdi_names.begin()]});
}
}
@ -132,8 +131,8 @@ void ScreenCapturerWinDirectx::CaptureFrame() {
if (current_screen_id_ == kFullDesktopScreenId) {
result = controller_->Duplicate(frames_.current_frame());
} else {
result = controller_->DuplicateMonitor(
frames_.current_frame(), current_screen_id_);
result = controller_->DuplicateMonitor(frames_.current_frame(),
current_screen_id_);
}
using DuplicateResult = DxgiDuplicatorController::Result;
@ -170,9 +169,8 @@ void ScreenCapturerWinDirectx::CaptureFrame() {
case DuplicateResult::SUCCEEDED: {
std::unique_ptr<DesktopFrame> frame =
frames_.current_frame()->frame()->Share();
frame->set_capture_time_ms(
(rtc::TimeNanos() - capture_start_time_nanos) /
rtc::kNumNanosecsPerMillisec);
frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) /
rtc::kNumNanosecsPerMillisec);
frame->set_capturer_id(DesktopCapturerId::kScreenCapturerWinDirectx);
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
break;

View File

@ -10,8 +10,8 @@
#include "modules/desktop_capture/win/screen_capturer_win_directx.h"
#include <vector>
#include <string>
#include <vector>
#include "modules/desktop_capture/desktop_capturer.h"
#include "test/gtest.h"
@ -22,9 +22,7 @@ namespace webrtc {
// devices in its output, since the device name is missing.
TEST(ScreenCaptureUtilsTest, GetScreenListFromDeviceNamesAndGetIndex) {
const std::vector<std::string> device_names = {
"\\\\.\\DISPLAY0",
"\\\\.\\DISPLAY1",
"\\\\.\\DISPLAY2",
"\\\\.\\DISPLAY0", "\\\\.\\DISPLAY1", "\\\\.\\DISPLAY2",
};
DesktopCapturer::SourceList screens;
ASSERT_TRUE(ScreenCapturerWinDirectx::GetScreenListFromDeviceNames(
@ -32,8 +30,8 @@ TEST(ScreenCaptureUtilsTest, GetScreenListFromDeviceNamesAndGetIndex) {
ASSERT_EQ(device_names.size(), screens.size());
for (size_t i = 0; i < screens.size(); i++) {
ASSERT_EQ(ScreenCapturerWinDirectx::GetIndexFromScreenId(
screens[i].id, device_names),
ASSERT_EQ(ScreenCapturerWinDirectx::GetIndexFromScreenId(screens[i].id,
device_names),
static_cast<int>(i));
}
}

View File

@ -88,14 +88,12 @@ void ScreenCapturerWinGdi::CaptureFrame() {
// Emit the current frame.
std::unique_ptr<DesktopFrame> frame = queue_.current_frame()->Share();
frame->set_dpi(DesktopVector(
GetDeviceCaps(desktop_dc_, LOGPIXELSX),
GetDeviceCaps(desktop_dc_, LOGPIXELSY)));
frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX),
GetDeviceCaps(desktop_dc_, LOGPIXELSY)));
frame->mutable_updated_region()->SetRect(
DesktopRect::MakeSize(frame->size()));
frame->set_capture_time_ms(
(rtc::TimeNanos() - capture_start_time_nanos) /
rtc::kNumNanosecsPerMillisec);
frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) /
rtc::kNumNanosecsPerMillisec);
frame->set_capturer_id(DesktopCapturerId::kScreenCapturerWinGdi);
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
}
@ -216,8 +214,8 @@ bool ScreenCapturerWinGdi::CaptureImage() {
}
bool result = (BitBlt(memory_dc_, 0, 0, screen_rect.width(),
screen_rect.height(), desktop_dc_, screen_rect.left(), screen_rect.top(),
SRCCOPY | CAPTUREBLT) != FALSE);
screen_rect.height(), desktop_dc_, screen_rect.left(),
screen_rect.top(), SRCCOPY | CAPTUREBLT) != FALSE);
if (!result) {
RTC_LOG_GLE(LS_WARNING) << "BitBlt failed";
}

View File

@ -44,7 +44,7 @@ class ScreenCapturerWinGdi : public DesktopCapturer {
bool SelectSource(SourceId id) override;
private:
typedef HRESULT (WINAPI * DwmEnableCompositionFunc)(UINT);
typedef HRESULT(WINAPI* DwmEnableCompositionFunc)(UINT);
// Make sure that the device contexts match the screen configuration.
void PrepareCaptureResources();

View File

@ -136,8 +136,8 @@ bool ScreenCapturerWinMagnifier::SelectSource(SourceId id) {
void ScreenCapturerWinMagnifier::SetExcludedWindow(WindowId excluded_window) {
excluded_window_ = (HWND)excluded_window;
if (excluded_window_ && magnifier_initialized_) {
set_window_filter_list_func_(
magnifier_window_, MW_FILTERMODE_EXCLUDE, 1, &excluded_window_);
set_window_filter_list_func_(magnifier_window_, MW_FILTERMODE_EXCLUDE, 1,
&excluded_window_);
}
}
@ -186,8 +186,7 @@ BOOL ScreenCapturerWinMagnifier::OnMagImageScalingCallback(
RECT clipped,
HRGN dirty) {
ScreenCapturerWinMagnifier* owner =
reinterpret_cast<ScreenCapturerWinMagnifier*>(
TlsGetValue(GetTlsIndex()));
reinterpret_cast<ScreenCapturerWinMagnifier*>(TlsGetValue(GetTlsIndex()));
TlsSetValue(GetTlsIndex(), nullptr);
owner->OnCaptured(srcdata, srcheader);
@ -243,10 +242,10 @@ bool ScreenCapturerWinMagnifier::InitializeMagnifier() {
}
HMODULE hInstance = nullptr;
result = GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<char*>(&DefWindowProc),
&hInstance);
result =
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<char*>(&DefWindowProc), &hInstance);
if (!result) {
mag_uninitialize_func_();
RTC_LOG_F(LS_WARNING) << "Failed to initialize ScreenCapturerWinMagnifier: "
@ -346,8 +345,7 @@ void ScreenCapturerWinMagnifier::OnCaptured(void* data,
// Copy the data into the frame.
current_frame->CopyPixelsFrom(
reinterpret_cast<uint8_t*>(data),
header.stride,
reinterpret_cast<uint8_t*>(data), header.stride,
DesktopRect::MakeXYWH(0, 0, header.width, header.height));
magnifier_capture_succeeded_ = true;

View File

@ -13,9 +13,9 @@
#include <memory>
#include <windows.h>
#include <magnification.h>
#include <wincodec.h>
#include <windows.h>
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/screen_capture_frame_queue.h"

View File

@ -25,8 +25,7 @@ bool GetWindowRect(HWND window, DesktopRect* result) {
if (!::GetWindowRect(window, &rect)) {
return false;
}
*result = DesktopRect::MakeLTRB(
rect.left, rect.top, rect.right, rect.bottom);
*result = DesktopRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom);
return true;
}
@ -97,22 +96,22 @@ bool GetWindowContentRect(HWND window, DesktopRect* result) {
}
int GetWindowRegionTypeWithBoundary(HWND window, DesktopRect* result) {
win::ScopedGDIObject<HRGN, win::DeleteObjectTraits<HRGN>>
scoped_hrgn(CreateRectRgn(0, 0, 0, 0));
win::ScopedGDIObject<HRGN, win::DeleteObjectTraits<HRGN>> scoped_hrgn(
CreateRectRgn(0, 0, 0, 0));
const int region_type = GetWindowRgn(window, scoped_hrgn.Get());
if (region_type == SIMPLEREGION) {
RECT rect;
GetRgnBox(scoped_hrgn.Get(), &rect);
*result = DesktopRect::MakeLTRB(
rect.left, rect.top, rect.right, rect.bottom);
*result =
DesktopRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom);
}
return region_type;
}
bool GetDcSize(HDC hdc, DesktopSize* size) {
win::ScopedGDIObject<HGDIOBJ, win::DeleteObjectTraits<HGDIOBJ>>
scoped_hgdi(GetCurrentObject(hdc, OBJ_BITMAP));
win::ScopedGDIObject<HGDIOBJ, win::DeleteObjectTraits<HGDIOBJ>> scoped_hgdi(
GetCurrentObject(hdc, OBJ_BITMAP));
BITMAP bitmap;
memset(&bitmap, 0, sizeof(BITMAP));
if (GetObject(scoped_hgdi.Get(), sizeof(BITMAP), &bitmap) == 0) {

View File

@ -59,7 +59,7 @@ bool GetDcSize(HDC hdc, DesktopSize* size);
// function returns false if native APIs fail.
bool IsWindowMaximized(HWND window, bool* result);
typedef HRESULT (WINAPI *DwmIsCompositionEnabledFunc)(BOOL* enabled);
typedef HRESULT(WINAPI* DwmIsCompositionEnabledFunc)(BOOL* enabled);
class WindowCaptureHelperWin {
public:
WindowCaptureHelperWin();

View File

@ -10,8 +10,8 @@
#include <memory>
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_region.h"
#include "test/gtest.h"

View File

@ -104,8 +104,8 @@ bool GetWindowDrawableRect(HWND window,
}
if (is_maximized) {
return GetCroppedWindowRect(
window, drawable_rect, /* original_rect */ nullptr);
return GetCroppedWindowRect(window, drawable_rect,
/* original_rect */ nullptr);
}
*drawable_rect = *original_rect;
return true;
@ -198,8 +198,8 @@ bool WindowCapturerWin::FocusOnSelectedSource() {
bool WindowCapturerWin::IsOccluded(const DesktopVector& pos) {
DesktopVector sys_pos = pos.add(GetFullscreenRect().top_left());
return reinterpret_cast<HWND>(window_finder_.GetWindowUnderPoint(sys_pos))
!= window_;
return reinterpret_cast<HWND>(window_finder_.GetWindowUnderPoint(sys_pos)) !=
window_;
}
void WindowCapturerWin::Start(Callback* callback) {
@ -317,10 +317,8 @@ void WindowCapturerWin::CaptureFrame() {
// Aero is enabled or PrintWindow() failed, use BitBlt.
if (!result) {
result = BitBlt(mem_dc, 0, 0, frame->size().width(), frame->size().height(),
window_dc,
cropped_rect.left() - original_rect.left(),
cropped_rect.top() - original_rect.top(),
SRCCOPY);
window_dc, cropped_rect.left() - original_rect.left(),
cropped_rect.top() - original_rect.top(), SRCCOPY);
}
SelectObject(mem_dc, previous_object);

View File

@ -10,9 +10,9 @@
#include <string.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
#include <X11/Xutil.h>
#include <utility>
@ -93,15 +93,14 @@ WindowCapturerLinux::~WindowCapturerLinux() {
}
bool WindowCapturerLinux::GetSourceList(SourceList* sources) {
return GetWindowList(&atom_cache_,
[this, sources](::Window window) {
Source w;
w.id = window;
if (this->GetWindowTitle(window, &w.title)) {
sources->push_back(w);
}
return true;
});
return GetWindowList(&atom_cache_, [this, sources](::Window window) {
Source w;
w.id = window;
if (this->GetWindowTitle(window, &w.title)) {
sources->push_back(w);
}
return true;
});
}
bool WindowCapturerLinux::SelectSource(SourceId id) {
@ -134,8 +133,8 @@ bool WindowCapturerLinux::FocusOnSelectedSource() {
::Window parent;
::Window root;
// Find the root window to pass event to.
int status = XQueryTree(
display(), selected_window_, &root, &parent, &children, &num_children);
int status = XQueryTree(display(), selected_window_, &root, &parent,
&children, &num_children);
if (status == 0) {
RTC_LOG(LS_ERROR) << "Failed to query for the root window.";
return false;
@ -164,11 +163,8 @@ bool WindowCapturerLinux::FocusOnSelectedSource() {
memset(xev.xclient.data.l, 0, sizeof(xev.xclient.data.l));
XSendEvent(display(),
root,
False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
XSendEvent(display(), root, False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
XFlush(display());
return true;
@ -229,7 +225,7 @@ void WindowCapturerLinux::CaptureFrame() {
bool WindowCapturerLinux::IsOccluded(const DesktopVector& pos) {
return window_finder_.GetWindowUnderPoint(pos) !=
static_cast<WindowId>(selected_window_);
static_cast<WindowId>(selected_window_);
}
bool WindowCapturerLinux::HandleXEvent(const XEvent& event) {
@ -237,7 +233,7 @@ bool WindowCapturerLinux::HandleXEvent(const XEvent& event) {
XConfigureEvent xce = event.xconfigure;
if (xce.window == selected_window_) {
if (!DesktopRectFromXAttributes(xce).equals(
x_server_pixel_buffer_.window_rect())) {
x_server_pixel_buffer_.window_rect())) {
if (!x_server_pixel_buffer_.Init(display(), selected_window_)) {
RTC_LOG(LS_ERROR)
<< "Failed to initialize pixel buffer after resizing.";
@ -260,8 +256,8 @@ bool WindowCapturerLinux::GetWindowTitle(::Window window, std::string* title) {
if (status && window_name.value && window_name.nitems) {
int cnt;
char** list = nullptr;
status = Xutf8TextPropertyToTextList(display(), &window_name, &list,
&cnt);
status =
Xutf8TextPropertyToTextList(display(), &window_name, &list, &cnt);
if (status >= Success && cnt && *list) {
if (cnt > 1) {
RTC_LOG(LS_INFO) << "Window has " << cnt

View File

@ -28,8 +28,8 @@
#if defined(WEBRTC_WIN)
#include <windows.h>
#include "modules/desktop_capture/window_finder_win.h"
#include "modules/desktop_capture/win/window_capture_utils.h"
#include "modules/desktop_capture/window_finder_win.h"
#endif
namespace webrtc {
@ -64,8 +64,8 @@ TEST(WindowFinderTest, FindConsoleWindow) {
MoveWindow(console_window, 0, 0, kMaxSize, kMaxSize, true);
// Brings console window to top.
SetWindowPos(
console_window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos(console_window, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
BringWindowToTop(console_window);
WindowFinderWin finder;
@ -154,14 +154,14 @@ TEST(WindowFinderTest, ShouldReturnNullWindowIfSpotIsOutOfScreen) {
return;
}
ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint(
DesktopVector(INT16_MAX, INT16_MAX)));
ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint(
DesktopVector(INT16_MAX, INT16_MIN)));
ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint(
DesktopVector(INT16_MIN, INT16_MAX)));
ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint(
DesktopVector(INT16_MIN, INT16_MIN)));
ASSERT_EQ(kNullWindowId,
finder->GetWindowUnderPoint(DesktopVector(INT16_MAX, INT16_MAX)));
ASSERT_EQ(kNullWindowId,
finder->GetWindowUnderPoint(DesktopVector(INT16_MAX, INT16_MIN)));
ASSERT_EQ(kNullWindowId,
finder->GetWindowUnderPoint(DesktopVector(INT16_MIN, INT16_MAX)));
ASSERT_EQ(kNullWindowId,
finder->GetWindowUnderPoint(DesktopVector(INT16_MIN, INT16_MIN)));
}
} // namespace

View File

@ -20,7 +20,7 @@ WindowFinderWin::WindowFinderWin() = default;
WindowFinderWin::~WindowFinderWin() = default;
WindowId WindowFinderWin::GetWindowUnderPoint(DesktopVector point) {
HWND window = WindowFromPoint(POINT { point.x(), point.y() });
HWND window = WindowFromPoint(POINT{point.x(), point.y()});
if (!window) {
return kNullWindowId;
}

View File

@ -16,8 +16,7 @@
namespace webrtc {
WindowFinderX11::WindowFinderX11(XAtomCache* cache)
: cache_(cache) {
WindowFinderX11::WindowFinderX11(XAtomCache* cache) : cache_(cache) {
RTC_DCHECK(cache_);
}
@ -25,16 +24,15 @@ WindowFinderX11::~WindowFinderX11() = default;
WindowId WindowFinderX11::GetWindowUnderPoint(DesktopVector point) {
WindowId id = kNullWindowId;
GetWindowList(cache_,
[&id, this, point](::Window window) {
DesktopRect rect;
if (GetWindowRect(this->cache_->display(), window, &rect) &&
rect.Contains(point)) {
id = window;
return false;
}
return true;
});
GetWindowList(cache_, [&id, this, point](::Window window) {
DesktopRect rect;
if (GetWindowRect(this->cache_->display(), window, &rect) &&
rect.Contains(point)) {
id = window;
return false;
}
return true;
});
return id;
}

View File

@ -19,8 +19,7 @@
namespace webrtc {
SharedXDisplay::SharedXDisplay(Display* display)
: display_(display) {
SharedXDisplay::SharedXDisplay(Display* display) : display_(display) {
RTC_DCHECK(display_);
}

View File

@ -10,10 +10,10 @@
#include "modules/desktop_capture/x11/window_list_utils.h"
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <string.h>
#include <algorithm>
@ -49,10 +49,9 @@ class XWindowProperty {
Atom actual_type;
int actual_format;
unsigned long bytes_after; // NOLINT: type required by XGetWindowProperty
int status = XGetWindowProperty(display, window, property, 0L, ~0L, False,
AnyPropertyType, &actual_type,
&actual_format, &size_,
&bytes_after, &data_);
int status = XGetWindowProperty(
display, window, property, 0L, ~0L, False, AnyPropertyType,
&actual_type, &actual_format, &size_, &bytes_after, &data_);
if (status != Success) {
data_ = nullptr;
return;
@ -78,9 +77,7 @@ class XWindowProperty {
const PropertyType* data() const {
return reinterpret_cast<PropertyType*>(data_);
}
PropertyType* data() {
return reinterpret_cast<PropertyType*>(data_);
}
PropertyType* data() { return reinterpret_cast<PropertyType*>(data_); }
private:
bool is_valid_ = false;
@ -106,7 +103,7 @@ class XWindowProperty {
RTC_DCHECK_EQ(state, WithdrawnState);
// If the window is in WithdrawnState then look at all of its children.
::Window root, parent;
::Window *children;
::Window* children;
unsigned int num_children;
if (!XQueryTree(cache->display(), window, &root, &parent, &children,
&num_children)) {
@ -137,14 +134,12 @@ bool IsDesktopElement(XAtomCache* cache, ::Window window) {
// says this hint *should* be present on all windows, and we use the existence
// of _NET_WM_WINDOW_TYPE_NORMAL in the property to indicate a window is not
// a desktop element (that is, only "normal" windows should be shareable).
XWindowProperty<uint32_t> window_type(
cache->display(), window, cache->WindowType());
XWindowProperty<uint32_t> window_type(cache->display(), window,
cache->WindowType());
if (window_type.is_valid() && window_type.size() > 0) {
uint32_t* end = window_type.data() + window_type.size();
bool is_normal = (end != std::find(
window_type.data(),
end,
cache->WindowTypeNormal()));
bool is_normal =
(end != std::find(window_type.data(), end, cache->WindowTypeNormal()));
return !is_normal;
}
@ -166,8 +161,8 @@ bool IsDesktopElement(XAtomCache* cache, ::Window window) {
int32_t GetWindowState(XAtomCache* cache, ::Window window) {
// Get WM_STATE property of the window.
XWindowProperty<uint32_t> window_state(
cache->display(), window, cache->WmState());
XWindowProperty<uint32_t> window_state(cache->display(), window,
cache->WmState());
// WM_STATE is considered to be set to WithdrawnState when it missing.
return window_state.is_valid() ? *window_state.data() : WithdrawnState;
@ -188,11 +183,7 @@ bool GetWindowList(XAtomCache* cache,
unsigned int num_children;
{
XErrorTrap error_trap(display);
if (XQueryTree(display,
root_window,
&root_window,
&parent,
&children,
if (XQueryTree(display, root_window, &root_window, &parent, &children,
&num_children) == 0 ||
error_trap.GetLastErrorAndDisable() != 0) {
failed_screens++;
@ -242,14 +233,8 @@ bool GetWindowRect(::Display* display,
{
XErrorTrap error_trap(display);
::Window child;
if (!XTranslateCoordinates(display,
window,
attributes->root,
-rect->left(),
-rect->top(),
&offset_x,
&offset_y,
&child) ||
if (!XTranslateCoordinates(display, window, attributes->root, -rect->left(),
-rect->top(), &offset_x, &offset_y, &child) ||
error_trap.GetLastErrorAndDisable() != 0) {
return false;
}

View File

@ -45,9 +45,7 @@ bool GetWindowRect(::Display* display,
// Creates a DesktopRect from |attributes|.
template <typename T>
DesktopRect DesktopRectFromXAttributes(const T& attributes) {
return DesktopRect::MakeXYWH(attributes.x,
attributes.y,
attributes.width,
return DesktopRect::MakeXYWH(attributes.x, attributes.y, attributes.width,
attributes.height);
}

View File

@ -11,8 +11,8 @@
#ifndef MODULES_DESKTOP_CAPTURE_X11_X_ATOM_CACHE_H_
#define MODULES_DESKTOP_CAPTURE_X11_X_ATOM_CACHE_H_
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
namespace webrtc {

View File

@ -37,11 +37,10 @@ int XServerErrorHandler(Display* display, XErrorEvent* error_event) {
} // namespace
XErrorTrap::XErrorTrap(Display* display)
: original_error_handler_(NULL),
enabled_(true) {
: original_error_handler_(NULL), enabled_(true) {
#if defined(TOOLKIT_GTK)
gdk_error_trap_push();
#else // !defined(TOOLKIT_GTK)
#else // !defined(TOOLKIT_GTK)
assert(!g_xserver_error_trap_enabled);
original_error_handler_ = XSetErrorHandler(&XServerErrorHandler);
g_xserver_error_trap_enabled = true;
@ -53,7 +52,7 @@ int XErrorTrap::GetLastErrorAndDisable() {
enabled_ = false;
#if defined(TOOLKIT_GTK)
return gdk_error_trap_push();
#else // !defined(TOOLKIT_GTK)
#else // !defined(TOOLKIT_GTK)
assert(g_xserver_error_trap_enabled);
XSetErrorHandler(original_error_handler_);
g_xserver_error_trap_enabled = false;

View File

@ -52,10 +52,8 @@ uint32_t MaskToShift(uint32_t mask) {
// Returns true if |image| is in RGB format.
bool IsXImageRGBFormat(XImage* image) {
return image->bits_per_pixel == 32 &&
image->red_mask == 0xff0000 &&
image->green_mask == 0xff00 &&
image->blue_mask == 0xff;
return image->bits_per_pixel == 32 && image->red_mask == 0xff0000 &&
image->green_mask == 0xff00 && image->blue_mask == 0xff;
}
// We expose two forms of blitting to handle variations in the pixel format.
@ -255,11 +253,9 @@ bool XServerPixelBuffer::InitPixmaps(int depth) {
{
XErrorTrap error_trap(display_);
shm_pixmap_ = XShmCreatePixmap(display_, window_,
shm_segment_info_->shmaddr,
shm_segment_info_,
window_rect_.width(),
window_rect_.height(), depth);
shm_pixmap_ = XShmCreatePixmap(
display_, window_, shm_segment_info_->shmaddr, shm_segment_info_,
window_rect_.width(), window_rect_.height(), depth);
XSync(display_, False);
if (error_trap.GetLastErrorAndDisable() != 0) {
// |shm_pixmap_| is not not valid because the request was not processed
@ -275,8 +271,7 @@ bool XServerPixelBuffer::InitPixmaps(int depth) {
shm_gc_values.subwindow_mode = IncludeInferiors;
shm_gc_values.graphics_exposures = False;
shm_gc_ = XCreateGC(display_, window_,
GCSubwindowMode | GCGraphicsExposures,
&shm_gc_values);
GCSubwindowMode | GCGraphicsExposures, &shm_gc_values);
XSync(display_, False);
if (error_trap.GetLastErrorAndDisable() != 0) {
XFreePixmap(display_, shm_pixmap_);
@ -321,9 +316,9 @@ bool XServerPixelBuffer::CaptureRect(const DesktopRect& rect,
if (shm_segment_info_ && (shm_pixmap_ || xshm_get_image_succeeded_)) {
if (shm_pixmap_) {
XCopyArea(display_, window_, shm_pixmap_, shm_gc_,
rect.left(), rect.top(), rect.width(), rect.height(),
rect.left(), rect.top());
XCopyArea(display_, window_, shm_pixmap_, shm_gc_, rect.left(),
rect.top(), rect.width(), rect.height(), rect.left(),
rect.top());
XSync(display_, False);
}