| 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 // Because the unit tests for gfx::Image are spread across multiple | 5 // Because the unit tests for gfx::Image are spread across multiple |
| 6 // implementation files, this header contains the reusable components. | 6 // implementation files, this header contains the reusable components. |
| 7 | 7 |
| 8 #include "ui/gfx/image/image_unittest_util.h" | 8 #include "ui/gfx/image/image_unittest_util.h" |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 96 } |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool IsEqual(const SkBitmap& bmp1, const SkBitmap& bmp2) { | 100 bool IsEqual(const SkBitmap& bmp1, const SkBitmap& bmp2) { |
| 101 if (bmp1.isNull() && bmp2.isNull()) | 101 if (bmp1.isNull() && bmp2.isNull()) |
| 102 return true; | 102 return true; |
| 103 | 103 |
| 104 if (bmp1.width() != bmp2.width() || | 104 if (bmp1.width() != bmp2.width() || |
| 105 bmp1.height() != bmp2.height() || | 105 bmp1.height() != bmp2.height() || |
| 106 bmp1.config() != SkBitmap::kARGB_8888_Config || | 106 bmp1.colorType() != kN32_SkColorType || |
| 107 bmp2.config() != SkBitmap::kARGB_8888_Config) { | 107 bmp2.colorType() != kN32_SkColorType) { |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 SkAutoLockPixels lock1(bmp1); | 111 SkAutoLockPixels lock1(bmp1); |
| 112 SkAutoLockPixels lock2(bmp2); | 112 SkAutoLockPixels lock2(bmp2); |
| 113 if (!bmp1.getPixels() || !bmp2.getPixels()) | 113 if (!bmp1.getPixels() || !bmp2.getPixels()) |
| 114 return false; | 114 return false; |
| 115 | 115 |
| 116 for (int y = 0; y < bmp1.height(); ++y) { | 116 for (int y = 0; y < bmp1.height(); ++y) { |
| 117 for (int x = 0; x < bmp1.width(); ++x) { | 117 for (int x = 0; x < bmp1.width(); ++x) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { | 254 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { |
| 255 #if defined(OS_MACOSX) | 255 #if defined(OS_MACOSX) |
| 256 return image1 == image2; | 256 return image1 == image2; |
| 257 #else | 257 #else |
| 258 return image1.BackedBySameObjectAs(image2); | 258 return image1.BackedBySameObjectAs(image2); |
| 259 #endif | 259 #endif |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace test | 262 } // namespace test |
| 263 } // namespace gfx | 263 } // namespace gfx |
| OLD | NEW |