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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 operator SkBitmap&() const; | 66 operator SkBitmap&() const; |
67 | 67 |
68 ~ImageSkia(); | 68 ~ImageSkia(); |
69 | 69 |
70 // Adds |image_rep| to the image reps contained by this object. | 70 // Adds |image_rep| to the image reps contained by this object. |
71 void AddRepresentation(const gfx::ImageSkiaRep& image_rep); | 71 void AddRepresentation(const gfx::ImageSkiaRep& image_rep); |
72 | 72 |
73 // Removes the image rep of |scale_factor| if present. | 73 // Removes the image rep of |scale_factor| if present. |
74 void RemoveRepresentation(ui::ScaleFactor scale_factor); | 74 void RemoveRepresentation(ui::ScaleFactor scale_factor); |
75 | 75 |
76 // Returns true if the object owns a image rep whose density matches | 76 // Returns true if the object owns an image rep whose density matches |
77 // |scale_factor| exactly. | 77 // |scale_factor| exactly. |
78 bool HasRepresentation(ui::ScaleFactor scale_factor); | 78 bool HasRepresentation(ui::ScaleFactor scale_factor) const; |
79 | 79 |
80 // Returns the image rep whose density best matches | 80 // Returns the image rep whose density best matches |
81 // |scale_factor|. | 81 // |scale_factor|. |
82 // Returns a null image rep if the object contains no image reps. | 82 // Returns a null image rep if the object contains no image reps. |
83 const gfx::ImageSkiaRep& GetRepresentation( | 83 const gfx::ImageSkiaRep& GetRepresentation( |
84 ui::ScaleFactor scale_factor) const; | 84 ui::ScaleFactor scale_factor) const; |
85 | 85 |
| 86 // Returns the image reps contained by this object. |
| 87 // If the image has a source, this method will attempt to generate |
| 88 // representations from the source for all supported scale factors. |
| 89 std::vector<ImageSkiaRep> GetRepresentations() const; |
| 90 |
86 // Returns true if object is null or its size is empty. | 91 // Returns true if object is null or its size is empty. |
87 bool empty() const; | 92 bool empty() const; |
88 | 93 |
89 // Returns true if this is a null object. | 94 // Returns true if this is a null object. |
90 // TODO(pkotwicz): Merge this function into empty(). | 95 // TODO(pkotwicz): Merge this function into empty(). |
91 bool isNull() const { return storage_ == NULL; } | 96 bool isNull() const { return storage_ == NULL; } |
92 | 97 |
93 // Width and height of image in DIP coordinate system. | 98 // Width and height of image in DIP coordinate system. |
94 int width() const; | 99 int width() const; |
95 int height() const; | 100 int height() const; |
96 gfx::Size size() const; | 101 gfx::Size size() const; |
97 | 102 |
98 // Wrapper function for SkBitmap::extractBitmap. | |
99 // Operates on each stored image rep. Note that it may not have | 103 // Operates on each stored image rep. Note that it may not have |
100 // all image reps for supported scale factors. | 104 // all image reps for supported scale factors. |
101 // TODO(oshima|pkotwicz): Investigate if this can be eliminated | 105 // TODO(oshima|pkotwicz): Investigate if this can be eliminated |
102 // after ImageSkiaSource conversion. | 106 // after ImageSkiaSource conversion. |
103 bool extractSubset(ImageSkia* dst, const SkIRect& subset) const; | 107 bool extractSubset(ImageSkia* dst, const SkIRect& subset) const; |
104 | 108 |
105 // Returns pointer to an SkBitmap contained by this object. | 109 // Returns pointer to 1x bitmap contained by this object. If there is no 1x |
106 // TODO(pkotwicz): This is temporary till conversion to gfx::ImageSkia is | 110 // bitmap, the bitmap whose scale factor is closest to 1x is returned. |
107 // done. | 111 // This function should only be used in unittests and on platforms which do |
| 112 // not support scale factors other than 1x. |
| 113 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap. |
108 const SkBitmap* bitmap() const; | 114 const SkBitmap* bitmap() const; |
109 | 115 |
110 // Returns a vector with the image reps contained in this object. | 116 // Returns a vector with the image reps contained in this object. |
111 // There is no guarantee that this will return all images rep for | 117 // There is no guarantee that this will return all images rep for |
112 // supported scale factors. | 118 // supported scale factors. |
113 // TODO(oshima): Update all use of this API and make this to fail | 119 // TODO(oshima): Update all use of this API and make this to fail |
114 // when source is used. | 120 // when source is used. |
115 std::vector<gfx::ImageSkiaRep> image_reps() const; | 121 std::vector<gfx::ImageSkiaRep> image_reps() const; |
116 | 122 |
117 private: | 123 private: |
118 // Initialize ImageSkiaStorage with passed in parameters. | 124 // Initialize ImageSkiaStorage with passed in parameters. |
119 // If the image rep's bitmap is empty, ImageStorage is set to NULL. | 125 // If the image rep's bitmap is empty, ImageStorage is set to NULL. |
120 void Init(const gfx::ImageSkiaRep& image_rep); | 126 void Init(const gfx::ImageSkiaRep& image_rep); |
121 | 127 |
122 // A refptr so that ImageRepSkia can be copied cheaply. | 128 // A refptr so that ImageRepSkia can be copied cheaply. |
123 scoped_refptr<internal::ImageSkiaStorage> storage_; | 129 scoped_refptr<internal::ImageSkiaStorage> storage_; |
124 }; | 130 }; |
125 | 131 |
126 } // namespace gfx | 132 } // namespace gfx |
127 | 133 |
128 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ | 134 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ |
OLD | NEW |