| 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/base/layout.h" | 9 #include "ui/base/layout.h" |
| 10 #include "ui/gfx/image/image_unittest_util.h" | 10 #include "ui/gfx/image/image_unittest_util.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 bool IsEmpty(const gfx::Image& image) { | 78 bool IsEmpty(const gfx::Image& image) { |
| 79 const SkBitmap& bmp = *image.ToSkBitmap(); | 79 const SkBitmap& bmp = *image.ToSkBitmap(); |
| 80 return bmp.isNull() || | 80 return bmp.isNull() || |
| 81 (bmp.width() == 0 && bmp.height() == 0); | 81 (bmp.width() == 0 && bmp.height() == 0); |
| 82 } | 82 } |
| 83 | 83 |
| 84 PlatformImage CreatePlatformImage() { | 84 PlatformImage CreatePlatformImage() { |
| 85 const SkBitmap bitmap(CreateBitmap(25, 25)); | 85 const SkBitmap bitmap(CreateBitmap(25, 25)); |
| 86 #if defined(OS_IOS) | 86 #if defined(OS_IOS) |
| 87 // iOS only supports one scale factor. | 87 ui::ScaleFactor scale_factor = ui::GetMaxScaleFactor(); |
| 88 std::vector<ui::ScaleFactor> supported_scale_factors = | |
| 89 ui::GetSupportedScaleFactors(); | |
| 90 DCHECK_EQ(1U, supported_scale_factors.size()); | |
| 91 if (supported_scale_factors.size() < 1) | |
| 92 return nil; | |
| 93 | |
| 94 ui::ScaleFactor scale_factor = supported_scale_factors[0]; | |
| 95 float scale = ui::GetScaleFactorScale(scale_factor); | 88 float scale = ui::GetScaleFactorScale(scale_factor); |
| 96 | 89 |
| 97 base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space( | 90 base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space( |
| 98 CGColorSpaceCreateDeviceRGB()); | 91 CGColorSpaceCreateDeviceRGB()); |
| 99 UIImage* image = | 92 UIImage* image = |
| 100 gfx::SkBitmapToUIImageWithColorSpace(bitmap, scale, color_space); | 93 gfx::SkBitmapToUIImageWithColorSpace(bitmap, scale, color_space); |
| 101 base::mac::NSObjectRetain(image); | 94 base::mac::NSObjectRetain(image); |
| 102 return image; | 95 return image; |
| 103 #elif defined(OS_MACOSX) | 96 #elif defined(OS_MACOSX) |
| 104 NSImage* image = gfx::SkBitmapToNSImage(bitmap); | 97 NSImage* image = gfx::SkBitmapToNSImage(bitmap); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { | 183 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { |
| 191 #if defined(OS_MACOSX) || defined(TOOLKIT_GTK) | 184 #if defined(OS_MACOSX) || defined(TOOLKIT_GTK) |
| 192 return image1 == image2; | 185 return image1 == image2; |
| 193 #else | 186 #else |
| 194 return image1.getPixels() == image2.getPixels(); | 187 return image1.getPixels() == image2.getPixels(); |
| 195 #endif | 188 #endif |
| 196 } | 189 } |
| 197 | 190 |
| 198 } // namespace test | 191 } // namespace test |
| 199 } // namespace gfx | 192 } // namespace gfx |
| OLD | NEW |