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

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

Issue 340613004: Use ImageSkiaSource to create ImageSkia from ImagePNGReps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: exclude new test on ios Created 6 years, 6 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_unittest.cc ('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 // Because the unit tests for gfx::Image are spread across multiple 5 // Because the unit tests for gfx::Image are spread across multiple
6 // implementation files, this header contains the reusable components. 6 // implementation files, this header contains the reusable components.
7 7
8 #include "ui/gfx/image/image_unittest_util.h" 8 #include "ui/gfx/image/image_unittest_util.h"
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 gfx::Image CreateImage() { 74 gfx::Image CreateImage() {
75 return CreateImage(100, 50); 75 return CreateImage(100, 50);
76 } 76 }
77 77
78 gfx::Image CreateImage(int width, int height) { 78 gfx::Image CreateImage(int width, int height) {
79 return gfx::Image::CreateFrom1xBitmap(CreateBitmap(width, height)); 79 return gfx::Image::CreateFrom1xBitmap(CreateBitmap(width, height));
80 } 80 }
81 81
82 bool IsEqual(const gfx::Image& img1, const gfx::Image& img2) { 82 bool IsEqual(const gfx::Image& img1, const gfx::Image& img2) {
83 img1.AsImageSkia().EnsureRepsForSupportedScales();
84 img2.AsImageSkia().EnsureRepsForSupportedScales();
83 std::vector<gfx::ImageSkiaRep> img1_reps = img1.AsImageSkia().image_reps(); 85 std::vector<gfx::ImageSkiaRep> img1_reps = img1.AsImageSkia().image_reps();
84 gfx::ImageSkia image_skia2 = img2.AsImageSkia(); 86 gfx::ImageSkia image_skia2 = img2.AsImageSkia();
85 if (image_skia2.image_reps().size() != img1_reps.size()) 87 if (image_skia2.image_reps().size() != img1_reps.size())
86 return false; 88 return false;
87 89
88 for (size_t i = 0; i < img1_reps.size(); ++i) { 90 for (size_t i = 0; i < img1_reps.size(); ++i) {
89 float scale = img1_reps[i].scale(); 91 float scale = img1_reps[i].scale();
90 const gfx::ImageSkiaRep& image_rep2 = image_skia2.GetRepresentation(scale); 92 const gfx::ImageSkiaRep& image_rep2 = image_skia2.GetRepresentation(scale);
91 if (image_rep2.scale() != scale || 93 if (image_rep2.scale() != scale ||
92 !IsEqual(img1_reps[i].sk_bitmap(), image_rep2.sk_bitmap())) { 94 !IsEqual(img1_reps[i].sk_bitmap(), image_rep2.sk_bitmap())) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { 255 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) {
254 #if defined(OS_MACOSX) 256 #if defined(OS_MACOSX)
255 return image1 == image2; 257 return image1 == image2;
256 #else 258 #else
257 return image1.BackedBySameObjectAs(image2); 259 return image1.BackedBySameObjectAs(image2);
258 #endif 260 #endif
259 } 261 }
260 262
261 } // namespace test 263 } // namespace test
262 } // namespace gfx 264 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698