Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ui / gfx / image / image_skia_rep.cc
blob005b9a3f54b5f1743828cc34429fb5849d957613
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"
7 namespace gfx {
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)
28 : bitmap_(src),
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_);
46 } // namespace gfx