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

Side by Side Diff: webrtc/modules/desktop_capture/differ.h

Issue 2202443002: [WebRTC] Add ScreenCapturerDifferWrapper to share Differ across ScreenCapturers (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DIFFER_H_ 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DIFFER_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DIFFER_H_ 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DIFFER_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/constructormagic.h" 17 #include "webrtc/base/constructormagic.h"
18 #include "webrtc/modules/desktop_capture/desktop_region.h" 18 #include "webrtc/typedefs.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 class DesktopRect;
23 class DesktopRegion;
24
22 // TODO(sergeyu): Simplify differ now that we are working with DesktopRegion. 25 // TODO(sergeyu): Simplify differ now that we are working with DesktopRegion.
23 // diff_info_ should no longer be needed, as we can put our data directly into 26 // diff_info_ should no longer be needed, as we can put our data directly into
24 // the region that we are calculating. 27 // the region that we are calculating.
25 // http://crbug.com/92379 28 // http://crbug.com/92379
26 // TODO(sergeyu): Rename this class to something more sensible, e.g. 29 // TODO(sergeyu): Rename this class to something more sensible, e.g.
27 // ScreenCaptureFrameDifferencer. 30 // ScreenCaptureFrameDifferencer.
28 class Differ { 31 class Differ {
Sergey Ulanov 2016/08/03 23:19:11 I would prefer cleaning up this code before extend
Hzj_jie 2016/08/04 02:28:07 I am happy with the change. But it seems like a ve
Sergey Ulanov 2016/08/08 18:42:42 Note that ScreenCapturerMac doesn't use Differ. H
29 public: 32 public:
30 // Create a differ that operates on bitmaps with the specified width, height 33 // Create a differ that operates on bitmaps with the specified width, height
31 // and bytes_per_pixel. 34 // and bytes_per_pixel.
32 Differ(int width, int height, int bytes_per_pixel, int stride); 35 Differ(int width, int height, int bytes_per_pixel, int stride);
33 ~Differ(); 36 ~Differ();
34 37
35 int width() { return width_; } 38 int width() { return width_; }
36 int height() { return height_; } 39 int height() { return height_; }
37 int bytes_per_pixel() { return bytes_per_pixel_; } 40 int bytes_per_pixel() { return bytes_per_pixel_; }
38 int bytes_per_row() { return bytes_per_row_; } 41 int bytes_per_row() { return bytes_per_row_; }
39 42
40 // Given the previous and current screen buffer, calculate the dirty region 43 // Given the previous and current screen buffer, calculates the dirty region
Jamie 2016/08/03 23:52:25 FWIW, either calculate or calculates would be appr
Hzj_jie 2016/08/04 02:28:07 Done.
41 // that encloses all of the changed pixels in the new screen. 44 // that encloses all of the changed pixels in the new screen.
42 void CalcDirtyRegion(const uint8_t* prev_buffer, const uint8_t* curr_buffer, 45 void CalcDirtyRegion(const uint8_t* prev_buffer,
46 const uint8_t* curr_buffer,
43 DesktopRegion* region); 47 DesktopRegion* region);
44 48
49 // Given the previous and current screen buffer, and a superset of dirty
50 // region as hint, calculates the dirty region that encloses all the changed
51 // pixels in the new screen.
52 void CalcDirtyRegionWithHints(const uint8_t* prev_buffer,
53 const uint8_t* curr_buffer,
54 const DesktopRegion& hints,
55 DesktopRegion* region);
56
45 private: 57 private:
46 // Allow tests to access our private parts. 58 // Allow tests to access our private parts.
47 friend class DifferTest; 59 friend class DifferTest;
48 60
49 // Identify all of the blocks that contain changed pixels. 61 // Identify all of the blocks that contain changed pixels in the |rect|.
50 void MarkDirtyBlocks(const uint8_t* prev_buffer, const uint8_t* curr_buffer); 62 void MarkDirtyBlocks(const uint8_t* prev_buffer,
63 const uint8_t* curr_buffer,
64 const DesktopRect& rect);
51 65
52 // After the dirty blocks have been identified, this routine merges adjacent 66 // After the dirty blocks have been identified, this routine merges adjacent
53 // blocks into a region. 67 // blocks into a region.
54 // The goal is to minimize the region that covers the dirty blocks. 68 // The goal is to minimize the region that covers the dirty blocks.
55 void MergeBlocks(DesktopRegion* region); 69 void MergeBlocks(DesktopRegion* region) const;
Jamie 2016/08/03 23:52:25 Optional: I'm not sure it's worth adding these con
Hzj_jie 2016/08/04 02:28:07 IMO, a const indeed tells the reader, this functio
56 70
57 // Checks whether the upper-left portions of the buffers are equal. The size 71 // Checks whether the upper-left portions of the buffers are equal. The size
58 // of the portion to check is specified by the |width| and |height| values. 72 // of the portion to check is specified by the |width| and |height| values.
59 // Note that if we force the capturer to always return images whose width and 73 // Note that if we force the capturer to always return images whose width and
60 // height are multiples of kBlockSize, then this will never be called. 74 // height are multiples of kBlockSize, then this will never be called.
61 bool PartialBlocksEqual(const uint8_t* prev_buffer, 75 bool PartialBlocksEqual(const uint8_t* prev_buffer,
62 const uint8_t* curr_buffer, 76 const uint8_t* curr_buffer,
63 int stride, 77 int stride,
64 int width, int height); 78 int width, int height);
65 79
66 // Dimensions of screen. 80 // Dimensions of screen.
67 int width_; 81 const int width_;
68 int height_; 82 const int height_;
69 83
70 // Number of bytes for each pixel in source and dest bitmap. 84 // Number of bytes for each pixel in source and dest bitmap.
71 // (Yes, they must match.) 85 // (Yes, they must match.)
72 int bytes_per_pixel_; 86 const int bytes_per_pixel_;
73 87
74 // Number of bytes in each row of the image (AKA: stride). 88 // Number of bytes in each row of the image (AKA: stride).
75 int bytes_per_row_; 89 const int bytes_per_row_;
90
91 // Dimensions and total size of diff info array.
92 const int diff_info_width_;
93 const int diff_info_height_;
94 const int diff_info_size_;
76 95
77 // Diff information for each block in the image. 96 // Diff information for each block in the image.
78 std::unique_ptr<bool[]> diff_info_; 97 const std::unique_ptr<bool[]> diff_info_;
79
80 // Dimensions and total size of diff info array.
81 int diff_info_width_;
82 int diff_info_height_;
83 int diff_info_size_;
84 98
85 RTC_DISALLOW_COPY_AND_ASSIGN(Differ); 99 RTC_DISALLOW_COPY_AND_ASSIGN(Differ);
86 }; 100 };
87 101
88 } // namespace webrtc 102 } // namespace webrtc
89 103
90 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DIFFER_H_ 104 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DIFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698