Chromium Code Reviews| Index: webrtc/modules/desktop_capture/differ.h |
| diff --git a/webrtc/modules/desktop_capture/differ.h b/webrtc/modules/desktop_capture/differ.h |
| index 9ab059bcaa24cdb8491b86791e954423dcd95cc6..dca38676fe831ba5a64445d685ef76ebbb8a9a9a 100644 |
| --- a/webrtc/modules/desktop_capture/differ.h |
| +++ b/webrtc/modules/desktop_capture/differ.h |
| @@ -15,10 +15,13 @@ |
| #include <vector> |
| #include "webrtc/base/constructormagic.h" |
| -#include "webrtc/modules/desktop_capture/desktop_region.h" |
| +#include "webrtc/typedefs.h" |
| namespace webrtc { |
| +class DesktopRect; |
| +class DesktopRegion; |
| + |
| // TODO(sergeyu): Simplify differ now that we are working with DesktopRegion. |
| // diff_info_ should no longer be needed, as we can put our data directly into |
| // the region that we are calculating. |
| @@ -37,22 +40,33 @@ class Differ { |
| int bytes_per_pixel() { return bytes_per_pixel_; } |
| int bytes_per_row() { return bytes_per_row_; } |
| - // Given the previous and current screen buffer, calculate the dirty region |
| + // 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.
|
| // that encloses all of the changed pixels in the new screen. |
| - void CalcDirtyRegion(const uint8_t* prev_buffer, const uint8_t* curr_buffer, |
| + void CalcDirtyRegion(const uint8_t* prev_buffer, |
| + const uint8_t* curr_buffer, |
| DesktopRegion* region); |
| + // Given the previous and current screen buffer, and a superset of dirty |
| + // region as hint, calculates the dirty region that encloses all the changed |
| + // pixels in the new screen. |
| + void CalcDirtyRegionWithHints(const uint8_t* prev_buffer, |
| + const uint8_t* curr_buffer, |
| + const DesktopRegion& hints, |
| + DesktopRegion* region); |
| + |
| private: |
| // Allow tests to access our private parts. |
| friend class DifferTest; |
| - // Identify all of the blocks that contain changed pixels. |
| - void MarkDirtyBlocks(const uint8_t* prev_buffer, const uint8_t* curr_buffer); |
| + // Identify all of the blocks that contain changed pixels in the |rect|. |
| + void MarkDirtyBlocks(const uint8_t* prev_buffer, |
| + const uint8_t* curr_buffer, |
| + const DesktopRect& rect); |
| // After the dirty blocks have been identified, this routine merges adjacent |
| // blocks into a region. |
| // The goal is to minimize the region that covers the dirty blocks. |
| - void MergeBlocks(DesktopRegion* region); |
| + 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
|
| // Checks whether the upper-left portions of the buffers are equal. The size |
| // of the portion to check is specified by the |width| and |height| values. |
| @@ -64,23 +78,23 @@ class Differ { |
| int width, int height); |
| // Dimensions of screen. |
| - int width_; |
| - int height_; |
| + const int width_; |
| + const int height_; |
| // Number of bytes for each pixel in source and dest bitmap. |
| // (Yes, they must match.) |
| - int bytes_per_pixel_; |
| + const int bytes_per_pixel_; |
| // Number of bytes in each row of the image (AKA: stride). |
| - int bytes_per_row_; |
| - |
| - // Diff information for each block in the image. |
| - std::unique_ptr<bool[]> diff_info_; |
| + const int bytes_per_row_; |
| // Dimensions and total size of diff info array. |
| - int diff_info_width_; |
| - int diff_info_height_; |
| - int diff_info_size_; |
| + const int diff_info_width_; |
| + const int diff_info_height_; |
| + const int diff_info_size_; |
| + |
| + // Diff information for each block in the image. |
| + const std::unique_ptr<bool[]> diff_info_; |
| RTC_DISALLOW_COPY_AND_ASSIGN(Differ); |
| }; |