| 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> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "ui/gfx/codec/png_codec.h" | 15 #include "ui/gfx/codec/png_codec.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
| 17 | 17 |
| 18 #if defined(OS_IOS) | 18 #if defined(OS_IOS) |
| 19 #include "base/mac/foundation_util.h" | 19 #include "base/mac/foundation_util.h" |
| 20 #include "base/mac/scoped_cftyperef.h" | 20 #include "base/mac/scoped_cftyperef.h" |
| 21 #include "skia/ext/skia_utils_ios.h" | 21 #include "skia/ext/skia_utils_ios.h" |
| 22 #elif defined(OS_MACOSX) | 22 #elif defined(OS_MACOSX) |
| 23 #include "base/mac/foundation_util.h" | 23 #include "base/mac/foundation_util.h" |
| 24 #include "base/mac/mac_util.h" |
| 24 #include "skia/ext/skia_utils_mac.h" | 25 #include "skia/ext/skia_utils_mac.h" |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 namespace gfx { | 28 namespace gfx { |
| 28 namespace test { | 29 namespace test { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 bool ColorComponentsClose(SkColor component1, SkColor component2) { | 33 bool ColorComponentsClose(SkColor component1, SkColor component2) { |
| 33 int c1 = static_cast<int>(component1); | 34 int c1 = static_cast<int>(component1); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 #if defined(OS_IOS) | 181 #if defined(OS_IOS) |
| 181 float scale = ImageSkia::GetMaxSupportedScale(); | 182 float scale = ImageSkia::GetMaxSupportedScale(); |
| 182 | 183 |
| 183 base::ScopedCFTypeRef<CGColorSpaceRef> color_space( | 184 base::ScopedCFTypeRef<CGColorSpaceRef> color_space( |
| 184 CGColorSpaceCreateDeviceRGB()); | 185 CGColorSpaceCreateDeviceRGB()); |
| 185 UIImage* image = | 186 UIImage* image = |
| 186 gfx::SkBitmapToUIImageWithColorSpace(bitmap, scale, color_space); | 187 gfx::SkBitmapToUIImageWithColorSpace(bitmap, scale, color_space); |
| 187 base::mac::NSObjectRetain(image); | 188 base::mac::NSObjectRetain(image); |
| 188 return image; | 189 return image; |
| 189 #elif defined(OS_MACOSX) | 190 #elif defined(OS_MACOSX) |
| 190 NSImage* image = gfx::SkBitmapToNSImage(bitmap); | 191 NSImage* image = gfx::SkBitmapToNSImageWithColorSpace( |
| 192 bitmap, base::mac::GetGenericRGBColorSpace()); |
| 191 base::mac::NSObjectRetain(image); | 193 base::mac::NSObjectRetain(image); |
| 192 return image; | 194 return image; |
| 193 #else | 195 #else |
| 194 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 196 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 195 #endif | 197 #endif |
| 196 } | 198 } |
| 197 | 199 |
| 198 gfx::Image::RepresentationType GetPlatformRepresentationType() { | 200 gfx::Image::RepresentationType GetPlatformRepresentationType() { |
| 199 #if defined(OS_IOS) | 201 #if defined(OS_IOS) |
| 200 return gfx::Image::kImageRepCocoaTouch; | 202 return gfx::Image::kImageRepCocoaTouch; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { | 256 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { |
| 255 #if defined(OS_MACOSX) | 257 #if defined(OS_MACOSX) |
| 256 return image1 == image2; | 258 return image1 == image2; |
| 257 #else | 259 #else |
| 258 return image1.BackedBySameObjectAs(image2); | 260 return image1.BackedBySameObjectAs(image2); |
| 259 #endif | 261 #endif |
| 260 } | 262 } |
| 261 | 263 |
| 262 } // namespace test | 264 } // namespace test |
| 263 } // namespace gfx | 265 } // namespace gfx |
| OLD | NEW |