OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_HOST_DIFFER_H_ | 5 #ifndef REMOTING_HOST_DIFFER_H_ |
6 #define REMOTING_HOST_DIFFER_H_ | 6 #define REMOTING_HOST_DIFFER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "remoting/base/types.h" | 12 #include "third_party/skia/include/core/SkRegion.h" |
13 #include "ui/gfx/rect.h" | |
14 | 13 |
15 namespace remoting { | 14 namespace remoting { |
16 | 15 |
17 typedef uint8 DiffInfo; | 16 typedef uint8 DiffInfo; |
18 | 17 |
| 18 // TODO: Simplify differ now that we are working with SkRegions. |
| 19 // diff_info_ should no longer be needed, as we can put our data directly into |
| 20 // the region that we are calculating. |
| 21 // http://crbug.com/92379 |
19 class Differ { | 22 class Differ { |
20 public: | 23 public: |
21 // Create a differ that operates on bitmaps with the specified width, height | 24 // Create a differ that operates on bitmaps with the specified width, height |
22 // and bytes_per_pixel. | 25 // and bytes_per_pixel. |
23 Differ(int width, int height, int bytes_per_pixel, int stride); | 26 Differ(int width, int height, int bytes_per_pixel, int stride); |
24 ~Differ(); | 27 ~Differ(); |
25 | 28 |
26 int width() { return width_; } | 29 int width() { return width_; } |
27 int height() { return height_; } | 30 int height() { return height_; } |
28 int bytes_per_pixel() { return bytes_per_pixel_; } | 31 int bytes_per_pixel() { return bytes_per_pixel_; } |
29 int bytes_per_row() { return bytes_per_row_; } | 32 int bytes_per_row() { return bytes_per_row_; } |
30 | 33 |
31 // Given the previous and current screen buffer, calculate the set of | 34 // Given the previous and current screen buffer, calculate the dirty region |
32 // rectangles that enclose all the changed pixels in the new screen. | 35 // that encloses all of the changed pixels in the new screen. |
33 void CalcDirtyRects(const void* prev_buffer, const void* curr_buffer, | 36 void CalcDirtyRegion(const void* prev_buffer, const void* curr_buffer, |
34 InvalidRects* rects); | 37 SkRegion* region); |
| 38 |
| 39 private: |
| 40 // Allow tests to access our private parts. |
| 41 friend class DifferTest; |
35 | 42 |
36 // Identify all of the blocks that contain changed pixels. | 43 // Identify all of the blocks that contain changed pixels. |
37 void MarkDirtyBlocks(const void* prev_buffer, const void* curr_buffer); | 44 void MarkDirtyBlocks(const void* prev_buffer, const void* curr_buffer); |
38 | 45 |
39 // After the dirty blocks have been identified, this routine merges adjacent | 46 // After the dirty blocks have been identified, this routine merges adjacent |
40 // blocks into larger rectangular units. | 47 // blocks into a region. |
41 // The goal is to minimize the number of rects that cover the dirty blocks, | 48 // The goal is to minimize the region that covers the dirty blocks. |
42 // although it is not required to calc the absolute minimum of rects. | 49 void MergeBlocks(SkRegion* region); |
43 void MergeBlocks(InvalidRects* rects); | |
44 | |
45 // Allow tests to access our private parts. | |
46 friend class DifferTest; | |
47 | |
48 private: | |
49 | 50 |
50 // Check for diffs in upper-left portion of the block. The size of the portion | 51 // Check for diffs in upper-left portion of the block. The size of the portion |
51 // to check is specified by the |width| and |height| values. | 52 // to check is specified by the |width| and |height| values. |
52 // Note that if we force the capturer to always return images whose width and | 53 // Note that if we force the capturer to always return images whose width and |
53 // height are multiples of kBlockSize, then this will never be called. | 54 // height are multiples of kBlockSize, then this will never be called. |
54 DiffInfo DiffPartialBlock(const uint8* prev_buffer, const uint8* curr_buffer, | 55 DiffInfo DiffPartialBlock(const uint8* prev_buffer, const uint8* curr_buffer, |
55 int stride, int width, int height); | 56 int stride, int width, int height); |
56 | 57 |
57 // Dimensions of screen. | 58 // Dimensions of screen. |
58 int width_; | 59 int width_; |
(...skipping 13 matching lines...) Expand all Loading... |
72 int diff_info_width_; | 73 int diff_info_width_; |
73 int diff_info_height_; | 74 int diff_info_height_; |
74 int diff_info_size_; | 75 int diff_info_size_; |
75 | 76 |
76 DISALLOW_COPY_AND_ASSIGN(Differ); | 77 DISALLOW_COPY_AND_ASSIGN(Differ); |
77 }; | 78 }; |
78 | 79 |
79 } // namespace remoting | 80 } // namespace remoting |
80 | 81 |
81 #endif // REMOTING_HOST_DIFFER_H_ | 82 #endif // REMOTING_HOST_DIFFER_H_ |
OLD | NEW |