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

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

Issue 10824359: Remove ImageSkia::empty and ImageSkia::extractSubset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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.h ('k') | ui/gfx/image/image_skia_util_mac.mm » ('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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 std::vector<ui::ScaleFactor> supported_scale_factors = 230 std::vector<ui::ScaleFactor> supported_scale_factors =
231 ui::GetSupportedScaleFactors(); 231 ui::GetSupportedScaleFactors();
232 for (size_t i = 0; i < supported_scale_factors.size(); ++i) 232 for (size_t i = 0; i < supported_scale_factors.size(); ++i)
233 storage_->FindRepresentation(supported_scale_factors[i], true); 233 storage_->FindRepresentation(supported_scale_factors[i], true);
234 234
235 return image_reps(); 235 return image_reps();
236 } 236 }
237 237
238 #endif // OS_MACOSX 238 #endif // OS_MACOSX
239 239
240 bool ImageSkia::empty() const {
241 return isNull() || storage_->size().IsEmpty();
242 }
243
244 int ImageSkia::width() const { 240 int ImageSkia::width() const {
245 return isNull() ? 0 : storage_->size().width(); 241 return isNull() ? 0 : storage_->size().width();
246 } 242 }
247 243
248 gfx::Size ImageSkia::size() const { 244 gfx::Size ImageSkia::size() const {
249 return gfx::Size(width(), height()); 245 return gfx::Size(width(), height());
250 } 246 }
251 247
252 int ImageSkia::height() const { 248 int ImageSkia::height() const {
253 return isNull() ? 0 : storage_->size().height(); 249 return isNull() ? 0 : storage_->size().height();
254 } 250 }
255 251
256 bool ImageSkia::extractSubset(ImageSkia* dst, const SkIRect& subset) const {
257 gfx::Rect rect(subset.x(), subset.y(), subset.width(), subset.height());
258 *dst = ImageSkiaOperations::ExtractSubset(*this, rect);
259 return (!dst->isNull());
260 }
261
262 std::vector<ImageSkiaRep> ImageSkia::image_reps() const { 252 std::vector<ImageSkiaRep> ImageSkia::image_reps() const {
263 if (isNull()) 253 if (isNull())
264 return std::vector<ImageSkiaRep>(); 254 return std::vector<ImageSkiaRep>();
265 255
266 ImageSkiaReps internal_image_reps = storage_->image_reps(); 256 ImageSkiaReps internal_image_reps = storage_->image_reps();
267 // Create list of image reps to return, skipping null image reps which were 257 // Create list of image reps to return, skipping null image reps which were
268 // added for caching purposes only. 258 // added for caching purposes only.
269 ImageSkiaReps image_reps; 259 ImageSkiaReps image_reps;
270 for (ImageSkiaReps::iterator it = internal_image_reps.begin(); 260 for (ImageSkiaReps::iterator it = internal_image_reps.begin();
271 it != internal_image_reps.end(); ++it) { 261 it != internal_image_reps.end(); ++it) {
(...skipping 23 matching lines...) Expand all
295 } 285 }
296 286
297 ImageSkiaReps::iterator it = 287 ImageSkiaReps::iterator it =
298 storage_->FindRepresentation(ui::SCALE_FACTOR_100P, true); 288 storage_->FindRepresentation(ui::SCALE_FACTOR_100P, true);
299 if (it != storage_->image_reps().end()) 289 if (it != storage_->image_reps().end())
300 return it->mutable_sk_bitmap(); 290 return it->mutable_sk_bitmap();
301 return NullImageRep().mutable_sk_bitmap(); 291 return NullImageRep().mutable_sk_bitmap();
302 } 292 }
303 293
304 } // namespace gfx 294 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia.h ('k') | ui/gfx/image/image_skia_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698