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

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

Issue 323013004: Clean up transform methods in GraphicsContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2nd Attempt Mac build fix Created 6 years, 6 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
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 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 context.setFillColor(opaque); 1035 context.setFillColor(opaque);
1036 path.moveTo(FloatPoint(10, 10)); 1036 path.moveTo(FloatPoint(10, 10));
1037 path.addLineTo(FloatPoint(40, 40)); 1037 path.addLineTo(FloatPoint(40, 40));
1038 context.strokePath(path); 1038 context.strokePath(path);
1039 1039
1040 context.endLayer(); 1040 context.endLayer();
1041 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); 1041 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
1042 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); 1042 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
1043 } 1043 }
1044 1044
1045 #define DISPATCH(c1, c2, op, params) do { c1.op(params); c2.op(params); } while (0); 1045 #define DISPATCH1(c1, c2, op, param1) do { c1.op(param1); c2.op(param1); } while (0);
1046 #define DISPATCH2(c1, c2, op, param1, param2) do { c1.op(param1, param2); c2.op( param1, param2); } while (0);
1046 1047
1047 TEST(GraphicsContextTest, RecordingTotalMatrix) 1048 TEST(GraphicsContextTest, RecordingTotalMatrix)
1048 { 1049 {
1049 SkBitmap bitmap; 1050 SkBitmap bitmap;
1050 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400)); 1051 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400));
1051 bitmap.eraseColor(0); 1052 bitmap.eraseColor(0);
1052 SkCanvas canvas(bitmap); 1053 SkCanvas canvas(bitmap);
1053 GraphicsContext context(&canvas); 1054 GraphicsContext context(&canvas);
1054 1055
1055 SkCanvas controlCanvas(400, 400); 1056 SkCanvas controlCanvas(400, 400);
1056 GraphicsContext controlContext(&controlCanvas); 1057 GraphicsContext controlContext(&controlCanvas);
1057 1058
1058 EXPECT_EQ(context.getCTM(), controlContext.getCTM()); 1059 EXPECT_EQ(context.getCTM(), controlContext.getCTM());
1059 DISPATCH(context, controlContext, scale, FloatSize(2, 2)); 1060 DISPATCH2(context, controlContext, scale, 2, 2);
1060 EXPECT_EQ(context.getCTM(), controlContext.getCTM()); 1061 EXPECT_EQ(context.getCTM(), controlContext.getCTM());
1061 1062
1062 controlContext.save(); 1063 controlContext.save();
1063 context.beginRecording(FloatRect(0, 0, 200, 200)); 1064 context.beginRecording(FloatRect(0, 0, 200, 200));
1064 DISPATCH(context, controlContext, translate, FloatSize(10, 10)); 1065 DISPATCH2(context, controlContext, translate, 10, 10);
1065 EXPECT_EQ(context.getCTM(), controlContext.getCTM()); 1066 EXPECT_EQ(context.getCTM(), controlContext.getCTM());
1066 1067
1067 controlContext.save(); 1068 controlContext.save();
1068 context.beginRecording(FloatRect(10, 10, 100, 100)); 1069 context.beginRecording(FloatRect(10, 10, 100, 100));
1069 DISPATCH(context, controlContext, rotate, 45); 1070 DISPATCH1(context, controlContext, rotate, 45);
1070 EXPECT_EQ(context.getCTM(), controlContext.getCTM()); 1071 EXPECT_EQ(context.getCTM(), controlContext.getCTM());
1071 1072
1072 controlContext.restore(); 1073 controlContext.restore();
1073 context.endRecording(); 1074 context.endRecording();
1074 EXPECT_EQ(context.getCTM(), controlContext.getCTM()); 1075 EXPECT_EQ(context.getCTM(), controlContext.getCTM());
1075 1076
1076 controlContext.restore(); 1077 controlContext.restore();
1077 context.endRecording(); 1078 context.endRecording();
1078 EXPECT_EQ(context.getCTM(), controlContext.getCTM()); 1079 EXPECT_EQ(context.getCTM(), controlContext.getCTM());
1079 } 1080 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 EXPECT_FALSE(pic); 1114 EXPECT_FALSE(pic);
1114 1115
1115 // endRecording finally makes the picture accessible 1116 // endRecording finally makes the picture accessible
1116 dl->endRecording(); 1117 dl->endRecording();
1117 pic = dl->picture(); 1118 pic = dl->picture();
1118 EXPECT_TRUE(pic); 1119 EXPECT_TRUE(pic);
1119 EXPECT_EQ(1, pic->getRefCnt()); 1120 EXPECT_EQ(1, pic->getRefCnt());
1120 } 1121 }
1121 1122
1122 } // namespace 1123 } // namespace
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext.cpp ('k') | Source/platform/graphics/filters/FETile.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698