| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "remoting/base/util.h" | 7 #include "remoting/base/util.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/libyuv/include/libyuv/convert_from_argb.h" |
| 9 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 10 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 10 | 11 |
| 11 static const int kWidth = 32 ; | 12 static const int kWidth = 32 ; |
| 12 static const int kHeight = 24 ; | 13 static const int kHeight = 24 ; |
| 13 static const int kBytesPerPixel = 4; | 14 static const int kBytesPerPixel = 4; |
| 14 static const int kYStride = kWidth; | 15 static const int kYStride = kWidth; |
| 15 static const int kUvStride = kWidth / 2; | 16 static const int kUvStride = kWidth / 2; |
| 16 static const int kRgbStride = kWidth * kBytesPerPixel; | 17 static const int kRgbStride = kWidth * kBytesPerPixel; |
| 17 static const uint32 kFillColor = 0xffffff; | 18 static const uint32 kFillColor = 0xffffff; |
| 18 | 19 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const webrtc::DesktopRect& rect) { | 85 const webrtc::DesktopRect& rect) { |
| 85 ASSERT_TRUE( | 86 ASSERT_TRUE( |
| 86 DoesRectContain(webrtc::DesktopRect::MakeSize(dest_size), rect)); | 87 DoesRectContain(webrtc::DesktopRect::MakeSize(dest_size), rect)); |
| 87 | 88 |
| 88 // Reset buffers. | 89 // Reset buffers. |
| 89 ResetYuvBuffer(); | 90 ResetYuvBuffer(); |
| 90 ResetRgbBuffer(); | 91 ResetRgbBuffer(); |
| 91 FillRgbBuffer(rect); | 92 FillRgbBuffer(rect); |
| 92 | 93 |
| 93 // RGB -> YUV | 94 // RGB -> YUV |
| 94 ConvertRGB32ToYUVWithRect(rgb_buffer_.get(), | 95 libyuv::ARGBToI420(rgb_buffer_.get(), |
| 95 yplane_, | 96 kRgbStride, |
| 96 uplane_, | 97 yplane_, |
| 97 vplane_, | 98 kYStride, |
| 98 0, | 99 uplane_, |
| 99 0, | 100 kUvStride, |
| 100 kWidth, | 101 vplane_, |
| 101 kHeight, | 102 kUvStride, |
| 102 kRgbStride, | 103 kWidth, |
| 103 kYStride, | 104 kHeight); |
| 104 kUvStride); | |
| 105 | 105 |
| 106 // Reset RGB buffer and do opposite conversion. | 106 // Reset RGB buffer and do opposite conversion. |
| 107 ResetRgbBuffer(); | 107 ResetRgbBuffer(); |
| 108 ConvertAndScaleYUVToRGB32Rect(yplane_, | 108 ConvertAndScaleYUVToRGB32Rect(yplane_, |
| 109 uplane_, | 109 uplane_, |
| 110 vplane_, | 110 vplane_, |
| 111 kYStride, | 111 kYStride, |
| 112 kUvStride, | 112 kUvStride, |
| 113 webrtc::DesktopSize(kWidth, kHeight), | 113 webrtc::DesktopSize(kWidth, kHeight), |
| 114 webrtc::DesktopRect::MakeWH(kWidth, kHeight), | 114 webrtc::DesktopRect::MakeWH(kWidth, kHeight), |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 EXPECT_FALSE(StringIsUtf8("\xfe\x80\x80\x80\x80\x80\x80", 7)); | 279 EXPECT_FALSE(StringIsUtf8("\xfe\x80\x80\x80\x80\x80\x80", 7)); |
| 280 EXPECT_FALSE(StringIsUtf8("\xff\x80\x80\x80\x80\x80\x80", 7)); | 280 EXPECT_FALSE(StringIsUtf8("\xff\x80\x80\x80\x80\x80\x80", 7)); |
| 281 | 281 |
| 282 // Invalid continuation byte | 282 // Invalid continuation byte |
| 283 EXPECT_FALSE(StringIsUtf8("\xc0\x00", 2)); | 283 EXPECT_FALSE(StringIsUtf8("\xc0\x00", 2)); |
| 284 EXPECT_FALSE(StringIsUtf8("\xc0\x40", 2)); | 284 EXPECT_FALSE(StringIsUtf8("\xc0\x40", 2)); |
| 285 EXPECT_FALSE(StringIsUtf8("\xc0\xc0", 2)); | 285 EXPECT_FALSE(StringIsUtf8("\xc0\xc0", 2)); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace remoting | 288 } // namespace remoting |
| OLD | NEW |