| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 ui::ScaleFactor scale_factor) const; | 90 ui::ScaleFactor scale_factor) const; |
| 91 | 91 |
| 92 #if defined(OS_MACOSX) | 92 #if defined(OS_MACOSX) |
| 93 // Returns the image reps contained by this object. | 93 // Returns the image reps contained by this object. |
| 94 // If the image has a source, this method will attempt to generate | 94 // If the image has a source, this method will attempt to generate |
| 95 // representations from the source for all supported scale factors. | 95 // representations from the source for all supported scale factors. |
| 96 // Mac only for now. | 96 // Mac only for now. |
| 97 std::vector<ImageSkiaRep> GetRepresentations() const; | 97 std::vector<ImageSkiaRep> GetRepresentations() const; |
| 98 #endif // OS_MACOSX | 98 #endif // OS_MACOSX |
| 99 | 99 |
| 100 // Returns true if object is null or its size is empty. | |
| 101 bool empty() const; | |
| 102 | |
| 103 // Returns true if this is a null object. | 100 // Returns true if this is a null object. |
| 104 // TODO(pkotwicz): Merge this function into empty(). | 101 // TODO(pkotwicz): Merge this function into empty(). |
| 105 bool isNull() const { return storage_ == NULL; } | 102 bool isNull() const { return storage_ == NULL; } |
| 106 | 103 |
| 107 // Width and height of image in DIP coordinate system. | 104 // Width and height of image in DIP coordinate system. |
| 108 int width() const; | 105 int width() const; |
| 109 int height() const; | 106 int height() const; |
| 110 gfx::Size size() const; | 107 gfx::Size size() const; |
| 111 | 108 |
| 112 // Wrapper function for SkBitmap::extractBitmap. | |
| 113 // Deprecated, use ImageSkiaOperations::ExtractSubset instead. | |
| 114 // TODO(pkotwicz): Remove this function. | |
| 115 bool extractSubset(ImageSkia* dst, const SkIRect& subset) const; | |
| 116 | |
| 117 // Returns pointer to 1x bitmap contained by this object. If there is no 1x | 109 // Returns pointer to 1x bitmap contained by this object. If there is no 1x |
| 118 // bitmap, the bitmap whose scale factor is closest to 1x is returned. | 110 // bitmap, the bitmap whose scale factor is closest to 1x is returned. |
| 119 // This function should only be used in unittests and on platforms which do | 111 // This function should only be used in unittests and on platforms which do |
| 120 // not support scale factors other than 1x. | 112 // not support scale factors other than 1x. |
| 121 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap. | 113 // TODO(pkotwicz): Return null SkBitmap when the object has no 1x bitmap. |
| 122 const SkBitmap* bitmap() const { return &GetBitmap(); } | 114 const SkBitmap* bitmap() const { return &GetBitmap(); } |
| 123 | 115 |
| 124 // Returns a vector with the image reps contained in this object. | 116 // Returns a vector with the image reps contained in this object. |
| 125 // 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 |
| 126 // supported scale factors. | 118 // supported scale factors. |
| 127 // 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 |
| 128 // when source is used. | 120 // when source is used. |
| 129 std::vector<gfx::ImageSkiaRep> image_reps() const; | 121 std::vector<gfx::ImageSkiaRep> image_reps() const; |
| 130 | 122 |
| 131 private: | 123 private: |
| 132 // Initialize ImageSkiaStorage with passed in parameters. | 124 // Initialize ImageSkiaStorage with passed in parameters. |
| 133 // 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. |
| 134 void Init(const gfx::ImageSkiaRep& image_rep); | 126 void Init(const gfx::ImageSkiaRep& image_rep); |
| 135 | 127 |
| 136 SkBitmap& GetBitmap() const; | 128 SkBitmap& GetBitmap() const; |
| 137 | 129 |
| 138 // A refptr so that ImageRepSkia can be copied cheaply. | 130 // A refptr so that ImageRepSkia can be copied cheaply. |
| 139 scoped_refptr<internal::ImageSkiaStorage> storage_; | 131 scoped_refptr<internal::ImageSkiaStorage> storage_; |
| 140 }; | 132 }; |
| 141 | 133 |
| 142 } // namespace gfx | 134 } // namespace gfx |
| 143 | 135 |
| 144 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ | 136 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ |
| OLD | NEW |