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

Side by Side Diff: Source/platform/graphics/GraphicsContextTest.cpp

Issue 815933006: Change all uses of the RoundedRect class to use FloatRoundedRect instead. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 12 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 | « Source/platform/graphics/GraphicsContext.cpp ('k') | Source/platform/graphics/Path.h » ('j') | 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 GraphicsContext context(&canvas, nullptr); 678 GraphicsContext context(&canvas, nullptr);
679 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque); 679 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque);
680 680
681 Color opaque(1.0f, 0.0f, 0.0f, 1.0f); 681 Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
682 Color alpha(0.0f, 0.0f, 0.0f, 0.0f); 682 Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
683 IntSize radii(10, 10); 683 IntSize radii(10, 10);
684 684
685 EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); 685 EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
686 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); 686 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
687 687
688 context.fillRoundedRect(IntRect(10, 10, 90, 90), radii, radii, radii, radii, opaque); 688 context.fillRoundedRect(FloatRect(10, 10, 90, 90), radii, radii, radii, radi i, opaque);
689 EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect()); 689 EXPECT_EQ_RECT(IntRect(0, 0, 0, 0), context.opaqueRegion().asRect());
690 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); 690 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
691 691
692 context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver); 692 context.fillRect(FloatRect(10, 10, 90, 90), opaque, CompositeSourceOver);
693 EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect()); 693 EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
694 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); 694 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
695 695
696 context.setCompositeOperation(CompositeSourceIn); 696 context.setCompositeOperation(CompositeSourceIn);
697 context.setShouldAntialias(false); 697 context.setShouldAntialias(false);
698 698
699 context.fillRoundedRect(IntRect(10, 10, 50, 30), radii, radii, radii, radii, opaque); 699 context.fillRoundedRect(FloatRect(10, 10, 50, 30), radii, radii, radii, radi i, opaque);
700 EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect()); 700 EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), context.opaqueRegion().asRect());
701 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); 701 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
702 702
703 context.fillRoundedRect(IntRect(10, 10, 30, 50), radii, radii, radii, radii, alpha); 703 context.fillRoundedRect(FloatRect(10, 10, 30, 50), radii, radii, radii, radi i, alpha);
704 EXPECT_EQ_RECT(IntRect(40, 10, 60, 90), context.opaqueRegion().asRect()); 704 EXPECT_EQ_RECT(IntRect(40, 10, 60, 90), context.opaqueRegion().asRect());
705 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); 705 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
706 706
707 context.fillRoundedRect(IntRect(10, 0, 50, 30), radii, radii, radii, radii, alpha); 707 context.fillRoundedRect(FloatRect(10, 0, 50, 30), radii, radii, radii, radii , alpha);
708 EXPECT_EQ_RECT(IntRect(40, 30, 60, 70), context.opaqueRegion().asRect()); 708 EXPECT_EQ_RECT(IntRect(40, 30, 60, 70), context.opaqueRegion().asRect());
709 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); 709 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
710 710
711 context.fillRoundedRect(IntRect(30, 0, 70, 50), radii, radii, radii, radii, opaque); 711 context.fillRoundedRect(FloatRect(30, 0, 70, 50), radii, radii, radii, radii , opaque);
712 EXPECT_EQ_RECT(IntRect(40, 30, 60, 70), context.opaqueRegion().asRect()); 712 EXPECT_EQ_RECT(IntRect(40, 30, 60, 70), context.opaqueRegion().asRect());
713 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect()); 713 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
714 } 714 }
715 715
716 TEST(GraphicsContextTest, trackOpaqueTextTest) 716 TEST(GraphicsContextTest, trackOpaqueTextTest)
717 { 717 {
718 int width = 200, height = 200; 718 int width = 200, height = 200;
719 SkBitmap bitmap; 719 SkBitmap bitmap;
720 bitmap.allocN32Pixels(width, height); 720 bitmap.allocN32Pixels(width, height);
721 bitmap.eraseColor(0); 721 bitmap.eraseColor(0);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 1212
1213 // endRecording finally makes the picture accessible 1213 // endRecording finally makes the picture accessible
1214 RefPtr<const SkPicture> picture = context.endRecording(); 1214 RefPtr<const SkPicture> picture = context.endRecording();
1215 EXPECT_TRUE(picture); 1215 EXPECT_TRUE(picture);
1216 EXPECT_TRUE(picture->unique()); 1216 EXPECT_TRUE(picture->unique());
1217 1217
1218 context.endRecording(); 1218 context.endRecording();
1219 } 1219 }
1220 1220
1221 } // namespace 1221 } // namespace
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext.cpp ('k') | Source/platform/graphics/Path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698