| 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 #include "ui/gfx/image/image_skia_rep.h" | 5 #include "ui/gfx/image/image_skia_rep.h" |
| 6 | 6 |
| 7 #include "base/logging.h" |
| 8 |
| 7 namespace gfx { | 9 namespace gfx { |
| 8 | 10 |
| 9 ImageSkiaRep::ImageSkiaRep() : scale_(1.0f) { | 11 ImageSkiaRep::ImageSkiaRep() : scale_(0.0f) { |
| 10 } | 12 } |
| 11 | 13 |
| 12 ImageSkiaRep::~ImageSkiaRep() { | 14 ImageSkiaRep::~ImageSkiaRep() { |
| 13 } | 15 } |
| 14 | 16 |
| 15 ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale) : scale_(scale) { | 17 ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale) : scale_(scale) { |
| 16 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, | 18 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, |
| 17 static_cast<int>(size.width() * scale), | 19 static_cast<int>(size.width() * this->scale()), |
| 18 static_cast<int>(size.height() * scale)); | 20 static_cast<int>(size.height() * this->scale())); |
| 19 bitmap_.allocPixels(); | 21 bitmap_.allocPixels(); |
| 20 } | 22 } |
| 21 | 23 |
| 22 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, float scale) | 24 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, float scale) |
| 23 : bitmap_(src), | 25 : bitmap_(src), |
| 24 scale_(scale) { | 26 scale_(scale) { |
| 25 } | 27 } |
| 26 | 28 |
| 27 int ImageSkiaRep::GetWidth() const { | 29 int ImageSkiaRep::GetWidth() const { |
| 28 return static_cast<int>(bitmap_.width() / scale_); | 30 return static_cast<int>(bitmap_.width() / scale()); |
| 29 } | 31 } |
| 30 | 32 |
| 31 int ImageSkiaRep::GetHeight() const { | 33 int ImageSkiaRep::GetHeight() const { |
| 32 return static_cast<int>(bitmap_.height() / scale_); | 34 return static_cast<int>(bitmap_.height() / scale()); |
| 35 } |
| 36 |
| 37 void ImageSkiaRep::SetScaled() { |
| 38 DCHECK_EQ(0.0f, scale_); |
| 39 if (scale_ == 0.0f) |
| 40 scale_ = 1.0f; |
| 33 } | 41 } |
| 34 | 42 |
| 35 } // namespace gfx | 43 } // namespace gfx |
| OLD | NEW |