OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_CAPTURER_DIFFER_H_ | |
6 #define REMOTING_CAPTURER_DIFFER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "third_party/skia/include/core/SkRegion.h" | |
13 | |
14 namespace remoting { | |
15 | |
16 typedef uint8 DiffInfo; | |
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 | |
22 // TODO(sergeyu): Rename this class to something more sensible, e.g. | |
23 // VideoFrameDifferencer. | |
24 class Differ { | |
25 public: | |
26 // Create a differ that operates on bitmaps with the specified width, height | |
27 // and bytes_per_pixel. | |
28 Differ(int width, int height, int bytes_per_pixel, int stride); | |
29 ~Differ(); | |
30 | |
31 int width() { return width_; } | |
32 int height() { return height_; } | |
33 int bytes_per_pixel() { return bytes_per_pixel_; } | |
34 int bytes_per_row() { return bytes_per_row_; } | |
35 | |
36 // Given the previous and current screen buffer, calculate the dirty region | |
37 // that encloses all of the changed pixels in the new screen. | |
38 void CalcDirtyRegion(const void* prev_buffer, const void* curr_buffer, | |
39 SkRegion* region); | |
40 | |
41 private: | |
42 // Allow tests to access our private parts. | |
43 friend class DifferTest; | |
44 | |
45 // Identify all of the blocks that contain changed pixels. | |
46 void MarkDirtyBlocks(const void* prev_buffer, const void* curr_buffer); | |
47 | |
48 // After the dirty blocks have been identified, this routine merges adjacent | |
49 // blocks into a region. | |
50 // The goal is to minimize the region that covers the dirty blocks. | |
51 void MergeBlocks(SkRegion* region); | |
52 | |
53 // Check for diffs in upper-left portion of the block. The size of the portion | |
54 // to check is specified by the |width| and |height| values. | |
55 // Note that if we force the capturer to always return images whose width and | |
56 // height are multiples of kBlockSize, then this will never be called. | |
57 DiffInfo DiffPartialBlock(const uint8* prev_buffer, const uint8* curr_buffer, | |
58 int stride, int width, int height); | |
59 | |
60 // Dimensions of screen. | |
61 int width_; | |
62 int height_; | |
63 | |
64 // Number of bytes for each pixel in source and dest bitmap. | |
65 // (Yes, they must match.) | |
66 int bytes_per_pixel_; | |
67 | |
68 // Number of bytes in each row of the image (AKA: stride). | |
69 int bytes_per_row_; | |
70 | |
71 // Diff information for each block in the image. | |
72 scoped_array<DiffInfo> diff_info_; | |
73 | |
74 // Dimensions and total size of diff info array. | |
75 int diff_info_width_; | |
76 int diff_info_height_; | |
77 int diff_info_size_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(Differ); | |
80 }; | |
81 | |
82 } // namespace remoting | |
83 | |
84 #endif // REMOTING_CAPTURER_DIFFER_H_ | |
OLD | NEW |