Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc

Issue 2933893003: Add reference counter of DxgiDuplicatorController to unload DXGI components (Closed)
Patch Set: unique_ptr -> scoped_refptr Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc
diff --git a/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc b/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc
index 9630265c63e8720ee3089b9fccb9f1b873aa05e8..55f1c87e95b3a05e2540a9ae6e70840de97a37a0 100644
--- a/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc
+++ b/webrtc/modules/desktop_capture/win/screen_capturer_win_directx.cc
@@ -36,11 +36,18 @@ bool ScreenCapturerWinDirectx::RetrieveD3dInfo(D3dInfo* info) {
return DxgiDuplicatorController::Instance()->RetrieveD3dInfo(info);
}
-ScreenCapturerWinDirectx::ScreenCapturerWinDirectx(
- const DesktopCaptureOptions& options)
- : callback_(nullptr) {}
+ScreenCapturerWinDirectx::ScreenCapturerWinDirectx()
+ : controller_(DxgiDuplicatorController::GetReference()) {}
-ScreenCapturerWinDirectx::~ScreenCapturerWinDirectx() {}
+ScreenCapturerWinDirectx::~ScreenCapturerWinDirectx() = default;
+
+bool ScreenCapturerWinDirectx::IsAvailable() const {
+ return controller_->IsSupported();
+}
+
+bool ScreenCapturerWinDirectx::GetD3dInfo(D3dInfo* info) const {
+ return controller_->RetrieveD3dInfo(info);
+}
void ScreenCapturerWinDirectx::Start(Callback* callback) {
RTC_DCHECK(!callback_);
@@ -67,10 +74,9 @@ void ScreenCapturerWinDirectx::CaptureFrame() {
DxgiDuplicatorController::Result result;
if (current_screen_id_ == kFullDesktopScreenId) {
- result = DxgiDuplicatorController::Instance()->Duplicate(
- frames_.current_frame());
+ result = controller_->Duplicate(frames_.current_frame());
} else {
- result = DxgiDuplicatorController::Instance()->DuplicateMonitor(
+ result = controller_->DuplicateMonitor(
frames_.current_frame(), current_screen_id_);
}
@@ -106,7 +112,7 @@ void ScreenCapturerWinDirectx::CaptureFrame() {
}
bool ScreenCapturerWinDirectx::GetSourceList(SourceList* sources) {
- int screen_count = DxgiDuplicatorController::Instance()->ScreenCount();
+ int screen_count = controller_->ScreenCount();
for (int i = 0; i < screen_count; i++) {
sources->push_back({i});
}
@@ -123,7 +129,7 @@ bool ScreenCapturerWinDirectx::SelectSource(SourceId id) {
return true;
}
- int screen_count = DxgiDuplicatorController::Instance()->ScreenCount();
+ int screen_count = controller_->ScreenCount();
if (id >= 0 && id < screen_count) {
current_screen_id_ = id;
return true;

Powered by Google App Engine
This is Rietveld 408576698