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

Unified Diff: ui/gfx/image/image_skia_rep.cc

Issue 277773002: Add ImageSkiaRep::unscaled that tells if the image is for unscaled image. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« no previous file with comments | « ui/gfx/image/image_skia_rep.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image/image_skia_rep.cc
diff --git a/ui/gfx/image/image_skia_rep.cc b/ui/gfx/image/image_skia_rep.cc
index f8f3acb19468e0ff8a295880d136734f11a7bfce..aeb027f17d66c3876d3ec82cdfecdd670d905ff8 100644
--- a/ui/gfx/image/image_skia_rep.cc
+++ b/ui/gfx/image/image_skia_rep.cc
@@ -4,9 +4,11 @@
#include "ui/gfx/image/image_skia_rep.h"
+#include "base/logging.h"
+
namespace gfx {
-ImageSkiaRep::ImageSkiaRep() : scale_(1.0f) {
+ImageSkiaRep::ImageSkiaRep() : scale_(0.0f) {
}
ImageSkiaRep::~ImageSkiaRep() {
@@ -14,8 +16,8 @@ ImageSkiaRep::~ImageSkiaRep() {
ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale) : scale_(scale) {
bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
- static_cast<int>(size.width() * scale),
- static_cast<int>(size.height() * scale));
+ static_cast<int>(size.width() * this->scale()),
+ static_cast<int>(size.height() * this->scale()));
bitmap_.allocPixels();
}
@@ -25,11 +27,17 @@ ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, float scale)
}
int ImageSkiaRep::GetWidth() const {
- return static_cast<int>(bitmap_.width() / scale_);
+ return static_cast<int>(bitmap_.width() / scale());
}
int ImageSkiaRep::GetHeight() const {
- return static_cast<int>(bitmap_.height() / scale_);
+ return static_cast<int>(bitmap_.height() / scale());
+}
+
+void ImageSkiaRep::SetScaled() {
+ DCHECK_EQ(0.0f, scale_);
+ if (scale_ == 0.0f)
+ scale_ = 1.0f;
}
} // namespace gfx
« no previous file with comments | « ui/gfx/image/image_skia_rep.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698