xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrDrawOpTest.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 #ifndef GrDrawOpTest_DEFINED
9 #define GrDrawOpTest_DEFINED
10 
11 #include "include/core/SkTypes.h"
12 
13 #if defined(GPU_TEST_UTILS)
14 
15 class GrContext_Base;
16 class GrPaint;
17 struct GrUserStencilSettings;
18 class SkRandom;
19 
20 namespace skgpu {
21 namespace ganesh {
22 class SurfaceDrawContext;
23 }
24 }  // namespace skgpu
25 
26 /**  This function draws a randomly configured GrDrawOp for testing purposes. */
27 void GrDrawRandomOp(SkRandom*, skgpu::ganesh::SurfaceDrawContext*, GrPaint&&);
28 
29 /** GrDrawOp subclasses should define test factory functions using this macro. */
30 #define GR_DRAW_OP_TEST_DEFINE(Op)                                 \
31     GrOp::Owner Op##__Test(GrPaint&& paint,                        \
32                            SkRandom* random,                       \
33                            GrRecordingContext* context,            \
34                            skgpu::ganesh::SurfaceDrawContext* sdc, \
35                            int numSamples)
36 #define GR_DRAW_OP_TEST_FRIEND(Op)   \
37     friend GrOp::OpOwner Op##__Test( \
38             GrPaint&&, SkRandom*, GrRecordingContext*, skgpu::ganesh::SurfaceDrawContext*, int)
39 
40 /** Helper for op test factories to pick a random stencil state. */
41 const GrUserStencilSettings* GrGetRandomStencil(SkRandom* random, GrContext_Base*);
42 
43 #endif
44 #endif
45