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.
5 #include "ui/gfx/image/image_skia_rep.h"
9 ImageSkiaRep::ImageSkiaRep()
10 : scale_factor_(ui::SCALE_FACTOR_NONE
) {
13 ImageSkiaRep::~ImageSkiaRep() {
16 ImageSkiaRep::ImageSkiaRep(const gfx::Size
& size
,
17 ui::ScaleFactor scale_factor
)
18 : scale_factor_(scale_factor
) {
19 float scale
= ui::GetScaleFactorScale(scale_factor
);
20 bitmap_
.setConfig(SkBitmap::kARGB_8888_Config
,
21 static_cast<int>(size
.width() * scale
),
22 static_cast<int>(size
.height() * scale
));
23 bitmap_
.allocPixels();
26 ImageSkiaRep::ImageSkiaRep(const SkBitmap
& src
,
27 ui::ScaleFactor scale_factor
)
29 scale_factor_(scale_factor
) {
32 int ImageSkiaRep::GetWidth() const {
33 return static_cast<int>(bitmap_
.width() /
34 ui::GetScaleFactorScale(scale_factor_
));
37 int ImageSkiaRep::GetHeight() const {
38 return static_cast<int>(bitmap_
.height() /
39 ui::GetScaleFactorScale(scale_factor_
));
42 float ImageSkiaRep::GetScale() const {
43 return ui::GetScaleFactorScale(scale_factor_
);