| 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 "remoting/host/differ_block.h" |
| 7 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 8 | 9 |
| 9 namespace remoting { | 10 namespace remoting { |
| 10 | 11 |
| 11 // 96x96 screen gives a 3x3 grid of blocks. | 12 // 96x96 screen gives a 4x4 grid of blocks. |
| 12 const int kScreenWidth= 96; | 13 const int kScreenWidth= 96; |
| 13 const int kScreenHeight = 96; | 14 const int kScreenHeight = 96; |
| 14 const int kBytesPerPixel = 3; | |
| 15 const int kBytesPerRow = (kBytesPerPixel * kScreenWidth); | 15 const int kBytesPerRow = (kBytesPerPixel * kScreenWidth); |
| 16 | 16 |
| 17 class DifferTest : public testing::Test { | 17 class DifferTest : public testing::Test { |
| 18 public: | 18 public: |
| 19 DifferTest() { | 19 DifferTest() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 protected: | 22 protected: |
| 23 virtual void SetUp() { | 23 virtual void SetUp() { |
| 24 InitDiffer(kScreenWidth, kScreenHeight, kBytesPerPixel, kBytesPerRow); | 24 InitDiffer(kScreenWidth, kScreenHeight, kBytesPerPixel, kBytesPerRow); |
| (...skipping 18 matching lines...) Expand all 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 return differ_->DiffBlock(prev_.get() + block_offset, | 53 return BlockDifference(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); |
| 64 } | 64 } |
| 65 | 65 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 520 |
| 521 dirty.reset(new InvalidRects()); | 521 dirty.reset(new InvalidRects()); |
| 522 differ_->MergeBlocks(dirty.get()); | 522 differ_->MergeBlocks(dirty.get()); |
| 523 | 523 |
| 524 ASSERT_EQ(2UL, dirty->size()); | 524 ASSERT_EQ(2UL, dirty->size()); |
| 525 CheckDirtyRect(*dirty.get(), 0, 0, 2, 2); | 525 CheckDirtyRect(*dirty.get(), 0, 0, 2, 2); |
| 526 CheckDirtyRect(*dirty.get(), 1, 2, 1, 1); | 526 CheckDirtyRect(*dirty.get(), 1, 2, 1, 1); |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace remoting | 529 } // namespace remoting |
| OLD | NEW |