blob: 1e88c219f5c4502a4e9e61758c9d4f37d47de4e0 [file] [log] [blame]
Brian Salomon5ec9def2016-12-20 15:34:05 -05001/*
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 Salomon5ec9def2016-12-20 15:34:05 -05009#include "SkRandom.h"
10#include "SkTypes.h"
Brian Salomon649a3412017-03-09 13:50:43 -050011#include "ops/GrMeshDrawOp.h"
Brian Salomon5ec9def2016-12-20 15:34:05 -050012
Hal Canary6f6961e2017-01-31 13:50:44 -050013#if GR_TEST_UTILS
Brian Salomon5ec9def2016-12-20 15:34:05 -050014
Brian Salomonf8334782017-01-03 09:42:58 -050015#define DRAW_OP_TEST_EXTERN(Op) \
Brian Salomond3ccb0a2017-04-03 10:38:00 -040016 extern std::unique_ptr<GrLegacyMeshDrawOp> Op##__Test(SkRandom*, GrContext* context);
Brian Salomon5ec9def2016-12-20 15:34:05 -050017
18#define DRAW_OP_TEST_ENTRY(Op) Op##__Test
19
20DRAW_OP_TEST_EXTERN(AAConvexPathOp);
Brian Salomon5ec9def2016-12-20 15:34:05 -050021DRAW_OP_TEST_EXTERN(AAFillRectOp);
22DRAW_OP_TEST_EXTERN(AAFillRectOpLocalMatrix);
23DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp)
24DRAW_OP_TEST_EXTERN(AAHairlineOp);
25DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
26DRAW_OP_TEST_EXTERN(AnalyticRectOp);
27DRAW_OP_TEST_EXTERN(DashOp);
28DRAW_OP_TEST_EXTERN(DefaultPathOp);
29DRAW_OP_TEST_EXTERN(CircleOp);
30DRAW_OP_TEST_EXTERN(DIEllipseOp);
31DRAW_OP_TEST_EXTERN(EllipseOp);
32DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
33DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp);
Brian Salomon5ec9def2016-12-20 15:34:05 -050034DRAW_OP_TEST_EXTERN(RRectOp);
Jim Van Verth83010462017-03-16 08:45:39 -040035DRAW_OP_TEST_EXTERN(SmallPathOp);
Brian Salomon5ec9def2016-12-20 15:34:05 -050036DRAW_OP_TEST_EXTERN(TesselatingPathOp);
37DRAW_OP_TEST_EXTERN(TextBlobOp);
38DRAW_OP_TEST_EXTERN(VerticesOp);
39
Brian Salomond3ccb0a2017-04-03 10:38:00 -040040std::unique_ptr<GrLegacyMeshDrawOp> GrRandomDrawOp(SkRandom* random, GrContext* context) {
41 using MakeTestDrawOpFn =
42 std::unique_ptr<GrLegacyMeshDrawOp>(SkRandom * random, GrContext * context);
Brian Salomon5ec9def2016-12-20 15:34:05 -050043 static constexpr MakeTestDrawOpFn* gFactories[] = {
44 DRAW_OP_TEST_ENTRY(AAConvexPathOp),
Brian Salomon5ec9def2016-12-20 15:34:05 -050045 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 Salomon5ec9def2016-12-20 15:34:05 -050058 DRAW_OP_TEST_ENTRY(RRectOp),
Jim Van Verth83010462017-03-16 08:45:39 -040059 DRAW_OP_TEST_ENTRY(SmallPathOp),
Brian Salomon5ec9def2016-12-20 15:34:05 -050060 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