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

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

Issue 24262008: Revert 224473 "Remove dependency on ui::ScaleFactor from ui/gfx" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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
« no previous file with comments | « trunk/src/ui/gfx/image/image_skia_rep.h ('k') | trunk/src/ui/gfx/image/image_skia_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 namespace gfx { 7 namespace gfx {
8 8
9 ImageSkiaRep::ImageSkiaRep() : scale_(1.0f) { 9 ImageSkiaRep::ImageSkiaRep()
10 : scale_factor_(ui::SCALE_FACTOR_NONE) {
10 } 11 }
11 12
12 ImageSkiaRep::~ImageSkiaRep() { 13 ImageSkiaRep::~ImageSkiaRep() {
13 } 14 }
14 15
15 ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale) : scale_(scale) { 16 ImageSkiaRep::ImageSkiaRep(const gfx::Size& size,
17 ui::ScaleFactor scale_factor)
18 : scale_factor_(scale_factor) {
19 float scale = ui::GetScaleFactorScale(scale_factor);
16 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 20 bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
17 static_cast<int>(size.width() * scale), 21 static_cast<int>(size.width() * scale),
18 static_cast<int>(size.height() * scale)); 22 static_cast<int>(size.height() * scale));
19 bitmap_.allocPixels(); 23 bitmap_.allocPixels();
20 } 24 }
21 25
22 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, float scale) 26 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src,
27 ui::ScaleFactor scale_factor)
23 : bitmap_(src), 28 : bitmap_(src),
24 scale_(scale) { 29 scale_factor_(scale_factor) {
25 } 30 }
26 31
27 int ImageSkiaRep::GetWidth() const { 32 int ImageSkiaRep::GetWidth() const {
28 return static_cast<int>(bitmap_.width() / scale_); 33 return static_cast<int>(bitmap_.width() /
34 ui::GetScaleFactorScale(scale_factor_));
29 } 35 }
30 36
31 int ImageSkiaRep::GetHeight() const { 37 int ImageSkiaRep::GetHeight() const {
32 return static_cast<int>(bitmap_.height() / scale_); 38 return static_cast<int>(bitmap_.height() /
39 ui::GetScaleFactorScale(scale_factor_));
40 }
41
42 float ImageSkiaRep::GetScale() const {
43 return ui::GetScaleFactorScale(scale_factor_);
33 } 44 }
34 45
35 } // namespace gfx 46 } // namespace gfx
OLDNEW
« no previous file with comments | « trunk/src/ui/gfx/image/image_skia_rep.h ('k') | trunk/src/ui/gfx/image/image_skia_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698