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

Side by Side Diff: webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc

Issue 2348803003: Remove differ from ScreenCapturer implementations (Closed)
Patch Set: Comment on the XDamage scenario in screen_capturer_x11.cc Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h" 11 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h"
12 12
13 #include <utility> 13 #include <utility>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/timeutils.h" 16 #include "webrtc/base/timeutils.h"
17 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 17 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
18 #include "webrtc/modules/desktop_capture/desktop_frame.h" 18 #include "webrtc/modules/desktop_capture/desktop_frame.h"
19 #include "webrtc/modules/desktop_capture/desktop_frame_win.h" 19 #include "webrtc/modules/desktop_capture/desktop_frame_win.h"
20 #include "webrtc/modules/desktop_capture/desktop_region.h" 20 #include "webrtc/modules/desktop_capture/desktop_region.h"
21 #include "webrtc/modules/desktop_capture/differ.h"
22 #include "webrtc/modules/desktop_capture/mouse_cursor.h" 21 #include "webrtc/modules/desktop_capture/mouse_cursor.h"
23 #include "webrtc/modules/desktop_capture/win/cursor.h" 22 #include "webrtc/modules/desktop_capture/win/cursor.h"
24 #include "webrtc/modules/desktop_capture/win/desktop.h" 23 #include "webrtc/modules/desktop_capture/win/desktop.h"
25 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h" 24 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h"
26 #include "webrtc/system_wrappers/include/logging.h" 25 #include "webrtc/system_wrappers/include/logging.h"
27 26
28 namespace webrtc { 27 namespace webrtc {
29 28
30 // kMagnifierWindowClass has to be "Magnifier" according to the Magnification 29 // kMagnifierWindowClass has to be "Magnifier" according to the Magnification
31 // API. The other strings can be anything. 30 // API. The other strings can be anything.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // CaptureImage may fail in some situations, e.g. windows8 metro mode. So 108 // CaptureImage may fail in some situations, e.g. windows8 metro mode. So
110 // defer to the fallback capturer if magnifier capturer did not work. 109 // defer to the fallback capturer if magnifier capturer did not work.
111 if (!CaptureImage(rect)) { 110 if (!CaptureImage(rect)) {
112 LOG_F(LS_WARNING) << "Switching to the fallback screen capturer because " 111 LOG_F(LS_WARNING) << "Switching to the fallback screen capturer because "
113 "last capture attempt failed."; 112 "last capture attempt failed.";
114 StartFallbackCapturer(); 113 StartFallbackCapturer();
115 fallback_capturer_->Capture(region); 114 fallback_capturer_->Capture(region);
116 return; 115 return;
117 } 116 }
118 117
119 const DesktopFrame* current_frame = queue_.current_frame();
120 const DesktopFrame* last_frame = queue_.previous_frame();
121 DesktopRegion updated_region;
122 if (last_frame && last_frame->size().equals(current_frame->size())) {
123 // Make sure the differencer is set up correctly for these previous and
124 // current screens.
125 if (!differ_.get() || (differ_->width() != current_frame->size().width()) ||
126 (differ_->height() != current_frame->size().height()) ||
127 (differ_->bytes_per_row() != current_frame->stride())) {
128 differ_.reset(new Differ(current_frame->size().width(),
129 current_frame->size().height(),
130 DesktopFrame::kBytesPerPixel,
131 current_frame->stride()));
132 }
133
134 // Calculate difference between the two last captured frames.
135 differ_->CalcDirtyRegion(
136 last_frame->data(), current_frame->data(), &updated_region);
137 } else {
138 updated_region.SetRect(DesktopRect::MakeSize(current_frame->size()));
139 }
140
141 // Emit the current frame. 118 // Emit the current frame.
142 std::unique_ptr<DesktopFrame> frame = queue_.current_frame()->Share(); 119 std::unique_ptr<DesktopFrame> frame = queue_.current_frame()->Share();
143 frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX), 120 frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX),
144 GetDeviceCaps(desktop_dc_, LOGPIXELSY))); 121 GetDeviceCaps(desktop_dc_, LOGPIXELSY)));
145 frame->mutable_updated_region()->Swap(&updated_region); 122 frame->mutable_updated_region()->SetRect(
123 DesktopRect::MakeSize(frame->size()));
146 frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / 124 frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) /
147 rtc::kNumNanosecsPerMillisec); 125 rtc::kNumNanosecsPerMillisec);
148 callback_->OnCaptureResult(Result::SUCCESS, std::move(frame)); 126 callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
149 } 127 }
150 128
151 bool ScreenCapturerWinMagnifier::GetScreenList(ScreenList* screens) { 129 bool ScreenCapturerWinMagnifier::GetScreenList(ScreenList* screens) {
152 return webrtc::GetScreenList(screens); 130 return webrtc::GetScreenList(screens);
153 } 131 }
154 132
155 bool ScreenCapturerWinMagnifier::SelectScreen(ScreenId id) { 133 bool ScreenCapturerWinMagnifier::SelectScreen(ScreenId id) {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 RTC_DCHECK(fallback_capturer_); 380 RTC_DCHECK(fallback_capturer_);
403 if (!fallback_capturer_started_) { 381 if (!fallback_capturer_started_) {
404 fallback_capturer_started_ = true; 382 fallback_capturer_started_ = true;
405 383
406 fallback_capturer_->Start(callback_); 384 fallback_capturer_->Start(callback_);
407 fallback_capturer_->SelectScreen(current_screen_id_); 385 fallback_capturer_->SelectScreen(current_screen_id_);
408 } 386 }
409 } 387 }
410 388
411 } // namespace webrtc 389 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698