Skip to content

Commit 7aea6af

Browse files
zijieheCommit bot
zijiehe
authored and
Commit bot
committed
Revert of Allow Windows to return a monitor out of the first quadrant (patchset #2 id:60001 of https://codereview.chromium.org/2848443004/ )
Reason for revert: TranslateRect() is placed in a wrong position. Original issue's description: > Allow Windows to return a monitor out of the first quadrant > > Windows may return a DesktopCoordinate out of the first quadrant > (x >= 0 && y >= 0), this typically happens when the primary and secondary > monitors are swapped. i.e. The secondary monitor is on the left but the primary > one is on the right. > This change "moves" the entire screen from any quadrant to the (0, 0), so we can > capture the monitors in other quadrants. > > BUG=chromium:715689 > > Review-Url: https://codereview.webrtc.org/2848443004 > Cr-Commit-Position: refs/heads/master@{#17935} > Committed: https://chromium.googlesource.com/external/webrtc/+/049ec71e657eef3d15e0f15d60acb1a71e81b521 [email protected] # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chromium:715689 Review-Url: https://codereview.webrtc.org/2852783002 Cr-Commit-Position: refs/heads/master@{#17936}
1 parent 049ec71 commit 7aea6af

6 files changed

+8
-41
lines changed

webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ using Microsoft::WRL::ComPtr;
2525
namespace {
2626

2727
bool IsValidRect(const RECT& rect) {
28-
return rect.right > rect.left && rect.bottom > rect.top;
28+
return rect.left >= 0 && rect.top >= 0 && rect.right > rect.left &&
29+
rect.bottom > rect.top;
2930
}
3031

3132
} // namespace
@@ -152,12 +153,4 @@ int64_t DxgiAdapterDuplicator::GetNumFramesCaptured() const {
152153
return min;
153154
}
154155

155-
void DxgiAdapterDuplicator::TranslateRect(const DesktopVector& position) {
156-
desktop_rect_.Translate(position);
157-
RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0);
158-
for (auto& duplicator : duplicators_) {
159-
duplicator.TranslateRect(position);
160-
}
161-
}
162-
163156
} // namespace webrtc

webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ class DxgiAdapterDuplicator {
7171
// The minimum num_frames_captured() returned by |duplicators_|.
7272
int64_t GetNumFramesCaptured() const;
7373

74-
// Moves |desktop_rect_| and all underlying |duplicators_|. See
75-
// DxgiDuplicatorController::TranslateRect().
76-
void TranslateRect(const DesktopVector& position);
77-
7874
private:
7975
bool DoInitialize();
8076

webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.cc

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ bool DxgiDuplicatorController::DoInitialize() {
193193
std::max(left.right(), right.right()),
194194
std::max(left.bottom(), right.bottom()));
195195
}
196-
TranslateRect();
197196
}
198197

199198
HDC hdc = GetDC(nullptr);
@@ -296,7 +295,7 @@ int64_t DxgiDuplicatorController::GetNumFramesCaptured() const {
296295
}
297296

298297
DesktopSize DxgiDuplicatorController::desktop_size() const {
299-
return desktop_rect_.size();
298+
return DesktopSize(desktop_rect_.right(), desktop_rect_.bottom());
300299
}
301300

302301
DesktopRect DxgiDuplicatorController::ScreenRect(int id) const {
@@ -379,13 +378,4 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context,
379378
return true;
380379
}
381380

382-
void DxgiDuplicatorController::TranslateRect() {
383-
const DesktopVector position =
384-
DesktopVector().subtract(desktop_rect_.top_left());
385-
desktop_rect_.Translate(position);
386-
for (auto& duplicator : duplicators_) {
387-
duplicator.TranslateRect(position);
388-
}
389-
}
390-
391381
} // namespace webrtc

webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ class DxgiDuplicatorController {
158158
// The minimum GetNumFramesCaptured() returned by |duplicators_|.
159159
int64_t GetNumFramesCaptured() const;
160160

161-
// Returns a DesktopSize to cover entire |desktop_rect_|.
161+
// Returns a DesktopSize to cover entire desktop_rect. This may be different
162+
// than desktop_rect().size(), since top-left of the screen does not need to
163+
// be started from (0, 0).
162164
DesktopSize desktop_size() const;
163165

164166
// Returns the size of one screen. |id| should be >= 0. If system does not
@@ -179,12 +181,6 @@ class DxgiDuplicatorController {
179181
// during first several capture attempts.
180182
bool EnsureFrameCaptured(Context* context, SharedDesktopFrame* target);
181183

182-
// Moves |desktop_rect_| and all underlying |duplicators_|, putting top left
183-
// corner of the desktop at (0, 0). This is necessary because DXGI_OUTPUT_DESC
184-
// may return negative coordinates. Called from DoInitialize() after all
185-
// DxgiAdapterDuplicator and DxgiOutputDuplicator instances are initialized.
186-
void TranslateRect();
187-
188184
// This lock must be locked whenever accessing any of the following objects.
189185
rtc::CriticalSection lock_;
190186

webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ DxgiOutputDuplicator::DxgiOutputDuplicator(const D3dDevice& device,
6767
desktop_rect_(RECTToDesktopRect(desc.DesktopCoordinates)) {
6868
RTC_DCHECK(output_);
6969
RTC_DCHECK(!desktop_rect_.is_empty());
70-
RTC_DCHECK(desktop_rect_.width() > 0 && desktop_rect_.height() > 0);
70+
RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0);
7171
}
7272

7373
DxgiOutputDuplicator::DxgiOutputDuplicator(DxgiOutputDuplicator&& other) =
@@ -381,9 +381,4 @@ int64_t DxgiOutputDuplicator::num_frames_captured() const {
381381
return num_frames_captured_;
382382
}
383383

384-
void DxgiOutputDuplicator::TranslateRect(const DesktopVector& position) {
385-
desktop_rect_.Translate(position);
386-
RTC_DCHECK(desktop_rect_.left() >= 0 && desktop_rect_.top() >= 0);
387-
}
388-
389384
} // namespace webrtc

webrtc/modules/desktop_capture/win/dxgi_output_duplicator.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ class DxgiOutputDuplicator {
7575
// How many frames have been captured by this DxigOutputDuplicator.
7676
int64_t num_frames_captured() const;
7777

78-
// Moves |desktop_rect_|. See DxgiDuplicatorController::TranslateRect().
79-
void TranslateRect(const DesktopVector& position);
80-
8178
private:
8279
// Calls DoDetectUpdatedRegion(). If it fails, this function sets the
8380
// |updated_region| as entire UntranslatedDesktopRect().
@@ -112,7 +109,7 @@ class DxgiOutputDuplicator {
112109

113110
const D3dDevice device_;
114111
const Microsoft::WRL::ComPtr<IDXGIOutput1> output_;
115-
DesktopRect desktop_rect_;
112+
const DesktopRect desktop_rect_;
116113
Microsoft::WRL::ComPtr<IDXGIOutputDuplication> duplication_;
117114
DXGI_OUTDUPL_DESC desc_;
118115
std::vector<uint8_t> metadata_;

0 commit comments

Comments
 (0)