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

Side by Side Diff: Source/platform/DragImageTest.cpp

Issue 886323005: Pass InterpolationQuality into DragImage to respect image-rendering:pixelated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Sync and rebase Created 5 years, 10 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 | « Source/platform/DragImage.cpp ('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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 SkAutoLockPixels lock(dragImageBitmap); 204 SkAutoLockPixels lock(dragImageBitmap);
205 ASSERT_NE(nullptr, dragImageBitmap.getPixels()); 205 ASSERT_NE(nullptr, dragImageBitmap.getPixels());
206 for (int x = 0; x < dragImageBitmap.width(); x++) { 206 for (int x = 0; x < dragImageBitmap.width(); x++) {
207 for (int y = 0; y < dragImageBitmap.height(); y++) { 207 for (int y = 0; y < dragImageBitmap.height(); y++) {
208 int alpha = SkColorGetA(dragImageBitmap.getColor(x, y)); 208 int alpha = SkColorGetA(dragImageBitmap.getColor(x, y));
209 ASSERT_EQ(0, alpha); 209 ASSERT_EQ(0, alpha);
210 } 210 }
211 } 211 }
212 } 212 }
213 213
214 TEST(DragImageTest, InterpolationNone)
215 {
216 SkBitmap expectedBitmap;
217 expectedBitmap.allocN32Pixels(4, 4);
218 {
219 SkAutoLockPixels lock(expectedBitmap);
220 expectedBitmap.eraseArea(SkIRect::MakeXYWH(0, 0, 2, 2), 0xFFFFFFFF);
221 expectedBitmap.eraseArea(SkIRect::MakeXYWH(0, 2, 2, 2), 0xFF000000);
222 expectedBitmap.eraseArea(SkIRect::MakeXYWH(2, 0, 2, 2), 0xFF000000);
223 expectedBitmap.eraseArea(SkIRect::MakeXYWH(2, 2, 2, 2), 0xFFFFFFFF);
224 }
225
226 RefPtr<TestImage> testImage(TestImage::create(IntSize(2, 2)));
227 const SkBitmap& testBitmap = testImage->nativeImageForCurrentFrame()->bitmap ();
228 {
229 SkAutoLockPixels lock(testBitmap);
230 testBitmap.eraseArea(SkIRect::MakeXYWH(0, 0, 1, 1), 0xFFFFFFFF);
231 testBitmap.eraseArea(SkIRect::MakeXYWH(0, 1, 1, 1), 0xFF000000);
232 testBitmap.eraseArea(SkIRect::MakeXYWH(1, 0, 1, 1), 0xFF000000);
233 testBitmap.eraseArea(SkIRect::MakeXYWH(1, 1, 1, 1), 0xFFFFFFFF);
234 }
235
236 OwnPtr<DragImage> dragImage = DragImage::create(testImage.get(), DoNotRespec tImageOrientation, 1, InterpolationNone);
237 ASSERT_TRUE(dragImage);
238 dragImage->scale(2, 2);
239 const SkBitmap& dragBitmap = dragImage->bitmap();
240 {
241 SkAutoLockPixels lock1(dragBitmap);
242 SkAutoLockPixels lock2(expectedBitmap);
243 for (int x = 0; x < dragBitmap.width(); ++x)
244 for (int y = 0; y < dragBitmap.height(); ++y)
245 EXPECT_EQ(expectedBitmap.getColor(x, y), dragBitmap.getColor(x, y));
246 }
247 }
248
214 } // anonymous namespace 249 } // anonymous namespace
OLDNEW
« no previous file with comments | « Source/platform/DragImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698