Revert 82838 - Temporary change to test perf regression (full)This change tests which part of this review:http://codereview.chromium.org/6897013/is causing a performance regression. This change will be reverted later tonight.
[email protected]
Review URL: http://codereview.chromium.org/6895050

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82856 0039d316-1c4b-4281-b951-d872f2087c98
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 @@
 #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 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 @@
   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 @@
 #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 @@
     }
 #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 @@
   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