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

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

Issue 657203002: The ScaleImageSkiaRep function which attempts to scale the image to the desired scale should not do… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | 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.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 bool operator()(const ImageSkiaRep& rep) const { 50 bool operator()(const ImageSkiaRep& rep) const {
51 return rep.scale() == scale_; 51 return rep.scale() == scale_;
52 } 52 }
53 53
54 private: 54 private:
55 float scale_; 55 float scale_;
56 }; 56 };
57 57
58 ImageSkiaRep ScaleImageSkiaRep(const ImageSkiaRep& rep, float target_scale) { 58 ImageSkiaRep ScaleImageSkiaRep(const ImageSkiaRep& rep, float target_scale) {
59 DCHECK_NE(rep.scale(), target_scale); 59 if (rep.is_null() || rep.scale() == target_scale)
60 if (rep.is_null())
61 return rep; 60 return rep;
62 61
63 gfx::Size scaled_size = ToCeiledSize( 62 gfx::Size scaled_size = ToCeiledSize(
64 gfx::ScaleSize(rep.pixel_size(), target_scale / rep.scale())); 63 gfx::ScaleSize(rep.pixel_size(), target_scale / rep.scale()));
65 return ImageSkiaRep(skia::ImageOperations::Resize( 64 return ImageSkiaRep(skia::ImageOperations::Resize(
66 rep.sk_bitmap(), 65 rep.sk_bitmap(),
67 skia::ImageOperations::RESIZE_LANCZOS3, 66 skia::ImageOperations::RESIZE_LANCZOS3,
68 scaled_size.width(), 67 scaled_size.width(),
69 scaled_size.height()), target_scale); 68 scaled_size.height()), target_scale);
70 } 69 }
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 bool ImageSkia::CanModify() const { 492 bool ImageSkia::CanModify() const {
494 return !storage_.get() || storage_->CanModify(); 493 return !storage_.get() || storage_->CanModify();
495 } 494 }
496 495
497 void ImageSkia::DetachStorageFromThread() { 496 void ImageSkia::DetachStorageFromThread() {
498 if (storage_.get()) 497 if (storage_.get())
499 storage_->DetachFromThread(); 498 storage_->DetachFromThread();
500 } 499 }
501 500
502 } // namespace gfx 501 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698