Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: ui/gfx/image_unittest.h

Issue 6849030: Add support for multi resolution icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comments Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/image_mac_unittest.mm ('k') | ui/gfx/image_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Because the unit tests for gfx::Image are spread across multiple
6 // implementation files, this header contains the reusable components.
7
8 #ifndef UI_GFX_IMAGE_UNITTEST_H_
9 #define UI_GFX_IMAGE_UNITTEST_H_
10
11 #include "base/memory/scoped_ptr.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14
15 #if defined(OS_LINUX)
16 #include "ui/gfx/gtk_util.h"
17 #elif defined(OS_MACOSX)
18 #include "base/mac/mac_util.h"
19 #include "skia/ext/skia_utils_mac.h"
20 #endif
21
22 namespace gfx {
23 namespace test {
24
25 #if defined(OS_MACOSX)
26 typedef NSImage* PlatformImage;
27 #elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
28 typedef GdkPixbuf* PlatformImage;
29 #else
30 typedef const SkBitmap* PlatformImage;
31 #endif
32
33 SkBitmap* CreateBitmap() {
34 SkBitmap* bitmap = new SkBitmap();
35 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 25, 25);
36 bitmap->allocPixels();
37 bitmap->eraseRGB(255, 0, 0);
38 return bitmap;
39 }
40
41 PlatformImage CreatePlatformImage() {
42 scoped_ptr<SkBitmap> bitmap(CreateBitmap());
43 #if defined(OS_MACOSX)
44 NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get()));
45 base::mac::NSObjectRetain(image);
46 return image;
47 #elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
48 return gfx::GdkPixbufFromSkBitmap(bitmap.get());
49 #else
50 return bitmap.release();
51 #endif
52 }
53
54 gfx::Image::RepresentationType GetPlatformRepresentationType() {
55 #if defined(OS_MACOSX)
56 return gfx::Image::kNSImageRep;
57 #elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
58 return gfx::Image::kGdkPixbufRep;
59 #else
60 return gfx::Image::kSkBitmapRep;
61 #endif
62 }
63
64 } // namespace test
65 } // namespace gfx
66
67 #endif // UI_GFX_IMAGE_UNITTEST_H_
OLDNEW
« no previous file with comments | « ui/gfx/image_mac_unittest.mm ('k') | ui/gfx/image_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698