Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrDrawOpTest.h" |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 9 | #include "SkRandom.h" |
| 10 | #include "SkTypes.h" |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 11 | #include "ops/GrMeshDrawOp.h" |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 12 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 13 | #if GR_TEST_UTILS |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 14 | |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 15 | #define DRAW_OP_TEST_EXTERN(Op) \ |
Brian Salomon | d3ccb0a | 2017-04-03 10:38:00 -0400 | [diff] [blame] | 16 | extern std::unique_ptr<GrLegacyMeshDrawOp> Op##__Test(SkRandom*, GrContext* context); |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 17 | |
| 18 | #define DRAW_OP_TEST_ENTRY(Op) Op##__Test |
| 19 | |
| 20 | DRAW_OP_TEST_EXTERN(AAConvexPathOp); |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 21 | DRAW_OP_TEST_EXTERN(AAFillRectOp); |
| 22 | DRAW_OP_TEST_EXTERN(AAFillRectOpLocalMatrix); |
| 23 | DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp) |
| 24 | DRAW_OP_TEST_EXTERN(AAHairlineOp); |
| 25 | DRAW_OP_TEST_EXTERN(AAStrokeRectOp); |
| 26 | DRAW_OP_TEST_EXTERN(AnalyticRectOp); |
| 27 | DRAW_OP_TEST_EXTERN(DashOp); |
| 28 | DRAW_OP_TEST_EXTERN(DefaultPathOp); |
| 29 | DRAW_OP_TEST_EXTERN(CircleOp); |
| 30 | DRAW_OP_TEST_EXTERN(DIEllipseOp); |
| 31 | DRAW_OP_TEST_EXTERN(EllipseOp); |
| 32 | DRAW_OP_TEST_EXTERN(GrDrawAtlasOp); |
| 33 | DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp); |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 34 | DRAW_OP_TEST_EXTERN(RRectOp); |
Jim Van Verth | 8301046 | 2017-03-16 08:45:39 -0400 | [diff] [blame] | 35 | DRAW_OP_TEST_EXTERN(SmallPathOp); |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 36 | DRAW_OP_TEST_EXTERN(TesselatingPathOp); |
| 37 | DRAW_OP_TEST_EXTERN(TextBlobOp); |
| 38 | DRAW_OP_TEST_EXTERN(VerticesOp); |
| 39 | |
Brian Salomon | d3ccb0a | 2017-04-03 10:38:00 -0400 | [diff] [blame] | 40 | std::unique_ptr<GrLegacyMeshDrawOp> GrRandomDrawOp(SkRandom* random, GrContext* context) { |
| 41 | using MakeTestDrawOpFn = |
| 42 | std::unique_ptr<GrLegacyMeshDrawOp>(SkRandom * random, GrContext * context); |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 43 | static constexpr MakeTestDrawOpFn* gFactories[] = { |
| 44 | DRAW_OP_TEST_ENTRY(AAConvexPathOp), |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 45 | DRAW_OP_TEST_ENTRY(AAFillRectOp), |
| 46 | DRAW_OP_TEST_ENTRY(AAFillRectOpLocalMatrix), |
| 47 | DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp), |
| 48 | DRAW_OP_TEST_ENTRY(AAHairlineOp), |
| 49 | DRAW_OP_TEST_ENTRY(AAStrokeRectOp), |
| 50 | DRAW_OP_TEST_ENTRY(AnalyticRectOp), |
| 51 | DRAW_OP_TEST_ENTRY(DashOp), |
| 52 | DRAW_OP_TEST_ENTRY(DefaultPathOp), |
| 53 | DRAW_OP_TEST_ENTRY(CircleOp), |
| 54 | DRAW_OP_TEST_ENTRY(DIEllipseOp), |
| 55 | DRAW_OP_TEST_ENTRY(EllipseOp), |
| 56 | DRAW_OP_TEST_ENTRY(GrDrawAtlasOp), |
| 57 | DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp), |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 58 | DRAW_OP_TEST_ENTRY(RRectOp), |
Jim Van Verth | 8301046 | 2017-03-16 08:45:39 -0400 | [diff] [blame] | 59 | DRAW_OP_TEST_ENTRY(SmallPathOp), |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 60 | DRAW_OP_TEST_ENTRY(TesselatingPathOp), |
| 61 | DRAW_OP_TEST_ENTRY(TextBlobOp), |
| 62 | DRAW_OP_TEST_ENTRY(VerticesOp) |
| 63 | }; |
| 64 | |
| 65 | uint32_t index = random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gFactories))); |
| 66 | return gFactories[index](random, context); |
| 67 | } |
| 68 | #endif |