OLD | NEW |
---|---|
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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 // Check that Rotate provides the desired results | 524 // Check that Rotate provides the desired results |
525 TEST(SkBitmapOperationsTest, RotateImage) { | 525 TEST(SkBitmapOperationsTest, RotateImage) { |
526 const int src_w = 6, src_h = 4; | 526 const int src_w = 6, src_h = 4; |
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(); |
oshima
2013/01/31 23:34:25
I think
src.eraseARGB(0, 0, 0, 0);
is what you n
| |
535 | 535 |
536 SkCanvas canvas(src); | 536 SkCanvas canvas(src); |
537 canvas.clear(SkColorSetARGB(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 canvas.drawColor(0x1FFF0000, SkXfermode::kSrc_Mode); |
oshima
2013/01/31 23:34:25
is this intentional?
| |
542 region.setRect(src_w / 2, 0, src_w, src_h / 2); | 543 region.setRect(src_w / 2, 0, src_w, src_h / 2); |
543 canvas.setClipRegion(region); | 544 canvas.setClipRegion(region); |
544 canvas.drawColor(SK_ColorBLUE, SkXfermode::kSrc_Mode); | 545 canvas.drawColor(SK_ColorBLUE, SkXfermode::kSrc_Mode); |
545 region.setRect(0, src_h / 2, src_w / 2, src_h); | 546 region.setRect(0, src_h / 2, src_w / 2, src_h); |
546 canvas.setClipRegion(region); | 547 canvas.setClipRegion(region); |
547 canvas.drawColor(SK_ColorGREEN, SkXfermode::kSrc_Mode); | 548 canvas.drawColor(SK_ColorGREEN, SkXfermode::kSrc_Mode); |
548 region.setRect(src_w / 2, src_h / 2, src_w, src_h); | 549 region.setRect(src_w / 2, src_h / 2, src_w, src_h); |
549 canvas.setClipRegion(region); | 550 canvas.setClipRegion(region); |
550 canvas.drawColor(SK_ColorYELLOW, SkXfermode::kSrc_Mode); | 551 canvas.drawColor(SK_ColorYELLOW, SkXfermode::kSrc_Mode); |
551 canvas.flush(); | 552 canvas.flush(); |
(...skipping 20 matching lines...) Expand all Loading... | |
572 | 573 |
573 for (int x=0; x < src_w; ++x) { | 574 for (int x=0; x < src_w; ++x) { |
574 for (int y=0; y < src_h; ++y) { | 575 for (int y=0; y < src_h; ++y) { |
575 ASSERT_EQ(*src.getAddr32(x,y), *rotate90.getAddr32(y, src_w - (x+1))); | 576 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)); | 577 ASSERT_EQ(*src.getAddr32(x,y), *rotate270.getAddr32(src_h - (y+1),x)); |
577 ASSERT_EQ(*src.getAddr32(x,y), | 578 ASSERT_EQ(*src.getAddr32(x,y), |
578 *rotate180.getAddr32(src_w - (x+1), src_h - (y+1))); | 579 *rotate180.getAddr32(src_w - (x+1), src_h - (y+1))); |
579 } | 580 } |
580 } | 581 } |
581 } | 582 } |
OLD | NEW |