summaryrefslogtreecommitdiffstats
path: root/ui/gfx/image.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/image.cc')
-rw-r--r--ui/gfx/image.cc45
1 files changed, 10 insertions, 35 deletions
diff --git a/ui/gfx/image.cc b/ui/gfx/image.cc
index 23edd96..9395279 100644
--- a/ui/gfx/image.cc
+++ b/ui/gfx/image.cc
@@ -7,7 +7,6 @@
#include <algorithm>
#include "base/logging.h"
-#include "base/stl_util-inl.h"
#include "third_party/skia/include/core/SkBitmap.h"
#if defined(OS_LINUX)
@@ -27,7 +26,7 @@ namespace internal {
#if defined(OS_MACOSX)
// This is a wrapper around gfx::NSImageToSkBitmap() because this cross-platform
// file cannot include the [square brackets] of ObjC.
-bool NSImageToSkBitmaps(NSImage* image, std::vector<const SkBitmap*>* bitmaps);
+const SkBitmap* NSImageToSkBitmap(NSImage* image);
#endif
#if defined(OS_LINUX)
@@ -85,27 +84,20 @@ class ImageRep {
class SkBitmapRep : public ImageRep {
public:
explicit SkBitmapRep(const SkBitmap* bitmap)
- : ImageRep(Image::kSkBitmapRep) {
- CHECK(bitmap);
- bitmaps_.push_back(bitmap);
- }
-
- explicit SkBitmapRep(const std::vector<const SkBitmap*>& bitmaps)
: ImageRep(Image::kSkBitmapRep),
- bitmaps_(bitmaps) {
- CHECK(!bitmaps_.empty());
+ bitmap_(bitmap) {
+ CHECK(bitmap);
}
virtual ~SkBitmapRep() {
- STLDeleteElements(&bitmaps_);
+ delete bitmap_;
+ bitmap_ = NULL;
}
- const SkBitmap* bitmap() const { return bitmaps_[0]; }
-
- const std::vector<const SkBitmap*>& bitmaps() const { return bitmaps_; }
+ const SkBitmap* bitmap() const { return bitmap_; }
private:
- std::vector<const SkBitmap*> bitmaps_;
+ const SkBitmap* bitmap_;
DISALLOW_COPY_AND_ASSIGN(SkBitmapRep);
};
@@ -201,12 +193,6 @@ Image::Image(const SkBitmap* bitmap)
AddRepresentation(rep);
}
-Image::Image(const std::vector<const SkBitmap*>& bitmaps)
- : storage_(new internal::ImageStorage(Image::kSkBitmapRep)) {
- internal::SkBitmapRep* rep = new internal::SkBitmapRep(bitmaps);
- AddRepresentation(rep);
-}
-
#if defined(OS_LINUX)
Image::Image(GdkPixbuf* pixbuf)
: storage_(new internal::ImageStorage(Image::kGdkPixbufRep)) {
@@ -303,9 +289,8 @@ internal::ImageRep* Image::GetRepresentation(RepresentationType rep_type) {
#elif defined(OS_MACOSX)
if (storage_->default_representation_type() == Image::kNSImageRep) {
internal::NSImageRep* nsimage_rep = default_rep->AsNSImageRep();
- std::vector<const SkBitmap*> bitmaps;
- CHECK(internal::NSImageToSkBitmaps(nsimage_rep->image(), &bitmaps));
- rep = new internal::SkBitmapRep(bitmaps);
+ rep = new internal::SkBitmapRep(
+ internal::NSImageToSkBitmap(nsimage_rep->image()));
}
#endif
CHECK(rep);
@@ -324,7 +309,7 @@ internal::ImageRep* Image::GetRepresentation(RepresentationType rep_type) {
}
#elif defined(OS_MACOSX)
if (rep_type == Image::kNSImageRep) {
- NSImage* image = gfx::SkBitmapsToNSImage(skia_rep->bitmaps());
+ NSImage* image = gfx::SkBitmapToNSImage(*(skia_rep->bitmap()));
base::mac::NSObjectRetain(image);
native_rep = new internal::NSImageRep(image);
}
@@ -342,14 +327,4 @@ void Image::AddRepresentation(internal::ImageRep* rep) {
storage_->representations().insert(std::make_pair(rep->type(), rep));
}
-size_t Image::GetNumberOfSkBitmaps() {
- return GetRepresentation(Image::kSkBitmapRep)->AsSkBitmapRep()->
- bitmaps().size();
-}
-
-const SkBitmap* Image::GetSkBitmapAtIndex(size_t index) {
- return GetRepresentation(Image::kSkBitmapRep)->AsSkBitmapRep()->
- bitmaps()[index];
-}
-
} // namespace gfx