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

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

Issue 285393002: Fixes use-of-uninitialized-value MSan error in image_skia_unittest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 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') | no next file » | 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" 7 #include "base/logging.h"
8 8
9 namespace gfx { 9 namespace gfx {
10 10
11 ImageSkiaRep::ImageSkiaRep() : scale_(0.0f) { 11 ImageSkiaRep::ImageSkiaRep() : scale_(0.0f) {
12 } 12 }
13 13
14 ImageSkiaRep::~ImageSkiaRep() { 14 ImageSkiaRep::~ImageSkiaRep() {
15 } 15 }
16 16
17 ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale) : scale_(scale) { 17 ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale) : scale_(scale) {
18 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, 18 bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
19 static_cast<int>(size.width() * this->scale()), 19 static_cast<int>(size.width() * this->scale()),
20 static_cast<int>(size.height() * this->scale())); 20 static_cast<int>(size.height() * this->scale()));
21 bitmap_.allocPixels(); 21 bitmap_.allocPixels();
22 bitmap_.eraseColor(SK_ColorRED);
22 } 23 }
23 24
24 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, float scale) 25 ImageSkiaRep::ImageSkiaRep(const SkBitmap& src, float scale)
25 : bitmap_(src), 26 : bitmap_(src),
26 scale_(scale) { 27 scale_(scale) {
27 } 28 }
28 29
29 int ImageSkiaRep::GetWidth() const { 30 int ImageSkiaRep::GetWidth() const {
30 return static_cast<int>(bitmap_.width() / scale()); 31 return static_cast<int>(bitmap_.width() / scale());
31 } 32 }
32 33
33 int ImageSkiaRep::GetHeight() const { 34 int ImageSkiaRep::GetHeight() const {
34 return static_cast<int>(bitmap_.height() / scale()); 35 return static_cast<int>(bitmap_.height() / scale());
35 } 36 }
36 37
37 void ImageSkiaRep::SetScaled() { 38 void ImageSkiaRep::SetScaled() {
38 DCHECK_EQ(0.0f, scale_); 39 DCHECK_EQ(0.0f, scale_);
39 if (scale_ == 0.0f) 40 if (scale_ == 0.0f)
40 scale_ = 1.0f; 41 scale_ = 1.0f;
41 } 42 }
42 43
43 } // namespace gfx 44 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia_rep.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698