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

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

Issue 2494893002: Crash in DirectX capturer (Closed)
Patch Set: Resolve review comments Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
diff --git a/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc b/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
index b17c195340b0e495fa6e123a2b33c06141e9a2c5..122ad1f6e159cab692eb28394588145173f075f2 100644
--- a/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
+++ b/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc
@@ -16,6 +16,8 @@
#include <DXGIFormat.h>
#include <Windows.h>
+#include <algorithm>
+
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/modules/desktop_capture/win/dxgi_texture_mapping.h"
@@ -274,29 +276,20 @@ void DxgiOutputDuplicator::Setup(Context* context) {
RTC_DCHECK(context->updated_region.is_empty());
// Always copy entire monitor during the first Duplicate() function call.
context->updated_region.AddRect(desktop_rect_);
- for (size_t i = 0; i < contexts_.size(); i++) {
- if (contexts_[i] == nullptr) {
- contexts_[i] = context;
- return;
- }
- }
-
+ RTC_DCHECK(std::find(contexts_.begin(), contexts_.end(), context) ==
+ contexts_.end());
contexts_.push_back(context);
}
void DxgiOutputDuplicator::Unregister(const Context* const context) {
- for (size_t i = 0; i < contexts_.size(); i++) {
- if (contexts_[i] == context) {
- contexts_[i] = nullptr;
- return;
- }
- }
-
- RTC_NOTREACHED();
+ auto it = std::find(contexts_.begin(), contexts_.end(), context);
+ RTC_DCHECK(it != contexts_.end());
+ contexts_.erase(it);
}
void DxgiOutputDuplicator::SpreadContextChange(const Context* const source) {
for (Context* dest : contexts_) {
+ RTC_DCHECK(dest);
if (dest != source) {
dest->updated_region.AddRegion(source->updated_region);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698