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 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "remoting/host/differ_block.h" | 6 #include "remoting/host/differ_block.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 |
11 // Run 900 times to mimic 1280x720. | 11 // Run 900 times to mimic 1280x720. |
12 // TODO(fbarchard): Remove benchmark once performance is non-issue. | 12 // TODO(fbarchard): Remove benchmark once performance is non-issue. |
13 static const int kTimesToRun = 900; | 13 static const int kTimesToRun = 900; |
14 | 14 |
15 static void GenerateData(uint8* data, int size) { | 15 static void GenerateData(uint8* data, int size) { |
16 for (int i = 0; i < size; ++i) { | 16 for (int i = 0; i < size; ++i) { |
17 data[i] = i; | 17 data[i] = i; |
18 } | 18 } |
19 } | 19 } |
20 | 20 |
21 class EncodeDoneHandler | |
22 : public base::RefCountedThreadSafe<EncodeDoneHandler> { | |
23 public: | |
24 MOCK_METHOD0(EncodeDone, void()); | |
25 }; | |
26 | |
27 // Memory buffer large enough for 2 blocks aligned to 16 bytes. | 21 // Memory buffer large enough for 2 blocks aligned to 16 bytes. |
28 static const int kSizeOfBlock = kBlockSize * kBlockSize * kBytesPerPixel; | 22 static const int kSizeOfBlock = kBlockSize * kBlockSize * kBytesPerPixel; |
29 uint8 block_buffer[kSizeOfBlock * 2 + 16]; | 23 uint8 block_buffer[kSizeOfBlock * 2 + 16]; |
30 | 24 |
31 void PrepareBuffers(uint8* &block1, uint8* &block2) { | 25 void PrepareBuffers(uint8* &block1, uint8* &block2) { |
32 block1 = reinterpret_cast<uint8*> | 26 block1 = reinterpret_cast<uint8*> |
33 ((reinterpret_cast<uintptr_t>(&block_buffer[0]) + 15) & ~15); | 27 ((reinterpret_cast<uintptr_t>(&block_buffer[0]) + 15) & ~15); |
34 GenerateData(block1, kSizeOfBlock); | 28 GenerateData(block1, kSizeOfBlock); |
35 block2 = block1 + kSizeOfBlock; | 29 block2 = block1 + kSizeOfBlock; |
36 memcpy(block2, block1, kSizeOfBlock); | 30 memcpy(block2, block1, kSizeOfBlock); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 PrepareBuffers(block1, block2); | 72 PrepareBuffers(block1, block2); |
79 block2[0] += 1; | 73 block2[0] += 1; |
80 | 74 |
81 for (int i = 0; i < kTimesToRun; ++i) { | 75 for (int i = 0; i < kTimesToRun; ++i) { |
82 int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel); | 76 int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel); |
83 EXPECT_EQ(1, result); | 77 EXPECT_EQ(1, result); |
84 } | 78 } |
85 } | 79 } |
86 | 80 |
87 } // namespace remoting | 81 } // namespace remoting |
OLD | NEW |