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

Unified Diff: ui/gfx/skbitmap_operations_unittest.cc

Issue 2355583002: stop using (deprecated) setClipRegion, add flag for new clipop type (Closed)
Patch Set: rename to DrawRectWithColor Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/skbitmap_operations_unittest.cc
diff --git a/ui/gfx/skbitmap_operations_unittest.cc b/ui/gfx/skbitmap_operations_unittest.cc
index d41747bce58bdc608dad50e183348a0f672f52a8..fed87609413531cbdc03ac397a65faae36bb4e7c 100644
--- a/ui/gfx/skbitmap_operations_unittest.cc
+++ b/ui/gfx/skbitmap_operations_unittest.cc
@@ -506,6 +506,21 @@ TEST(SkBitmapOperationsTest, CreateTransposedBitmap) {
}
}
+void DrawRectWithColor(SkCanvas* canvas,
+ int left,
+ int top,
+ int right,
+ int bottom,
+ SkColor color) {
+ SkPaint paint;
+ paint.setColor(color);
+ paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+ canvas->drawRect(
+ SkRect::MakeLTRB(SkIntToScalar(left), SkIntToScalar(top),
+ SkIntToScalar(right), SkIntToScalar(bottom)),
+ paint);
+}
+
// Check that Rotate provides the desired results
TEST(SkBitmapOperationsTest, RotateImage) {
const int src_w = 6, src_h = 4;
@@ -519,22 +534,13 @@ TEST(SkBitmapOperationsTest, RotateImage) {
SkCanvas canvas(src);
src.eraseARGB(0, 0, 0, 0);
- SkRegion region;
- region.setRect(0, 0, src_w / 2, src_h / 2);
- canvas.setClipRegion(region);
// This region is a semi-transparent red to test non-opaque pixels.
- canvas.drawColor(0x1FFF0000, SkXfermode::kSrc_Mode);
- region.setRect(src_w / 2, 0, src_w, src_h / 2);
- canvas.setClipRegion(region);
- canvas.drawColor(SK_ColorBLUE, SkXfermode::kSrc_Mode);
- region.setRect(0, src_h / 2, src_w / 2, src_h);
- canvas.setClipRegion(region);
- canvas.drawColor(SK_ColorGREEN, SkXfermode::kSrc_Mode);
- region.setRect(src_w / 2, src_h / 2, src_w, src_h);
- canvas.setClipRegion(region);
- canvas.drawColor(SK_ColorYELLOW, SkXfermode::kSrc_Mode);
- canvas.flush();
+ DrawRectWithColor(&canvas, 0, 0, src_w / 2, src_h / 2, 0x1FFF0000);
+ DrawRectWithColor(&canvas, src_w / 2, 0, src_w, src_h / 2, SK_ColorBLUE);
+ DrawRectWithColor(&canvas, 0, src_h / 2, src_w / 2, src_h, SK_ColorGREEN);
+ DrawRectWithColor(&canvas, src_w / 2, src_h / 2, src_w, src_h,
+ SK_ColorYELLOW);
SkBitmap rotate90, rotate180, rotate270;
rotate90 = SkBitmapOperations::Rotate(src,
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698