| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/image/image.h" | 5 #include "ui/gfx/image/image.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #if defined(OS_IOS) | 51 #if defined(OS_IOS) |
| 52 ImageSkia* ImageSkiaFromPNG( | 52 ImageSkia* ImageSkiaFromPNG( |
| 53 const std::vector<ImagePNGRep>& image_png_reps); | 53 const std::vector<ImagePNGRep>& image_png_reps); |
| 54 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromImageSkia( | 54 scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromImageSkia( |
| 55 const ImageSkia* skia); | 55 const ImageSkia* skia); |
| 56 #else | 56 #else |
| 57 // Returns a 16x16 red image to visually show error in decoding PNG. | 57 // Returns a 16x16 red image to visually show error in decoding PNG. |
| 58 // Caller takes ownership of returned ImageSkia. | 58 // Caller takes ownership of returned ImageSkia. |
| 59 ImageSkia* GetErrorImageSkia() { | 59 ImageSkia* GetErrorImageSkia() { |
| 60 SkBitmap bitmap; | 60 SkBitmap bitmap; |
| 61 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); | 61 bitmap.allocN32Pixels(16, 16); |
| 62 bitmap.allocPixels(); | |
| 63 bitmap.eraseARGB(0xff, 0xff, 0, 0); | 62 bitmap.eraseARGB(0xff, 0xff, 0, 0); |
| 64 return new ImageSkia(ImageSkiaRep(bitmap, 1.0f)); | 63 return new ImageSkia(ImageSkiaRep(bitmap, 1.0f)); |
| 65 } | 64 } |
| 66 | 65 |
| 67 class PNGImageSource : public ImageSkiaSource { | 66 class PNGImageSource : public ImageSkiaSource { |
| 68 public: | 67 public: |
| 69 PNGImageSource() {} | 68 PNGImageSource() {} |
| 70 virtual ~PNGImageSource() {} | 69 virtual ~PNGImageSource() {} |
| 71 | 70 |
| 72 virtual ImageSkiaRep GetImageForScale(float scale) OVERRIDE { | 71 virtual ImageSkiaRep GetImageForScale(float scale) OVERRIDE { |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } | 770 } |
| 772 return it->second; | 771 return it->second; |
| 773 } | 772 } |
| 774 | 773 |
| 775 void Image::AddRepresentation(internal::ImageRep* rep) const { | 774 void Image::AddRepresentation(internal::ImageRep* rep) const { |
| 776 CHECK(storage_.get()); | 775 CHECK(storage_.get()); |
| 777 storage_->representations().insert(std::make_pair(rep->type(), rep)); | 776 storage_->representations().insert(std::make_pair(rep->type(), rep)); |
| 778 } | 777 } |
| 779 | 778 |
| 780 } // namespace gfx | 779 } // namespace gfx |
| OLD | NEW |