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

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

Issue 10391179: Revert 137622 - Fix a couple of bugs with the image skia implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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/base/resource/resource_bundle.cc ('k') | ui/gfx/screen.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.h" 5 #include "ui/gfx/image/image_skia.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ImageSkia::~ImageSkia() { 84 ImageSkia::~ImageSkia() {
85 } 85 }
86 86
87 void ImageSkia::AddBitmapForScale(const SkBitmap& bitmap, 87 void ImageSkia::AddBitmapForScale(const SkBitmap& bitmap,
88 float dip_scale_factor) { 88 float dip_scale_factor) {
89 DCHECK(!bitmap.isNull()); 89 DCHECK(!bitmap.isNull());
90 90
91 if (isNull()) { 91 if (isNull()) {
92 Init(bitmap, dip_scale_factor); 92 Init(bitmap, dip_scale_factor);
93 } else { 93 } else {
94 // Currently data packs include 1x scale images whenever a different scale 94 // We currently assume that the bitmap size = 1x size * |dip_scale_factor|.
95 // image is unavailable. As |dip_scale_factor| is derived from the data 95 // TODO(pkotwicz): Do something better because of rounding errors when
96 // pack, sometimes |dip_scale_factor| is incorrect. 96 // |dip_scale_factor| is not an int.
97 // TODO(pkotwicz): Fix this and add DCHECK. 97 // TODO(pkotwicz): Remove DCHECK for dip_scale_factor == 1.0f once
98 // image_loading_tracker correctly handles multiple sized images.
99 DCHECK(dip_scale_factor == 1.0f ||
100 static_cast<int>(width() * dip_scale_factor) == bitmap.width());
101 DCHECK(dip_scale_factor == 1.0f ||
102 static_cast<int>(height() * dip_scale_factor) == bitmap.height());
98 storage_->AddBitmap(bitmap); 103 storage_->AddBitmap(bitmap);
99 } 104 }
100 } 105 }
101 106
102 const SkBitmap& ImageSkia::GetBitmapForScale(float x_scale_factor, 107 const SkBitmap& ImageSkia::GetBitmapForScale(float x_scale_factor,
103 float y_scale_factor, 108 float y_scale_factor,
104 float* bitmap_scale_factor) const { 109 float* bitmap_scale_factor) const {
105 110
106 if (empty()) 111 if (empty())
107 return *null_bitmap_; 112 return *null_bitmap_;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 storage_ = NULL; 183 storage_ = NULL;
179 return; 184 return;
180 } 185 }
181 storage_ = new internal::ImageSkiaStorage(); 186 storage_ = new internal::ImageSkiaStorage();
182 storage_->set_size(gfx::Size(static_cast<int>(bitmap.width() / scale_factor), 187 storage_->set_size(gfx::Size(static_cast<int>(bitmap.width() / scale_factor),
183 static_cast<int>(bitmap.height() / scale_factor))); 188 static_cast<int>(bitmap.height() / scale_factor)));
184 storage_->AddBitmap(bitmap); 189 storage_->AddBitmap(bitmap);
185 } 190 }
186 191
187 } // namespace gfx 192 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle.cc ('k') | ui/gfx/screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698