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_unittest_util.h" | 9 #include "ui/gfx/image_unittest_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
12 | 12 |
13 #if defined(OS_LINUX) | 13 #if defined(TOOLKIT_USES_GTK) |
14 #include "ui/gfx/gtk_util.h" | 14 #include "ui/gfx/gtk_util.h" |
15 #elif defined(OS_MACOSX) | 15 #elif defined(OS_MACOSX) |
16 #include "base/mac/mac_util.h" | 16 #include "base/mac/mac_util.h" |
17 #include "skia/ext/skia_utils_mac.h" | 17 #include "skia/ext/skia_utils_mac.h" |
18 #endif | 18 #endif |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 namespace test { | 21 namespace test { |
22 | 22 |
23 SkBitmap* CreateBitmap(int width, int height) { | 23 SkBitmap* CreateBitmap(int width, int height) { |
24 SkBitmap* bitmap = new SkBitmap(); | 24 SkBitmap* bitmap = new SkBitmap(); |
25 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 25 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); |
26 bitmap->allocPixels(); | 26 bitmap->allocPixels(); |
27 bitmap->eraseRGB(255, 0, 0); | 27 bitmap->eraseRGB(255, 0, 0); |
28 return bitmap; | 28 return bitmap; |
29 } | 29 } |
30 | 30 |
31 PlatformImage CreatePlatformImage() { | 31 PlatformImage CreatePlatformImage() { |
32 scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25)); | 32 scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25)); |
33 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
34 NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get())); | 34 NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get())); |
35 base::mac::NSObjectRetain(image); | 35 base::mac::NSObjectRetain(image); |
36 return image; | 36 return image; |
37 #elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) | 37 #elif defined(TOOLKIT_GTK) |
Robert Sesek
2011/05/24 16:24:12
USES?
| |
38 return gfx::GdkPixbufFromSkBitmap(bitmap.get()); | 38 return gfx::GdkPixbufFromSkBitmap(bitmap.get()); |
39 #else | 39 #else |
40 return bitmap.release(); | 40 return bitmap.release(); |
41 #endif | 41 #endif |
42 } | 42 } |
43 | 43 |
44 gfx::Image::RepresentationType GetPlatformRepresentationType() { | 44 gfx::Image::RepresentationType GetPlatformRepresentationType() { |
45 #if defined(OS_MACOSX) | 45 #if defined(OS_MACOSX) |
46 return gfx::Image::kImageRepCocoa; | 46 return gfx::Image::kImageRepCocoa; |
47 #elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) | 47 #elif defined(TOOLKIT_GTK) |
Robert Sesek
2011/05/24 16:24:12
USES?
| |
48 return gfx::Image::kImageRepGdk; | 48 return gfx::Image::kImageRepGdk; |
49 #else | 49 #else |
50 return gfx::Image::kImageRepSkia; | 50 return gfx::Image::kImageRepSkia; |
51 #endif | 51 #endif |
52 } | 52 } |
53 | 53 |
54 } // namespace test | 54 } // namespace test |
55 } // namespace gfx | 55 } // namespace gfx |
OLD | NEW |