diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-04 01:29:28 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-04 01:29:28 +0000 |
commit | 15a2084decf18de467200317261d2d6c8d5e631b (patch) | |
tree | 0659326dad3c9ea9434c6b57c03e29ee2e663ce8 /ui | |
parent | 522b96de69a3a950ea0a47de76ae426d4451cb85 (diff) | |
download | chromium_src-15a2084decf18de467200317261d2d6c8d5e631b.zip chromium_src-15a2084decf18de467200317261d2d6c8d5e631b.tar.gz chromium_src-15a2084decf18de467200317261d2d6c8d5e631b.tar.bz2 |
Use gfx::Image in BrowserThemePack
This is a part of the work to switch the Mac build to use bitmaps instead of PDFs.
This change updates BrowserThemePack to cache images as gfx::Image instead of SkBitmap. This allows callers to get multi resolution images.
BUG=75812
TEST=Ran and verified that things looked ok.
Review URL: http://codereview.chromium.org/6904162
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/image.cc | 23 | ||||
-rw-r--r-- | ui/gfx/image.h | 22 |
2 files changed, 23 insertions, 22 deletions
diff --git a/ui/gfx/image.cc b/ui/gfx/image.cc index 23edd96..c6b22474 100644 --- a/ui/gfx/image.cc +++ b/ui/gfx/image.cc @@ -234,34 +234,34 @@ Image& Image::operator=(const Image& other) { Image::~Image() { } -Image::operator const SkBitmap*() { +Image::operator const SkBitmap*() const { internal::ImageRep* rep = GetRepresentation(Image::kSkBitmapRep); return rep->AsSkBitmapRep()->bitmap(); } -Image::operator const SkBitmap&() { +Image::operator const SkBitmap&() const { return *(this->operator const SkBitmap*()); } #if defined(OS_LINUX) -Image::operator GdkPixbuf*() { +Image::operator GdkPixbuf*() const { internal::ImageRep* rep = GetRepresentation(Image::kGdkPixbufRep); return rep->AsGdkPixbufRep()->pixbuf(); } #endif #if defined(OS_MACOSX) -Image::operator NSImage*() { +Image::operator NSImage*() const { internal::ImageRep* rep = GetRepresentation(Image::kNSImageRep); return rep->AsNSImageRep()->image(); } #endif -bool Image::HasRepresentation(RepresentationType type) { +bool Image::HasRepresentation(RepresentationType type) const { return storage_->representations().count(type) != 0; } -size_t Image::RepresentationCount() { +size_t Image::RepresentationCount() const { return storage_->representations().size(); } @@ -269,7 +269,7 @@ void Image::SwapRepresentations(gfx::Image* other) { storage_.swap(other->storage_); } -internal::ImageRep* Image::DefaultRepresentation() { +internal::ImageRep* Image::DefaultRepresentation() const { RepresentationMap& representations = storage_->representations(); RepresentationMap::iterator it = representations.find(storage_->default_representation_type()); @@ -277,7 +277,8 @@ internal::ImageRep* Image::DefaultRepresentation() { return it->second; } -internal::ImageRep* Image::GetRepresentation(RepresentationType rep_type) { +internal::ImageRep* Image::GetRepresentation( + RepresentationType rep_type) const { // If the requested rep is the default, return it. internal::ImageRep* default_rep = DefaultRepresentation(); if (rep_type == storage_->default_representation_type()) @@ -338,16 +339,16 @@ internal::ImageRep* Image::GetRepresentation(RepresentationType rep_type) { return NULL; } -void Image::AddRepresentation(internal::ImageRep* rep) { +void Image::AddRepresentation(internal::ImageRep* rep) const { storage_->representations().insert(std::make_pair(rep->type(), rep)); } -size_t Image::GetNumberOfSkBitmaps() { +size_t Image::GetNumberOfSkBitmaps() const { return GetRepresentation(Image::kSkBitmapRep)->AsSkBitmapRep()-> bitmaps().size(); } -const SkBitmap* Image::GetSkBitmapAtIndex(size_t index) { +const SkBitmap* Image::GetSkBitmapAtIndex(size_t index) const { return GetRepresentation(Image::kSkBitmapRep)->AsSkBitmapRep()-> bitmaps()[index]; } diff --git a/ui/gfx/image.h b/ui/gfx/image.h index ed9508f..875cbf1 100644 --- a/ui/gfx/image.h +++ b/ui/gfx/image.h @@ -79,43 +79,43 @@ class Image { ~Image(); // Conversion handlers. - operator const SkBitmap*(); - operator const SkBitmap&(); + operator const SkBitmap*() const ; + operator const SkBitmap&() const; #if defined(OS_LINUX) - operator GdkPixbuf*(); + operator GdkPixbuf*() const; #elif defined(OS_MACOSX) - operator NSImage*(); + operator NSImage*() const; #endif // Gets the number of bitmaps in this image. This may cause a conversion // to a bitmap representation. Note, this function and GetSkBitmapAtIndex() // are primarily meant to be used by the theme provider. - size_t GetNumberOfSkBitmaps(); + size_t GetNumberOfSkBitmaps() const; // Gets the bitmap at the given index. This may cause a conversion // to a bitmap representation. Note, the internal ordering of bitmaps is not // guaranteed. - const SkBitmap* GetSkBitmapAtIndex(size_t index); + const SkBitmap* GetSkBitmapAtIndex(size_t index) const; // Inspects the representations map to see if the given type exists. - bool HasRepresentation(RepresentationType type); + bool HasRepresentation(RepresentationType type) const; // Returns the number of representations. - size_t RepresentationCount(); + size_t RepresentationCount() const; // Swaps this image's internal representations with |other|. void SwapRepresentations(gfx::Image* other); private: // Returns the ImageRep for the default representation. - internal::ImageRep* DefaultRepresentation(); + internal::ImageRep* DefaultRepresentation() const; // Returns a ImageRep for the given representation type, converting and // caching if necessary. - internal::ImageRep* GetRepresentation(RepresentationType rep); + internal::ImageRep* GetRepresentation(RepresentationType rep) const; // Stores a representation into the map. - void AddRepresentation(internal::ImageRep* rep); + void AddRepresentation(internal::ImageRep* rep) const; // Internal class that holds all the representations. This allows the Image to // be cheaply copied. |