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..bd321d5e1ef46d814622c66bede6d7cb8bc83de1 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; |
- } |
- } |
- |
contexts_.push_back(context); |
Sergey Ulanov
2016/11/11 22:57:35
Maybe DCHECK here that context is not already in c
Hzj_jie
2016/11/11 23:28:23
Done.
|
} |
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(); |
+ // There is no ostream operator<< defined for std::vector::iterator, so |
+ // RTC_DCHECK_EQ will trigger build break. Refer to webrtc/base/checks.h:130. |
Sergey Ulanov
2016/11/11 22:57:35
I don't think you really need this comment, it's a
Hzj_jie
2016/11/11 23:28:23
Really, I thought it was not so common.
|
+ RTC_DCHECK(std::find(contexts_.begin(), contexts_.end(), context) != |
Sergey Ulanov
2016/11/11 22:57:35
I'd prefer to save result of std::find() and use i
Hzj_jie
2016/11/11 23:28:23
Done.
|
+ contexts_.end()); |
+ contexts_.erase(std::find(contexts_.begin(), contexts_.end(), context)); |
} |
void DxgiOutputDuplicator::SpreadContextChange(const Context* const source) { |
for (Context* dest : contexts_) { |
+ RTC_DCHECK(dest); |
if (dest != source) { |
dest->updated_region.AddRegion(source->updated_region); |
} |