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

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

Issue 10389109: Add gfx::Screen::IsEnabled() (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
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 float smallest_diff = std::numeric_limits<float>::max(); 140 float smallest_diff = std::numeric_limits<float>::max();
141 for (size_t i = 0; i < bitmaps.size(); ++i) { 141 for (size_t i = 0; i < bitmaps.size(); ++i) {
142 float diff = std::abs(bitmaps[i].width() - desired_width) + 142 float diff = std::abs(bitmaps[i].width() - desired_width) +
143 std::abs(bitmaps[i].height() - desired_height); 143 std::abs(bitmaps[i].height() - desired_height);
144 if (diff < smallest_diff) { 144 if (diff < smallest_diff) {
145 closest_index = i; 145 closest_index = i;
146 smallest_diff = diff; 146 smallest_diff = diff;
147 } 147 }
148 } 148 }
149 if (smallest_diff < std::numeric_limits<float>::max()) { 149 if (smallest_diff < std::numeric_limits<float>::max()) {
150 *bitmap_scale_factor = bitmaps[closest_index].width() / width(); 150 *bitmap_scale_factor = static_cast<float>(bitmaps[closest_index].width()) /
151 width();
151 return bitmaps[closest_index]; 152 return bitmaps[closest_index];
152 } 153 }
153 154
154 return *null_bitmap; 155 return *null_bitmap;
155 } 156 }
156 157
157 bool ImageSkia::empty() const { 158 bool ImageSkia::empty() const {
158 return isNull() || storage_->size().IsEmpty(); 159 return isNull() || storage_->size().IsEmpty();
159 } 160 }
160 161
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 storage_ = NULL; 199 storage_ = NULL;
199 return; 200 return;
200 } 201 }
201 storage_ = new internal::ImageSkiaStorage(); 202 storage_ = new internal::ImageSkiaStorage();
202 storage_->set_size(gfx::Size(static_cast<int>(bitmap.width() / scale_factor), 203 storage_->set_size(gfx::Size(static_cast<int>(bitmap.width() / scale_factor),
203 static_cast<int>(bitmap.height() / scale_factor))); 204 static_cast<int>(bitmap.height() / scale_factor)));
204 storage_->AddBitmap(bitmap); 205 storage_->AddBitmap(bitmap);
205 } 206 }
206 207
207 } // namespace gfx 208 } // namespace gfx
OLDNEW
« ui/base/resource/resource_bundle.cc ('K') | « ui/base/resource/resource_bundle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698