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