| 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 "remoting/host/differ.h" | 5 #include "remoting/host/differ.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 | 10 |
| 11 Differ::Differ(int width, int height, int bpp, int stride) { | 11 Differ::Differ(int width, int height, int bpp, int stride) { |
| 12 // Dimensions of screen. | 12 // Dimensions of screen. |
| 13 width_ = width; | 13 width_ = width; |
| 14 height_ = height; | 14 height_ = height; |
| 15 bytes_per_pixel_ = bpp; | 15 bytes_per_pixel_ = bpp; |
| 16 bytes_per_row_ = stride; | 16 bytes_per_row_ = stride; |
| 17 | 17 |
| 18 // Calc number of blocks (full and partial) required to cover entire image. | 18 // Calc number of blocks (full and partial) required to cover entire image. |
| 19 // One additional row/column is added as a boundary on the right & bottom. | 19 // One additional row/column is added as a boundary on the right & bottom. |
| 20 diff_info_width_ = (width_ + kBlockSize - 1) / kBlockSize + 1; | 20 diff_info_width_ = (width_ + kBlockSize - 1) / kBlockSize + 1; |
| 21 diff_info_height_ = (height_ + kBlockSize - 1) / kBlockSize + 1; | 21 diff_info_height_ = (height_ + kBlockSize - 1) / kBlockSize + 1; |
| 22 diff_info_size_ = diff_info_width_ * diff_info_height_ * sizeof(DiffInfo); | 22 diff_info_size_ = diff_info_width_ * diff_info_height_ * sizeof(DiffInfo); |
| 23 diff_info_.reset(new uint8[diff_info_size_]); | 23 diff_info_.reset(new uint8[diff_info_size_]); |
| 24 } | 24 } |
| 25 | 25 |
| 26 Differ::~Differ() {} |
| 27 |
| 26 void Differ::CalcDirtyRects(const void* prev_buffer, const void* curr_buffer, | 28 void Differ::CalcDirtyRects(const void* prev_buffer, const void* curr_buffer, |
| 27 InvalidRects* rects) { | 29 InvalidRects* rects) { |
| 28 if (!rects) { | 30 if (!rects) { |
| 29 return; | 31 return; |
| 30 } | 32 } |
| 31 rects->clear(); | 33 rects->clear(); |
| 32 | 34 |
| 33 if (!prev_buffer || !curr_buffer) { | 35 if (!prev_buffer || !curr_buffer) { |
| 34 return; | 36 return; |
| 35 } | 37 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // Increment to next block in this row. | 219 // Increment to next block in this row. |
| 218 diff_info++; | 220 diff_info++; |
| 219 } | 221 } |
| 220 | 222 |
| 221 // Go to start of next row. | 223 // Go to start of next row. |
| 222 diff_info_row_start += diff_info_stride; | 224 diff_info_row_start += diff_info_stride; |
| 223 } | 225 } |
| 224 } | 226 } |
| 225 | 227 |
| 226 } // namespace remoting | 228 } // namespace remoting |
| OLD | NEW |