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

Side by Side Diff: ui/gfx/skbitmap_operations_unittest.cc

Issue 12151002: Initialize memory, remove valgrind supression, add transparency test. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: clear -> erase, add comment. Created 7 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 | « tools/valgrind/memcheck/suppressions.txt ('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 #include "ui/gfx/skbitmap_operations.h" 5 #include "ui/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/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkColorPriv.h" 10 #include "third_party/skia/include/core/SkColorPriv.h"
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 SkBitmap src; 527 SkBitmap src;
528 // Create a simple 4 color bitmap: 528 // Create a simple 4 color bitmap:
529 // RRRBBB 529 // RRRBBB
530 // RRRBBB 530 // RRRBBB
531 // GGGYYY 531 // GGGYYY
532 // GGGYYY 532 // GGGYYY
533 src.setConfig(SkBitmap::kARGB_8888_Config, src_w, src_h); 533 src.setConfig(SkBitmap::kARGB_8888_Config, src_w, src_h);
534 src.allocPixels(); 534 src.allocPixels();
535 535
536 SkCanvas canvas(src); 536 SkCanvas canvas(src);
537 src.eraseARGB(0, 0, 0, 0);
537 SkRegion region; 538 SkRegion region;
538 539
539 region.setRect(0, 0, src_w / 2, src_h / 2); 540 region.setRect(0, 0, src_w / 2, src_h / 2);
540 canvas.setClipRegion(region); 541 canvas.setClipRegion(region);
541 canvas.drawColor(SK_ColorRED, SkXfermode::kSrc_Mode); 542 // This region is a semi-transparent red to test non-opaque pixels.
543 canvas.drawColor(0x1FFF0000, SkXfermode::kSrc_Mode);
542 region.setRect(src_w / 2, 0, src_w, src_h / 2); 544 region.setRect(src_w / 2, 0, src_w, src_h / 2);
543 canvas.setClipRegion(region); 545 canvas.setClipRegion(region);
544 canvas.drawColor(SK_ColorBLUE, SkXfermode::kSrc_Mode); 546 canvas.drawColor(SK_ColorBLUE, SkXfermode::kSrc_Mode);
545 region.setRect(0, src_h / 2, src_w / 2, src_h); 547 region.setRect(0, src_h / 2, src_w / 2, src_h);
546 canvas.setClipRegion(region); 548 canvas.setClipRegion(region);
547 canvas.drawColor(SK_ColorGREEN, SkXfermode::kSrc_Mode); 549 canvas.drawColor(SK_ColorGREEN, SkXfermode::kSrc_Mode);
548 region.setRect(src_w / 2, src_h / 2, src_w, src_h); 550 region.setRect(src_w / 2, src_h / 2, src_w, src_h);
549 canvas.setClipRegion(region); 551 canvas.setClipRegion(region);
550 canvas.drawColor(SK_ColorYELLOW, SkXfermode::kSrc_Mode); 552 canvas.drawColor(SK_ColorYELLOW, SkXfermode::kSrc_Mode);
551 canvas.flush(); 553 canvas.flush();
(...skipping 20 matching lines...) Expand all
572 574
573 for (int x=0; x < src_w; ++x) { 575 for (int x=0; x < src_w; ++x) {
574 for (int y=0; y < src_h; ++y) { 576 for (int y=0; y < src_h; ++y) {
575 ASSERT_EQ(*src.getAddr32(x,y), *rotate90.getAddr32(y, src_w - (x+1))); 577 ASSERT_EQ(*src.getAddr32(x,y), *rotate90.getAddr32(y, src_w - (x+1)));
576 ASSERT_EQ(*src.getAddr32(x,y), *rotate270.getAddr32(src_h - (y+1),x)); 578 ASSERT_EQ(*src.getAddr32(x,y), *rotate270.getAddr32(src_h - (y+1),x));
577 ASSERT_EQ(*src.getAddr32(x,y), 579 ASSERT_EQ(*src.getAddr32(x,y),
578 *rotate180.getAddr32(src_w - (x+1), src_h - (y+1))); 580 *rotate180.getAddr32(src_w - (x+1), src_h - (y+1)));
579 } 581 }
580 } 582 }
581 } 583 }
OLDNEW
« no previous file with comments | « tools/valgrind/memcheck/suppressions.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698