| Index: ui/gfx/image/image.cc
|
| diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
|
| index afce7d8bdedc0a95869600fa9568c993b943bca4..38df8d163cae053acbf213bdc1c7ecbfeed0ca38 100644
|
| --- a/ui/gfx/image/image.cc
|
| +++ b/ui/gfx/image/image.cc
|
| @@ -7,8 +7,9 @@
|
| #include <algorithm>
|
|
|
| #include "base/logging.h"
|
| -#include "base/stl_util.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| +#include "ui/gfx/image/image_skia.h"
|
| #include "ui/gfx/size.h"
|
|
|
| #if defined(TOOLKIT_GTK)
|
| @@ -96,31 +97,18 @@ class ImageRep {
|
|
|
| class ImageRepSkia : public ImageRep {
|
| public:
|
| - explicit ImageRepSkia(const SkBitmap* bitmap)
|
| - : ImageRep(Image::kImageRepSkia) {
|
| - CHECK(bitmap);
|
| - // TODO(rohitrao): Add a CHECK to ensure that !bitmap->isNull().
|
| - bitmaps_.push_back(bitmap);
|
| - }
|
| -
|
| - explicit ImageRepSkia(const std::vector<const SkBitmap*>& bitmaps)
|
| + explicit ImageRepSkia(ImageSkia* image)
|
| : ImageRep(Image::kImageRepSkia),
|
| - bitmaps_(bitmaps) {
|
| - CHECK(!bitmaps_.empty());
|
| - // TODO(rohitrao): Add a CHECK to ensure that !bitmap->isNull() for each
|
| - // vector element.
|
| + image_(image) {
|
| }
|
|
|
| virtual ~ImageRepSkia() {
|
| - STLDeleteElements(&bitmaps_);
|
| }
|
|
|
| - const SkBitmap* bitmap() const { return bitmaps_[0]; }
|
| -
|
| - const std::vector<const SkBitmap*>& bitmaps() const { return bitmaps_; }
|
| + ImageSkia* image() { return image_.get(); }
|
|
|
| private:
|
| - std::vector<const SkBitmap*> bitmaps_;
|
| + scoped_ptr<ImageSkia> image_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ImageRepSkia);
|
| };
|
| @@ -238,20 +226,22 @@ Image::Image() {
|
|
|
| Image::Image(const SkBitmap* bitmap)
|
| : storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
|
| - internal::ImageRepSkia* rep = new internal::ImageRepSkia(bitmap);
|
| + internal::ImageRepSkia* rep = new internal::ImageRepSkia(
|
| + new ImageSkia(bitmap));
|
| AddRepresentation(rep);
|
| }
|
|
|
| Image::Image(const SkBitmap& bitmap)
|
| : storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
|
| internal::ImageRepSkia* rep =
|
| - new internal::ImageRepSkia(new SkBitmap(bitmap));
|
| + new internal::ImageRepSkia(new ImageSkia(new SkBitmap(bitmap)));
|
| AddRepresentation(rep);
|
| }
|
|
|
| Image::Image(const std::vector<const SkBitmap*>& bitmaps)
|
| : storage_(new internal::ImageStorage(Image::kImageRepSkia)) {
|
| - internal::ImageRepSkia* rep = new internal::ImageRepSkia(bitmaps);
|
| + internal::ImageRepSkia* rep = new internal::ImageRepSkia(
|
| + new ImageSkia(bitmaps));
|
| AddRepresentation(rep);
|
| }
|
|
|
| @@ -284,7 +274,12 @@ Image::~Image() {
|
|
|
| const SkBitmap* Image::ToSkBitmap() const {
|
| internal::ImageRep* rep = GetRepresentation(Image::kImageRepSkia);
|
| - return rep->AsImageRepSkia()->bitmap();
|
| + return rep->AsImageRepSkia()->image()->bitmap();
|
| +}
|
| +
|
| +const ImageSkia* Image::ToImageSkia() const {
|
| + internal::ImageRep* rep = GetRepresentation(Image::kImageRepSkia);
|
| + return rep->AsImageRepSkia()->image();
|
| }
|
|
|
| #if defined(TOOLKIT_GTK)
|
| @@ -447,14 +442,4 @@ void Image::AddRepresentation(internal::ImageRep* rep) const {
|
| storage_->representations().insert(std::make_pair(rep->type(), rep));
|
| }
|
|
|
| -size_t Image::GetNumberOfSkBitmaps() const {
|
| - return GetRepresentation(Image::kImageRepSkia)->AsImageRepSkia()->
|
| - bitmaps().size();
|
| -}
|
| -
|
| -const SkBitmap* Image::GetSkBitmapAtIndex(size_t index) const {
|
| - return GetRepresentation(Image::kImageRepSkia)->AsImageRepSkia()->
|
| - bitmaps()[index];
|
| -}
|
| -
|
| } // namespace gfx
|
|
|