| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 PlatformImage ToPlatformType(const gfx::Image& image) { | 106 PlatformImage ToPlatformType(const gfx::Image& image) { |
| 107 #if defined(OS_MACOSX) | 107 #if defined(OS_MACOSX) |
| 108 return image.ToNSImage(); | 108 return image.ToNSImage(); |
| 109 #elif defined(TOOLKIT_GTK) | 109 #elif defined(TOOLKIT_GTK) |
| 110 return image.ToGdkPixbuf(); | 110 return image.ToGdkPixbuf(); |
| 111 #else | 111 #else |
| 112 return *image.ToSkBitmap(); | 112 return *image.ToSkBitmap(); |
| 113 #endif | 113 #endif |
| 114 } | 114 } |
| 115 | 115 |
| 116 PlatformImage CopyPlatformType(const gfx::Image& image) { |
| 117 #if defined(OS_MACOSX) |
| 118 return image.CopyNSImage(); |
| 119 #elif defined(TOOLKIT_GTK) |
| 120 return image.CopyGdkPixbuf(); |
| 121 #else |
| 122 return *image.ToSkBitmap(); |
| 123 #endif |
| 124 } |
| 125 |
| 116 bool IsPlatformImageValid(PlatformImage image) { | 126 bool IsPlatformImageValid(PlatformImage image) { |
| 117 #if defined(OS_MACOSX) || defined(TOOLKIT_GTK) | 127 #if defined(OS_MACOSX) || defined(TOOLKIT_GTK) |
| 118 return image != NULL; | 128 return image != NULL; |
| 119 #else | 129 #else |
| 120 return !image.isNull(); | 130 return !image.isNull(); |
| 121 #endif | 131 #endif |
| 122 } | 132 } |
| 123 | 133 |
| 124 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { | 134 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { |
| 125 #if defined(OS_MACOSX) || defined(TOOLKIT_GTK) | 135 #if defined(OS_MACOSX) || defined(TOOLKIT_GTK) |
| 126 return image1 == image2; | 136 return image1 == image2; |
| 127 #else | 137 #else |
| 128 return image1.getPixels() == image2.getPixels(); | 138 return image1.getPixels() == image2.getPixels(); |
| 129 #endif | 139 #endif |
| 130 } | 140 } |
| 131 | 141 |
| 132 } // namespace test | 142 } // namespace test |
| 133 } // namespace gfx | 143 } // namespace gfx |
| OLD | NEW |