| 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 #ifndef UI_GFX_IMAGE_IMAGE_SKIA_H_ | 5 #ifndef UI_GFX_IMAGE_IMAGE_SKIA_H_ |
| 6 #define UI_GFX_IMAGE_IMAGE_SKIA_H_ | 6 #define UI_GFX_IMAGE_IMAGE_SKIA_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // ImageSkia is cheap to copy and intentionally supports copy semantics. | 30 // ImageSkia is cheap to copy and intentionally supports copy semantics. |
| 31 class UI_EXPORT ImageSkia { | 31 class UI_EXPORT ImageSkia { |
| 32 public: | 32 public: |
| 33 typedef std::vector<ImageSkiaRep> ImageSkiaReps; | 33 typedef std::vector<ImageSkiaRep> ImageSkiaReps; |
| 34 | 34 |
| 35 // Creates an instance with no bitmaps. | 35 // Creates an instance with no bitmaps. |
| 36 ImageSkia(); | 36 ImageSkia(); |
| 37 | 37 |
| 38 // Creates an instance that will use the |source| to get the image | 38 // Creates an instance that will use the |source| to get the image |
| 39 // for scale factors. |size| specifes the size of the image in DIP. | 39 // for scale factors. |size| specifes the size of the image in DIP. |
| 40 // ImageSkia owns |source|. |
| 40 ImageSkia(ImageSkiaSource* source, const gfx::Size& size); | 41 ImageSkia(ImageSkiaSource* source, const gfx::Size& size); |
| 41 | 42 |
| 42 // Adds ref to passed in bitmap. | 43 // Adds ref to passed in bitmap. |
| 43 // DIP width and height are set based on scale factor of 1x. | 44 // DIP width and height are set based on scale factor of 1x. |
| 44 // TODO(pkotwicz): This is temporary till conversion to gfx::ImageSkia is | 45 // TODO(pkotwicz): This is temporary till conversion to gfx::ImageSkia is |
| 45 // done. | 46 // done. |
| 46 ImageSkia(const SkBitmap& bitmap); | 47 ImageSkia(const SkBitmap& bitmap); |
| 47 | 48 |
| 48 ImageSkia(const gfx::ImageSkiaRep& image_rep); | 49 ImageSkia(const gfx::ImageSkiaRep& image_rep); |
| 49 | 50 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap. | 114 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap. |
| 114 const SkBitmap* bitmap() const { return &GetBitmap(); } | 115 const SkBitmap* bitmap() const { return &GetBitmap(); } |
| 115 | 116 |
| 116 // Returns a vector with the image reps contained in this object. | 117 // Returns a vector with the image reps contained in this object. |
| 117 // There is no guarantee that this will return all images rep for | 118 // There is no guarantee that this will return all images rep for |
| 118 // supported scale factors. | 119 // supported scale factors. |
| 119 // TODO(oshima): Update all use of this API and make this to fail | 120 // TODO(oshima): Update all use of this API and make this to fail |
| 120 // when source is used. | 121 // when source is used. |
| 121 std::vector<gfx::ImageSkiaRep> image_reps() const; | 122 std::vector<gfx::ImageSkiaRep> image_reps() const; |
| 122 | 123 |
| 124 // Delete the ImageSkiaSource if any. It will make GetRepresentation |
| 125 // thread safe because it will no longer update the storage. |
| 126 void DeleteSource(); |
| 127 |
| 128 // When the soruce is available, generates all ImageReps for |
| 129 // supported scale factors. This method is defined as const as |
| 130 // the state change in the storage is agnostic to the caller. |
| 131 void EnsureRepsForSupportedScaleFactors() const; |
| 132 |
| 123 private: | 133 private: |
| 124 // Initialize ImageSkiaStorage with passed in parameters. | 134 // Initialize ImageSkiaStorage with passed in parameters. |
| 125 // If the image rep's bitmap is empty, ImageStorage is set to NULL. | 135 // If the image rep's bitmap is empty, ImageStorage is set to NULL. |
| 126 void Init(const gfx::ImageSkiaRep& image_rep); | 136 void Init(const gfx::ImageSkiaRep& image_rep); |
| 127 | 137 |
| 128 SkBitmap& GetBitmap() const; | 138 SkBitmap& GetBitmap() const; |
| 129 | 139 |
| 130 // A refptr so that ImageRepSkia can be copied cheaply. | 140 // A refptr so that ImageRepSkia can be copied cheaply. |
| 131 scoped_refptr<internal::ImageSkiaStorage> storage_; | 141 scoped_refptr<internal::ImageSkiaStorage> storage_; |
| 132 }; | 142 }; |
| 133 | 143 |
| 134 } // namespace gfx | 144 } // namespace gfx |
| 135 | 145 |
| 136 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ | 146 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ |
| OLD | NEW |