diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 19:31:26 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 19:31:26 +0000 |
commit | 17437dba596f54bbafe2814a2c70552e7396aa4a (patch) | |
tree | 90dd8b904c57df38d093d527eb80f0427d581a8a /ui/gfx/image_unittest_util.cc | |
parent | 95d99c5d933de6eabd30aa22f5d20c7de43cb11e (diff) | |
download | chromium_src-17437dba596f54bbafe2814a2c70552e7396aa4a.zip chromium_src-17437dba596f54bbafe2814a2c70552e7396aa4a.tar.gz chromium_src-17437dba596f54bbafe2814a2c70552e7396aa4a.tar.bz2 |
Use large icon resource pak
This is a part of r82185 that was reverted. The change was reverted because it caused a performance regression.
In r82538 and r82584 I re-checked in code to split high-res icons into a seperate resource pak and load it.
This change adds code to actually use use the high-res icons.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/6897013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/image_unittest_util.cc')
-rw-r--r-- | ui/gfx/image_unittest_util.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/ui/gfx/image_unittest_util.cc b/ui/gfx/image_unittest_util.cc new file mode 100644 index 0000000..b996a86 --- /dev/null +++ b/ui/gfx/image_unittest_util.cc @@ -0,0 +1,55 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Because the unit tests for gfx::Image are spread across multiple +// implementation files, this header contains the reusable components. + +#include "base/memory/scoped_ptr.h" +#include "ui/gfx/image_unittest_util.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/skia/include/core/SkBitmap.h" + +#if defined(OS_LINUX) +#include "ui/gfx/gtk_util.h" +#elif defined(OS_MACOSX) +#include "base/mac/mac_util.h" +#include "skia/ext/skia_utils_mac.h" +#endif + +namespace gfx { +namespace test { + +SkBitmap* CreateBitmap(int width, int height) { + SkBitmap* bitmap = new SkBitmap(); + bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); + bitmap->allocPixels(); + bitmap->eraseRGB(255, 0, 0); + return bitmap; +} + +PlatformImage CreatePlatformImage() { + scoped_ptr<SkBitmap> bitmap(CreateBitmap(25, 25)); +#if defined(OS_MACOSX) + NSImage* image = gfx::SkBitmapToNSImage(*(bitmap.get())); + base::mac::NSObjectRetain(image); + return image; +#elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) + return gfx::GdkPixbufFromSkBitmap(bitmap.get()); +#else + return bitmap.release(); +#endif +} + +gfx::Image::RepresentationType GetPlatformRepresentationType() { +#if defined(OS_MACOSX) + return gfx::Image::kNSImageRep; +#elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) + return gfx::Image::kGdkPixbufRep; +#else + return gfx::Image::kSkBitmapRep; +#endif +} + +} // namespace test +} // namespace gfx |