| 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/capturer_fake.h" | 5 #include "remoting/host/capturer_fake.h" |
| 6 | 6 |
| 7 #include "gfx/rect.h" | 7 #include "gfx/rect.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 | 10 |
| 11 static const int kWidth = 640; | 11 static const int kWidth = 320; |
| 12 static const int kHeight = 480; | 12 static const int kHeight = 240; |
| 13 static const int kBytesPerPixel = 3; // 24 bit RGB is 3 bytes per pixel. | 13 static const int kBytesPerPixel = 4; // 32 bit RGB is 4 bytes per pixel. |
| 14 static const int kMaxColorChannelValue = 255; | 14 static const int kMaxColorChannelValue = 255; |
| 15 | 15 |
| 16 CapturerFake::CapturerFake() | 16 CapturerFake::CapturerFake() |
| 17 : seed_(0) { | 17 : seed_(0) { |
| 18 // Dimensions of screen. | 18 // Dimensions of screen. |
| 19 width_ = kWidth; | 19 width_ = kWidth; |
| 20 height_ = kHeight; | 20 height_ = kHeight; |
| 21 pixel_format_ = chromotocol_pb::PixelFormatRgb24; | 21 pixel_format_ = PixelFormatRgb32; |
| 22 bytes_per_pixel_ = kBytesPerPixel; | 22 bytes_per_pixel_ = kBytesPerPixel; |
| 23 bytes_per_row_ = width_ * bytes_per_pixel_; | 23 bytes_per_row_ = width_ * bytes_per_pixel_; |
| 24 | 24 |
| 25 // Create memory for the buffers. | 25 // Create memory for the buffers. |
| 26 int buffer_size = height_ * bytes_per_row_; | 26 int buffer_size = height_ * bytes_per_row_; |
| 27 for (int i = 0; i < kNumBuffers; i++) { | 27 for (int i = 0; i < kNumBuffers; i++) { |
| 28 buffers_[i].reset(new uint8[buffer_size]); | 28 buffers_[i].reset(new uint8[buffer_size]); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 void CapturerFake::GetDataStride(int strides[]) const { | 69 void CapturerFake::GetDataStride(int strides[]) const { |
| 70 // Only the first plane has data. | 70 // Only the first plane has data. |
| 71 strides[0] = bytes_per_row_; | 71 strides[0] = bytes_per_row_; |
| 72 strides[1] = strides[2] = 0; | 72 strides[1] = strides[2] = 0; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void CapturerFake::GenerateImage() { | 75 void CapturerFake::GenerateImage() { |
| 76 uint8* row = buffers_[current_buffer_].get(); | 76 uint8* row = buffers_[current_buffer_].get(); |
| 77 for (int y = 0; y < height_; ++y) { | 77 for (int y = 0; y < height_; ++y) { |
| 78 int offset = y % 3; |
| 78 for (int x = 0; x < width_; ++x) { | 79 for (int x = 0; x < width_; ++x) { |
| 79 row[x] = seed_++; | 80 row[x * kBytesPerPixel + offset] = seed_++; |
| 80 seed_ &= kMaxColorChannelValue; | 81 seed_ &= kMaxColorChannelValue; |
| 81 } | 82 } |
| 82 row += bytes_per_row_; | 83 row += bytes_per_row_; |
| 83 } | 84 } |
| 85 ++seed_; |
| 84 } | 86 } |
| 85 | 87 |
| 86 } // namespace remoting | 88 } // namespace remoting |
| OLD | NEW |