| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 DesktopRect::MakeOriginSize(src_pos, dest_rect.size()))); | 50 DesktopRect::MakeOriginSize(src_pos, dest_rect.size()))); |
| 51 | 51 |
| 52 CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos), | 52 CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos), |
| 53 src_frame.stride(), dest_rect); | 53 src_frame.stride(), dest_rect); |
| 54 } | 54 } |
| 55 | 55 |
| 56 uint8_t* DesktopFrame::GetFrameDataAtPos(const DesktopVector& pos) const { | 56 uint8_t* DesktopFrame::GetFrameDataAtPos(const DesktopVector& pos) const { |
| 57 return data() + stride() * pos.y() + DesktopFrame::kBytesPerPixel * pos.x(); | 57 return data() + stride() * pos.y() + DesktopFrame::kBytesPerPixel * pos.x(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool DesktopFrame::DataEquals(const DesktopFrame& other) const { |
| 61 if (!size().equals(other.size())) { |
| 62 return false; |
| 63 } |
| 64 if (stride() == other.stride() && |
| 65 stride() == DesktopFrame::kBytesPerPixel * size().width()) { |
| 66 return memcmp(data(), other.data(), stride() * size().height()) == 0; |
| 67 } |
| 68 |
| 69 const uint8_t* my_array = data(); |
| 70 const uint8_t* other_array = other.data(); |
| 71 for (int i = 0; i < size().height(); i++) { |
| 72 const uint8_t* my_this_line = my_array; |
| 73 const uint8_t* other_this_line = other_array; |
| 74 for (int j = 0; j < size().width(); j++) { |
| 75 if (memcmp(my_this_line, other_this_line, kBytesPerPixel) |
| 76 != 0) { |
| 77 return false; |
| 78 } |
| 79 my_this_line += kBytesPerPixel; |
| 80 other_this_line += kBytesPerPixel; |
| 81 } |
| 82 my_array += stride(); |
| 83 other_array += other.stride(); |
| 84 } |
| 85 |
| 86 return true; |
| 87 } |
| 88 |
| 89 void DesktopFrame::Paint(DesktopVector pos, RgbaColor color) { |
| 90 RTC_DCHECK(DesktopRect::MakeSize(size()).Contains(pos)); |
| 91 *reinterpret_cast<uint32_t*>(GetFrameDataAtPos(pos)) = color.ToUInt32(); |
| 92 } |
| 93 |
| 94 void DesktopFrame::Clear() { |
| 95 memset(data(), 0, stride() * size().height()); |
| 96 } |
| 97 |
| 60 BasicDesktopFrame::BasicDesktopFrame(DesktopSize size) | 98 BasicDesktopFrame::BasicDesktopFrame(DesktopSize size) |
| 61 : DesktopFrame(size, kBytesPerPixel * size.width(), | 99 : DesktopFrame(size, kBytesPerPixel * size.width(), |
| 62 new uint8_t[kBytesPerPixel * size.width() * size.height()], | 100 new uint8_t[kBytesPerPixel * size.width() * size.height()], |
| 63 NULL) { | 101 NULL) { |
| 64 } | 102 } |
| 65 | 103 |
| 66 BasicDesktopFrame::~BasicDesktopFrame() { | 104 BasicDesktopFrame::~BasicDesktopFrame() { |
| 67 delete[] data_; | 105 delete[] data_; |
| 68 } | 106 } |
| 69 | 107 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 : DesktopFrame(size, | 147 : DesktopFrame(size, |
| 110 stride, | 148 stride, |
| 111 reinterpret_cast<uint8_t*>(shared_memory->data()), | 149 reinterpret_cast<uint8_t*>(shared_memory->data()), |
| 112 shared_memory) {} | 150 shared_memory) {} |
| 113 | 151 |
| 114 SharedMemoryDesktopFrame::~SharedMemoryDesktopFrame() { | 152 SharedMemoryDesktopFrame::~SharedMemoryDesktopFrame() { |
| 115 delete shared_memory_; | 153 delete shared_memory_; |
| 116 } | 154 } |
| 117 | 155 |
| 118 } // namespace webrtc | 156 } // namespace webrtc |
| OLD | NEW |