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

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

Issue 277773002: Add ImageSkiaRep::unscaled that tells if the image is for unscaled image. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « ui/gfx/image/image_skia_rep.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('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 #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
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia_rep.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698