summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 20:11:26 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-20 20:11:26 +0000
commit8e453206d7d2c1341e155876ff6b12bf3486a4b2 (patch)
tree3f4ae3eec091e7b02181591b5700af5240a08b7e /ui
parentfadcd6d7321dde7e590fa637ef0913f14e65e683 (diff)
downloadchromium_src-8e453206d7d2c1341e155876ff6b12bf3486a4b2.zip
chromium_src-8e453206d7d2c1341e155876ff6b12bf3486a4b2.tar.gz
chromium_src-8e453206d7d2c1341e155876ff6b12bf3486a4b2.tar.bz2
Rename internal gfx::Image members to be less confusing with Cocoa types.
BUG=82453 TEST=ui_unittests Review URL: http://codereview.chromium.org/7055010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/resource/resource_bundle_mac.mm2
-rw-r--r--ui/gfx/image.cc118
-rw-r--r--ui/gfx/image.h6
-rw-r--r--ui/gfx/image_unittest.cc14
-rw-r--r--ui/gfx/image_unittest_util.cc6
5 files changed, 73 insertions, 73 deletions
diff --git a/ui/base/resource/resource_bundle_mac.mm b/ui/base/resource/resource_bundle_mac.mm
index 0508177..2c66d60 100644
--- a/ui/base/resource/resource_bundle_mac.mm
+++ b/ui/base/resource/resource_bundle_mac.mm
@@ -71,7 +71,7 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
base::AutoLock lock(*lock_);
ImageMap::const_iterator found = images_.find(resource_id);
if (found != images_.end()) {
- if (!found->second->HasRepresentation(gfx::Image::kNSImageRep)) {
+ if (!found->second->HasRepresentation(gfx::Image::kImageRepCocoa)) {
DLOG(WARNING) << "ResourceBundle::GetNativeImageNamed() is returning a"
<< " cached gfx::Image that isn't backed by an NSImage. The image"
<< " will be converted, rather than going through the NSImage loader."
diff --git a/ui/gfx/image.cc b/ui/gfx/image.cc
index c6b22474..272eb79 100644
--- a/ui/gfx/image.cc
+++ b/ui/gfx/image.cc
@@ -40,9 +40,9 @@ const SkBitmap* GdkPixbufToSkBitmap(GdkPixbuf* pixbuf) {
}
#endif
-class SkBitmapRep;
-class GdkPixbufRep;
-class NSImageRep;
+class ImageRepSkia;
+class ImageRepGdk;
+class ImageRepCocoa;
// An ImageRep is the object that holds the backing memory for an Image. Each
// RepresentationType has an ImageRep subclass that is responsible for freeing
@@ -57,22 +57,22 @@ class ImageRep {
virtual ~ImageRep() {}
// Cast helpers ("fake RTTI").
- SkBitmapRep* AsSkBitmapRep() {
- CHECK_EQ(type_, Image::kSkBitmapRep);
- return reinterpret_cast<SkBitmapRep*>(this);
+ ImageRepSkia* AsImageRepSkia() {
+ CHECK_EQ(type_, Image::kImageRepSkia);
+ return reinterpret_cast<ImageRepSkia*>(this);
}
#if defined(OS_LINUX)
- GdkPixbufRep* AsGdkPixbufRep() {
- CHECK_EQ(type_, Image::kGdkPixbufRep);
- return reinterpret_cast<GdkPixbufRep*>(this);
+ ImageRepGdk* AsImageRepGdk() {
+ CHECK_EQ(type_, Image::kImageRepGdk);
+ return reinterpret_cast<ImageRepGdk*>(this);
}
#endif
#if defined(OS_MACOSX)
- NSImageRep* AsNSImageRep() {
- CHECK_EQ(type_, Image::kNSImageRep);
- return reinterpret_cast<NSImageRep*>(this);
+ ImageRepCocoa* AsImageRepCocoa() {
+ CHECK_EQ(type_, Image::kImageRepCocoa);
+ return reinterpret_cast<ImageRepCocoa*>(this);
}
#endif
@@ -82,21 +82,21 @@ class ImageRep {
Image::RepresentationType type_;
};
-class SkBitmapRep : public ImageRep {
+class ImageRepSkia : public ImageRep {
public:
- explicit SkBitmapRep(const SkBitmap* bitmap)
- : ImageRep(Image::kSkBitmapRep) {
+ explicit ImageRepSkia(const SkBitmap* bitmap)
+ : ImageRep(Image::kImageRepSkia) {
CHECK(bitmap);
bitmaps_.push_back(bitmap);
}
- explicit SkBitmapRep(const std::vector<const SkBitmap*>& bitmaps)
- : ImageRep(Image::kSkBitmapRep),
+ explicit ImageRepSkia(const std::vector<const SkBitmap*>& bitmaps)
+ : ImageRep(Image::kImageRepSkia),
bitmaps_(bitmaps) {
CHECK(!bitmaps_.empty());
}
- virtual ~SkBitmapRep() {
+ virtual ~ImageRepSkia() {
STLDeleteElements(&bitmaps_);
}
@@ -107,19 +107,19 @@ class SkBitmapRep : public ImageRep {
private:
std::vector<const SkBitmap*> bitmaps_;
- DISALLOW_COPY_AND_ASSIGN(SkBitmapRep);
+ DISALLOW_COPY_AND_ASSIGN(ImageRepSkia);
};
#if defined(OS_LINUX)
-class GdkPixbufRep : public ImageRep {
+class ImageRepGdk : public ImageRep {
public:
- explicit GdkPixbufRep(GdkPixbuf* pixbuf)
- : ImageRep(Image::kGdkPixbufRep),
+ explicit ImageRepGdk(GdkPixbuf* pixbuf)
+ : ImageRep(Image::kImageRepGdk),
pixbuf_(pixbuf) {
CHECK(pixbuf);
}
- virtual ~GdkPixbufRep() {
+ virtual ~ImageRepGdk() {
if (pixbuf_) {
g_object_unref(pixbuf_);
pixbuf_ = NULL;
@@ -131,20 +131,20 @@ class GdkPixbufRep : public ImageRep {
private:
GdkPixbuf* pixbuf_;
- DISALLOW_COPY_AND_ASSIGN(GdkPixbufRep);
+ DISALLOW_COPY_AND_ASSIGN(ImageRepGdk);
};
#endif
#if defined(OS_MACOSX)
-class NSImageRep : public ImageRep {
+class ImageRepCocoa : public ImageRep {
public:
- explicit NSImageRep(NSImage* image)
- : ImageRep(Image::kNSImageRep),
+ explicit ImageRepCocoa(NSImage* image)
+ : ImageRep(Image::kImageRepCocoa),
image_(image) {
CHECK(image);
}
- virtual ~NSImageRep() {
+ virtual ~ImageRepCocoa() {
base::mac::NSObjectRelease(image_);
image_ = nil;
}
@@ -154,7 +154,7 @@ class NSImageRep : public ImageRep {
private:
NSImage* image_;
- DISALLOW_COPY_AND_ASSIGN(NSImageRep);
+ DISALLOW_COPY_AND_ASSIGN(ImageRepCocoa);
};
#endif
@@ -196,29 +196,29 @@ class ImageStorage : public base::RefCounted<ImageStorage> {
} // namespace internal
Image::Image(const SkBitmap* bitmap)
- : storage_(new internal::ImageStorage(Image::kSkBitmapRep)) {
- internal::SkBitmapRep* rep = new internal::SkBitmapRep(bitmap);
+ : storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
+ internal::ImageRepSkia* rep = new internal::ImageRepSkia(bitmap);
AddRepresentation(rep);
}
Image::Image(const std::vector<const SkBitmap*>& bitmaps)
- : storage_(new internal::ImageStorage(Image::kSkBitmapRep)) {
- internal::SkBitmapRep* rep = new internal::SkBitmapRep(bitmaps);
+ : storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
+ internal::ImageRepSkia* rep = new internal::ImageRepSkia(bitmaps);
AddRepresentation(rep);
}
#if defined(OS_LINUX)
Image::Image(GdkPixbuf* pixbuf)
- : storage_(new internal::ImageStorage(Image::kGdkPixbufRep)) {
- internal::GdkPixbufRep* rep = new internal::GdkPixbufRep(pixbuf);
+ : storage_(new internal::ImageStorage(Image::kImageRepGdk)) {
+ internal::ImageRepGdk* rep = new internal::ImageRepGdk(pixbuf);
AddRepresentation(rep);
}
#endif
#if defined(OS_MACOSX)
Image::Image(NSImage* image)
- : storage_(new internal::ImageStorage(Image::kNSImageRep)) {
- internal::NSImageRep* rep = new internal::NSImageRep(image);
+ : storage_(new internal::ImageStorage(Image::kImageRepCocoa)) {
+ internal::ImageRepCocoa* rep = new internal::ImageRepCocoa(image);
AddRepresentation(rep);
}
#endif
@@ -235,8 +235,8 @@ Image::~Image() {
}
Image::operator const SkBitmap*() const {
- internal::ImageRep* rep = GetRepresentation(Image::kSkBitmapRep);
- return rep->AsSkBitmapRep()->bitmap();
+ internal::ImageRep* rep = GetRepresentation(Image::kImageRepSkia);
+ return rep->AsImageRepSkia()->bitmap();
}
Image::operator const SkBitmap&() const {
@@ -245,15 +245,15 @@ Image::operator const SkBitmap&() const {
#if defined(OS_LINUX)
Image::operator GdkPixbuf*() const {
- internal::ImageRep* rep = GetRepresentation(Image::kGdkPixbufRep);
- return rep->AsGdkPixbufRep()->pixbuf();
+ internal::ImageRep* rep = GetRepresentation(Image::kImageRepGdk);
+ return rep->AsImageRepGdk()->pixbuf();
}
#endif
#if defined(OS_MACOSX)
Image::operator NSImage*() const {
- internal::ImageRep* rep = GetRepresentation(Image::kNSImageRep);
- return rep->AsNSImageRep()->image();
+ internal::ImageRep* rep = GetRepresentation(Image::kImageRepCocoa);
+ return rep->AsImageRepCocoa()->image();
}
#endif
@@ -293,20 +293,20 @@ internal::ImageRep* Image::GetRepresentation(
// from the default rep.
// Handle native-to-Skia conversion.
- if (rep_type == Image::kSkBitmapRep) {
- internal::SkBitmapRep* rep = NULL;
+ if (rep_type == Image::kImageRepSkia) {
+ internal::ImageRepSkia* rep = NULL;
#if defined(OS_LINUX)
- if (storage_->default_representation_type() == Image::kGdkPixbufRep) {
- internal::GdkPixbufRep* pixbuf_rep = default_rep->AsGdkPixbufRep();
- rep = new internal::SkBitmapRep(
+ if (storage_->default_representation_type() == Image::kImageRepGdk) {
+ internal::ImageRepGdk* pixbuf_rep = default_rep->AsImageRepGdk();
+ rep = new internal::ImageRepSkia(
internal::GdkPixbufToSkBitmap(pixbuf_rep->pixbuf()));
}
#elif defined(OS_MACOSX)
- if (storage_->default_representation_type() == Image::kNSImageRep) {
- internal::NSImageRep* nsimage_rep = default_rep->AsNSImageRep();
+ if (storage_->default_representation_type() == Image::kImageRepCocoa) {
+ internal::ImageRepCocoa* nsimage_rep = default_rep->AsImageRepCocoa();
std::vector<const SkBitmap*> bitmaps;
CHECK(internal::NSImageToSkBitmaps(nsimage_rep->image(), &bitmaps));
- rep = new internal::SkBitmapRep(bitmaps);
+ rep = new internal::ImageRepSkia(bitmaps);
}
#endif
CHECK(rep);
@@ -315,19 +315,19 @@ internal::ImageRep* Image::GetRepresentation(
}
// Handle Skia-to-native conversions.
- if (default_rep->type() == Image::kSkBitmapRep) {
- internal::SkBitmapRep* skia_rep = default_rep->AsSkBitmapRep();
+ if (default_rep->type() == Image::kImageRepSkia) {
+ internal::ImageRepSkia* skia_rep = default_rep->AsImageRepSkia();
internal::ImageRep* native_rep = NULL;
#if defined(OS_LINUX)
- if (rep_type == Image::kGdkPixbufRep) {
+ if (rep_type == Image::kImageRepGdk) {
GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(skia_rep->bitmap());
- native_rep = new internal::GdkPixbufRep(pixbuf);
+ native_rep = new internal::ImageRepGdk(pixbuf);
}
#elif defined(OS_MACOSX)
- if (rep_type == Image::kNSImageRep) {
+ if (rep_type == Image::kImageRepCocoa) {
NSImage* image = gfx::SkBitmapsToNSImage(skia_rep->bitmaps());
base::mac::NSObjectRetain(image);
- native_rep = new internal::NSImageRep(image);
+ native_rep = new internal::ImageRepCocoa(image);
}
#endif
CHECK(native_rep);
@@ -344,12 +344,12 @@ void Image::AddRepresentation(internal::ImageRep* rep) const {
}
size_t Image::GetNumberOfSkBitmaps() const {
- return GetRepresentation(Image::kSkBitmapRep)->AsSkBitmapRep()->
+ return GetRepresentation(Image::kImageRepSkia)->AsImageRepSkia()->
bitmaps().size();
}
const SkBitmap* Image::GetSkBitmapAtIndex(size_t index) const {
- return GetRepresentation(Image::kSkBitmapRep)->AsSkBitmapRep()->
+ return GetRepresentation(Image::kImageRepSkia)->AsImageRepSkia()->
bitmaps()[index];
}
diff --git a/ui/gfx/image.h b/ui/gfx/image.h
index 875cbf1..df088fe 100644
--- a/ui/gfx/image.h
+++ b/ui/gfx/image.h
@@ -43,9 +43,9 @@ class ImageStorage;
class Image {
public:
enum RepresentationType {
- kGdkPixbufRep,
- kNSImageRep,
- kSkBitmapRep,
+ kImageRepGdk,
+ kImageRepCocoa,
+ kImageRepSkia,
};
typedef std::map<RepresentationType, internal::ImageRep*> RepresentationMap;
diff --git a/ui/gfx/image_unittest.cc b/ui/gfx/image_unittest.cc
index aba1ed6..b617efd 100644
--- a/ui/gfx/image_unittest.cc
+++ b/ui/gfx/image_unittest.cc
@@ -42,7 +42,7 @@ TEST_F(ImageTest, SkiaToSkia) {
EXPECT_FALSE(bitmap->isNull());
EXPECT_EQ(1U, image.RepresentationCount());
- EXPECT_TRUE(image.HasRepresentation(gfx::Image::kSkBitmapRep));
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia));
if (!kUsesSkiaNatively)
EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
}
@@ -58,7 +58,7 @@ TEST_F(ImageTest, SkiaToSkiaRef) {
EXPECT_FALSE(bitmap1->isNull());
EXPECT_EQ(1U, image.RepresentationCount());
- EXPECT_TRUE(image.HasRepresentation(gfx::Image::kSkBitmapRep));
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia));
if (!kUsesSkiaNatively)
EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
}
@@ -67,7 +67,7 @@ TEST_F(ImageTest, SkiaToPlatform) {
gfx::Image image(gt::CreateBitmap(25, 25));
const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U;
- EXPECT_TRUE(image.HasRepresentation(gfx::Image::kSkBitmapRep));
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia));
if (!kUsesSkiaNatively)
EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
@@ -78,7 +78,7 @@ TEST_F(ImageTest, SkiaToPlatform) {
EXPECT_FALSE(bitmap.isNull());
EXPECT_EQ(kRepCount, image.RepresentationCount());
- EXPECT_TRUE(image.HasRepresentation(gfx::Image::kSkBitmapRep));
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia));
EXPECT_TRUE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
}
@@ -88,7 +88,7 @@ TEST_F(ImageTest, PlatformToSkia) {
EXPECT_TRUE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
if (!kUsesSkiaNatively)
- EXPECT_FALSE(image.HasRepresentation(gfx::Image::kSkBitmapRep));
+ EXPECT_FALSE(image.HasRepresentation(gfx::Image::kImageRepSkia));
const SkBitmap* bitmap = static_cast<const SkBitmap*>(image);
EXPECT_TRUE(bitmap);
@@ -98,7 +98,7 @@ TEST_F(ImageTest, PlatformToSkia) {
EXPECT_TRUE(static_cast<gt::PlatformImage>(image));
EXPECT_EQ(kRepCount, image.RepresentationCount());
- EXPECT_TRUE(image.HasRepresentation(gfx::Image::kSkBitmapRep));
+ EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia));
}
TEST_F(ImageTest, PlatformToPlatform) {
@@ -112,7 +112,7 @@ TEST_F(ImageTest, PlatformToPlatform) {
EXPECT_TRUE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
if (!kUsesSkiaNatively)
- EXPECT_FALSE(image.HasRepresentation(gfx::Image::kSkBitmapRep));
+ EXPECT_FALSE(image.HasRepresentation(gfx::Image::kImageRepSkia));
}
TEST_F(ImageTest, CheckSkiaColor) {
diff --git a/ui/gfx/image_unittest_util.cc b/ui/gfx/image_unittest_util.cc
index b996a86..bb1265b 100644
--- a/ui/gfx/image_unittest_util.cc
+++ b/ui/gfx/image_unittest_util.cc
@@ -43,11 +43,11 @@ PlatformImage CreatePlatformImage() {
gfx::Image::RepresentationType GetPlatformRepresentationType() {
#if defined(OS_MACOSX)
- return gfx::Image::kNSImageRep;
+ return gfx::Image::kImageRepCocoa;
#elif defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
- return gfx::Image::kGdkPixbufRep;
+ return gfx::Image::kImageRepGdk;
#else
- return gfx::Image::kSkBitmapRep;
+ return gfx::Image::kImageRepSkia;
#endif
}