blob: 6e63f5d0e10063db5c99ce1b467016cca0cb53cc [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 Salomon649a3412017-03-09 13:50:43 -050016 extern std::unique_ptr<GrMeshDrawOp> 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 Salomon649a3412017-03-09 13:50:43 -050040std::unique_ptr<GrMeshDrawOp> GrRandomDrawOp(SkRandom* random, GrContext* context) {
41 using MakeTestDrawOpFn = std::unique_ptr<GrMeshDrawOp>(SkRandom* random, GrContext* context);
Brian Salomon5ec9def2016-12-20 15:34:05 -050042 static constexpr MakeTestDrawOpFn* gFactories[] = {
43 DRAW_OP_TEST_ENTRY(AAConvexPathOp),
Brian Salomon5ec9def2016-12-20 15:34:05 -050044 DRAW_OP_TEST_ENTRY(AAFillRectOp),
45 DRAW_OP_TEST_ENTRY(AAFillRectOpLocalMatrix),
46 DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp),
47 DRAW_OP_TEST_ENTRY(AAHairlineOp),
48 DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
49 DRAW_OP_TEST_ENTRY(AnalyticRectOp),
50 DRAW_OP_TEST_ENTRY(DashOp),
51 DRAW_OP_TEST_ENTRY(DefaultPathOp),
52 DRAW_OP_TEST_ENTRY(CircleOp),
53 DRAW_OP_TEST_ENTRY(DIEllipseOp),
54 DRAW_OP_TEST_ENTRY(EllipseOp),
55 DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
56 DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp),
Brian Salomon5ec9def2016-12-20 15:34:05 -050057 DRAW_OP_TEST_ENTRY(RRectOp),
Jim Van Verth83010462017-03-16 08:45:39 -040058 DRAW_OP_TEST_ENTRY(SmallPathOp),
Brian Salomon5ec9def2016-12-20 15:34:05 -050059 DRAW_OP_TEST_ENTRY(TesselatingPathOp),
60 DRAW_OP_TEST_ENTRY(TextBlobOp),
61 DRAW_OP_TEST_ENTRY(VerticesOp)
62 };
63
64 uint32_t index = random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gFactories)));
65 return gFactories[index](random, context);
66}
67#endif