Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Unified Diff: ui/gfx/image/image_skia.h

Issue 10086023: Expose array of bitmaps contained by gfx::Image similar to NSImage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698