Chromium Code Reviews

Side by Side Diff: gfx/skbitmap_operations_unittest.cc

Issue 2963009: Windows: Fix opacity of drag images.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: merge Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « gfx/skbitmap_operations.cc ('k') | views/drag_utils_win.cc » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "gfx/skbitmap_operations.h" 5 #include "gfx/skbitmap_operations.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "third_party/skia/include/core/SkColorPriv.h" 9 #include "third_party/skia/include/core/SkColorPriv.h"
10 #include "third_party/skia/include/core/SkUnPreMultiply.h" 10 #include "third_party/skia/include/core/SkUnPreMultiply.h"
(...skipping 453 matching lines...)
464 // Test multiple steps of downsampling. 464 // Test multiple steps of downsampling.
465 SkBitmap large; 465 SkBitmap large;
466 large.setConfig(SkBitmap::kARGB_8888_Config, 100, 43); 466 large.setConfig(SkBitmap::kARGB_8888_Config, 100, 43);
467 large.allocPixels(); 467 large.allocPixels();
468 result = SkBitmapOperations::DownsampleByTwoUntilSize(large, 6, 6); 468 result = SkBitmapOperations::DownsampleByTwoUntilSize(large, 6, 6);
469 469
470 // The result should be divided in half 100x43 -> 50x22 -> 25x11 470 // The result should be divided in half 100x43 -> 50x22 -> 25x11
471 EXPECT_EQ(25, result.width()); 471 EXPECT_EQ(25, result.width());
472 EXPECT_EQ(11, result.height()); 472 EXPECT_EQ(11, result.height());
473 } 473 }
474
475 TEST(SkBitmapOperationsTest, UnPreMultiply) {
476 SkBitmap input;
477 input.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
478 input.allocPixels();
479
480 *input.getAddr32(0, 0) = 0x80000000;
481 *input.getAddr32(1, 0) = 0x80808080;
482 *input.getAddr32(0, 1) = 0xFF00CC88;
483 *input.getAddr32(1, 1) = 0x0000CC88;
484
485 SkBitmap result = SkBitmapOperations::UnPreMultiply(input);
486 EXPECT_EQ(2, result.width());
487 EXPECT_EQ(2, result.height());
488
489 SkAutoLockPixels lock(result);
490 EXPECT_EQ(0x80000000, *result.getAddr32(0, 0));
491 EXPECT_EQ(0x80FFFFFF, *result.getAddr32(1, 0));
492 EXPECT_EQ(0xFF00CC88, *result.getAddr32(0, 1));
493 EXPECT_EQ(0x00000000u, *result.getAddr32(1, 1)); // "Division by zero".
494 }
OLDNEW
« no previous file with comments | « gfx/skbitmap_operations.cc ('k') | views/drag_utils_win.cc » ('j') | no next file with comments »

Powered by Google App Engine