OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_GFX_IMAGE_IMAGE_SKIA_H_ | |
6 #define UI_GFX_IMAGE_IMAGE_SKIA_H_ | |
7 #pragma once | |
8 | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "third_party/skia/include/core/SkBitmap.h" | |
13 #include "ui/gfx/size.h" | |
14 | |
15 // Container for images at various densities. | |
Robert Sesek
2012/04/16 16:06:01
This should be filled out more (use cases, should
| |
16 // Smallest image is assumed to represent 1x density. | |
17 namespace gfx { | |
18 | |
19 class UI_EXPORT ImageSkia { | |
20 public: | |
21 ImageSkia(const SkBitmap* bitmap); | |
Robert Sesek
2012/04/16 16:06:01
explicit?
| |
22 ImageSkia(const std::vector<const SkBitmap*>& bitmaps); | |
23 virtual ~ImageSkia(); | |
24 | |
25 // Returns the bitmap whose density best matches |device_scale_factor|. | |
26 const SkBitmap* GetBitmapForScaleFactor(float device_scale_factor) const; | |
27 | |
28 // Gets the number of bitmaps in this image. | |
29 size_t GetNumberOfBitmaps() const { return bitmaps_.size(); } | |
Robert Sesek
2012/04/16 16:06:01
Out-of-line.
| |
30 | |
31 // Gets the bitmap at the given index. | |
32 const SkBitmap* GetBitmapAtIndex(size_t index) const { | |
33 return bitmaps_[index]; | |
Robert Sesek
2012/04/16 16:06:01
Out-of-line.
| |
34 } | |
35 | |
36 // Returns true if the smallest bitmap is empty. | |
37 bool empty() const { return size_.IsEmpty(); } | |
Robert Sesek
2012/04/16 16:06:01
This is unclear and confounds IsEmpty() in image.h
| |
38 | |
39 // Returns true if the object contains no bitmaps. | |
40 bool isNull() const { return bitmaps_.empty(); }; | |
Robert Sesek
2012/04/16 16:06:01
Naming: IsEmpty() to be consistent with image.h. O
| |
41 | |
42 // Width and height of image in DIP coordinate system. | |
43 int width() const { return size_.width(); } | |
44 int height() const { return size_.height(); } | |
45 | |
46 const SkBitmap* bitmap() { return bitmaps_[0]; } | |
Robert Sesek
2012/04/16 16:06:01
Needs a comment.
| |
47 | |
48 private: | |
49 std::vector<const SkBitmap*> bitmaps_; | |
50 gfx::Size size_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(ImageSkia); | |
53 }; | |
54 | |
55 } // namespace gfx | |
56 | |
57 #endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ | |
OLD | NEW |