OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/image/image_unittest_util.h" | 9 #include "ui/gfx/image/image_unittest_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 (bmp.width() == 0 && bmp.height() == 0); | 64 (bmp.width() == 0 && bmp.height() == 0); |
65 } | 65 } |
66 | 66 |
67 PlatformImage CreatePlatformImage() { | 67 PlatformImage CreatePlatformImage() { |
68 scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25)); | 68 scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25)); |
69 #if defined(OS_MACOSX) | 69 #if defined(OS_MACOSX) |
70 NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get())); | 70 NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get())); |
71 base::mac::NSObjectRetain(image); | 71 base::mac::NSObjectRetain(image); |
72 return image; | 72 return image; |
73 #elif defined(TOOLKIT_GTK) | 73 #elif defined(TOOLKIT_GTK) |
74 return gfx::GdkPixbufFromSkBitmap(bitmap.get()); | 74 return gfx::GdkPixbufFromSkBitmap(*bitmap.get()); |
75 #else | 75 #else |
76 return bitmap.release(); | 76 return bitmap.release(); |
77 #endif | 77 #endif |
78 } | 78 } |
79 | 79 |
80 gfx::Image::RepresentationType GetPlatformRepresentationType() { | 80 gfx::Image::RepresentationType GetPlatformRepresentationType() { |
81 #if defined(OS_MACOSX) | 81 #if defined(OS_MACOSX) |
82 return gfx::Image::kImageRepCocoa; | 82 return gfx::Image::kImageRepCocoa; |
83 #elif defined(TOOLKIT_GTK) | 83 #elif defined(TOOLKIT_GTK) |
84 return gfx::Image::kImageRepGdk; | 84 return gfx::Image::kImageRepGdk; |
85 #else | 85 #else |
86 return gfx::Image::kImageRepSkia; | 86 return gfx::Image::kImageRepSkia; |
87 #endif | 87 #endif |
88 } | 88 } |
89 | 89 |
90 PlatformImage ToPlatformType(const gfx::Image& image) { | 90 PlatformImage ToPlatformType(const gfx::Image& image) { |
91 #if defined(OS_MACOSX) | 91 #if defined(OS_MACOSX) |
92 return image.ToNSImage(); | 92 return image.ToNSImage(); |
93 #elif defined(TOOLKIT_GTK) | 93 #elif defined(TOOLKIT_GTK) |
94 return image.ToGdkPixbuf(); | 94 return image.ToGdkPixbuf(); |
95 #else | 95 #else |
96 return image.ToSkBitmap(); | 96 return image.ToSkBitmap(); |
97 #endif | 97 #endif |
98 } | 98 } |
99 | 99 |
100 } // namespace test | 100 } // namespace test |
101 } // namespace gfx | 101 } // namespace gfx |
OLD | NEW |