Chromium Code Reviews| Index: ui/gfx/image/image_skia.h |
| diff --git a/ui/gfx/image/image_skia.h b/ui/gfx/image/image_skia.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0606f49c6c77de10fd1609b569961007392e651b |
| --- /dev/null |
| +++ b/ui/gfx/image/image_skia.h |
| @@ -0,0 +1,57 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_GFX_IMAGE_IMAGE_SKIA_H_ |
| +#define UI_GFX_IMAGE_IMAGE_SKIA_H_ |
| +#pragma once |
| + |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| +#include "ui/gfx/size.h" |
| + |
| +// Container for images at various densities. |
|
Robert Sesek
2012/04/16 16:06:01
This should be filled out more (use cases, should
|
| +// Smallest image is assumed to represent 1x density. |
| +namespace gfx { |
| + |
| +class UI_EXPORT ImageSkia { |
| + public: |
| + ImageSkia(const SkBitmap* bitmap); |
|
Robert Sesek
2012/04/16 16:06:01
explicit?
|
| + ImageSkia(const std::vector<const SkBitmap*>& bitmaps); |
| + virtual ~ImageSkia(); |
| + |
| + // Returns the bitmap whose density best matches |device_scale_factor|. |
| + const SkBitmap* GetBitmapForScaleFactor(float device_scale_factor) const; |
| + |
| + // Gets the number of bitmaps in this image. |
| + size_t GetNumberOfBitmaps() const { return bitmaps_.size(); } |
|
Robert Sesek
2012/04/16 16:06:01
Out-of-line.
|
| + |
| + // Gets the bitmap at the given index. |
| + const SkBitmap* GetBitmapAtIndex(size_t index) const { |
| + return bitmaps_[index]; |
|
Robert Sesek
2012/04/16 16:06:01
Out-of-line.
|
| + } |
| + |
| + // Returns true if the smallest bitmap is empty. |
| + bool empty() const { return size_.IsEmpty(); } |
|
Robert Sesek
2012/04/16 16:06:01
This is unclear and confounds IsEmpty() in image.h
|
| + |
| + // Returns true if the object contains no bitmaps. |
| + bool isNull() const { return bitmaps_.empty(); }; |
|
Robert Sesek
2012/04/16 16:06:01
Naming: IsEmpty() to be consistent with image.h. O
|
| + |
| + // Width and height of image in DIP coordinate system. |
| + int width() const { return size_.width(); } |
| + int height() const { return size_.height(); } |
| + |
| + const SkBitmap* bitmap() { return bitmaps_[0]; } |
|
Robert Sesek
2012/04/16 16:06:01
Needs a comment.
|
| + |
| +private: |
| + std::vector<const SkBitmap*> bitmaps_; |
| + gfx::Size size_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ImageSkia); |
| +}; |
| + |
| +} // namespace gfx |
| + |
| +#endif // UI_GFX_IMAGE_IMAGE_SKIA_H_ |