| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "remoting/host/differ.h" | 6 #include "remoting/host/differ.h" |
| 7 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "testing/gmock/include/gmock/gmock.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 void ClearBuffer(uint8* buffer) { | 43 void ClearBuffer(uint8* buffer) { |
| 44 memset(buffer, 0, buffer_size_); | 44 memset(buffer, 0, buffer_size_); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Convenience wrapper for Differ's DiffBlock that calculates the appropriate | 47 // Convenience wrapper for Differ's DiffBlock that calculates the appropriate |
| 48 // offset to the start of the desired block. | 48 // offset to the start of the desired block. |
| 49 DiffInfo DiffBlock(int block_x, int block_y) { | 49 DiffInfo DiffBlock(int block_x, int block_y) { |
| 50 // Offset from upper-left of buffer to upper-left of requested block. | 50 // Offset from upper-left of buffer to upper-left of requested block. |
| 51 int block_offset = ((block_y * stride_) + (block_x * bytes_per_pixel_)) | 51 int block_offset = ((block_y * stride_) + (block_x * bytes_per_pixel_)) |
| 52 * kBlockSize; | 52 * kBlockSize; |
| 53 differ_->DiffBlock(prev_.get() + block_offset, | 53 return differ_->DiffBlock(prev_.get() + block_offset, |
| 54 curr_.get() + block_offset, | 54 curr_.get() + block_offset, |
| 55 stride_); | 55 stride_); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Write the pixel |value| into the specified block in the |buffer|. | 58 // Write the pixel |value| into the specified block in the |buffer|. |
| 59 // This is a convenience wrapper around WritePixel(). | 59 // This is a convenience wrapper around WritePixel(). |
| 60 void WriteBlockPixel(uint8* buffer, int block_x, int block_y, | 60 void WriteBlockPixel(uint8* buffer, int block_x, int block_y, |
| 61 int pixel_x, int pixel_y, uint32 value) { | 61 int pixel_x, int pixel_y, uint32 value) { |
| 62 WritePixel(buffer, (block_x * kBlockSize) + pixel_x, | 62 WritePixel(buffer, (block_x * kBlockSize) + pixel_x, |
| 63 (block_y * kBlockSize) + pixel_y, value); | 63 (block_y * kBlockSize) + pixel_y, value); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 521 |
| 522 dirty = new DirtyRects(); | 522 dirty = new DirtyRects(); |
| 523 differ_->MergeBlocks(dirty); | 523 differ_->MergeBlocks(dirty); |
| 524 | 524 |
| 525 ASSERT_EQ(2, dirty->size()); | 525 ASSERT_EQ(2, dirty->size()); |
| 526 CheckDirtyRect(dirty->at(0), 0, 0, 2, 2); | 526 CheckDirtyRect(dirty->at(0), 0, 0, 2, 2); |
| 527 CheckDirtyRect(dirty->at(1), 1, 2, 1, 1); | 527 CheckDirtyRect(dirty->at(1), 1, 2, 1, 1); |
| 528 } | 528 } |
| 529 | 529 |
| 530 } // namespace remoting | 530 } // namespace remoting |
| OLD | NEW |