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

Side by Side Diff: ui/gfx/image/image_skia_rep.cc

Issue 10694045: Loading/Creating images for mutiple scale factors on the fly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: size fix Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/gfx/size.h"
8
7 namespace gfx { 9 namespace gfx {
8 10
9 ImageSkiaRep::ImageSkiaRep() 11 ImageSkiaRep::ImageSkiaRep()
10 : scale_factor_(ui::SCALE_FACTOR_NONE) { 12 : scale_factor_(ui::SCALE_FACTOR_NONE) {
11 } 13 }
12 14
13 ImageSkiaRep::~ImageSkiaRep() { 15 ImageSkiaRep::~ImageSkiaRep() {
14 } 16 }
15 17
16 ImageSkiaRep::ImageSkiaRep(int width, int height, 18 ImageSkiaRep::ImageSkiaRep(const gfx::Size& size,
17 ui::ScaleFactor scale_factor) 19 ui::ScaleFactor scale_factor)
18 : scale_factor_(scale_factor) { 20 : scale_factor_(scale_factor) {
19 float scale = ui::GetScaleFactorScale(scale_factor); 21 float scale = ui::GetScaleFactorScale(scale_factor);
20 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 22 bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
21 static_cast<int>(width * scale), 23 static_cast<int>(size.width() * scale),
22 static_cast<int>(height * scale)); 24 static_cast<int>(size.height() * scale));
23 bitmap_.allocPixels(); 25 bitmap_.allocPixels();
24 } 26 }
25 27
26 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src) 28 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src)
27 : bitmap_(src), 29 : bitmap_(src),
28 scale_factor_(ui::SCALE_FACTOR_NONE) { 30 scale_factor_(ui::SCALE_FACTOR_NONE) {
29 } 31 }
30 32
31 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, 33 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src,
32 ui::ScaleFactor scale_factor) 34 ui::ScaleFactor scale_factor)
(...skipping 19 matching lines...) Expand all
52 int ImageSkiaRep::GetHeight() const { 54 int ImageSkiaRep::GetHeight() const {
53 return static_cast<int>(bitmap_.height() / 55 return static_cast<int>(bitmap_.height() /
54 ui::GetScaleFactorScale(scale_factor_)); 56 ui::GetScaleFactorScale(scale_factor_));
55 } 57 }
56 58
57 float ImageSkiaRep::GetScale() const { 59 float ImageSkiaRep::GetScale() const {
58 return ui::GetScaleFactorScale(scale_factor_); 60 return ui::GetScaleFactorScale(scale_factor_);
59 } 61 }
60 62
61 } // namespace gfx 63 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698