blob: 9d1fdeb05c9761cf12856b91f03b8ca836cc7f5d [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#ifndef GrDrawOpTest_DEFINED
9#define GrDrawOpTest_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkRefCnt.h"
12#include "src/gpu/GrTestUtils.h"
Brian Salomon5ec9def2016-12-20 15:34:05 -050013
Hal Canary6f6961e2017-01-31 13:50:44 -050014#if GR_TEST_UTILS
Brian Salomon5ec9def2016-12-20 15:34:05 -050015
Robert Phillipsb97da532019-02-12 15:24:12 -050016class GrContext_Base;
Brian Salomon17726632017-05-12 14:09:46 -040017class GrDrawOp;
Brian Salomon17726632017-05-12 14:09:46 -040018class GrPaint;
Robert Phillipsb97da532019-02-12 15:24:12 -050019class GrRecordingContext;
Robert Phillips4dca8312021-07-28 15:13:20 -040020namespace skgpu { namespace v1 { class SurfaceDrawContext; }}
Brian Salomon17726632017-05-12 14:09:46 -040021struct GrUserStencilSettings;
Brian Salomon5ec9def2016-12-20 15:34:05 -050022class SkRandom;
23
Brian Salomon17726632017-05-12 14:09:46 -040024/** This function draws a randomly configured GrDrawOp for testing purposes. */
Robert Phillips4dca8312021-07-28 15:13:20 -040025void GrDrawRandomOp(SkRandom*, skgpu::v1::SurfaceDrawContext*, GrPaint&&);
Brian Salomon5ec9def2016-12-20 15:34:05 -050026
27/** GrDrawOp subclasses should define test factory functions using this macro. */
Brian Salomon17726632017-05-12 14:09:46 -040028#define GR_DRAW_OP_TEST_DEFINE(Op) \
Robert Phillips4dca8312021-07-28 15:13:20 -040029 GrOp::Owner Op##__Test(GrPaint&& paint, \
30 SkRandom* random, \
31 GrRecordingContext* context, \
32 skgpu::v1::SurfaceDrawContext* sdc, \
33 int numSamples)
Robert Phillipsb97da532019-02-12 15:24:12 -050034#define GR_DRAW_OP_TEST_FRIEND(Op) \
Robert Phillips4dca8312021-07-28 15:13:20 -040035 friend GrOp::OpOwner Op##__Test(GrPaint&&, \
36 SkRandom*, \
37 GrRecordingContext*, \
38 skgpu::v1::SurfaceDrawContext*, \
39 int)
Brian Salomon5ec9def2016-12-20 15:34:05 -050040
Brian Salomon17726632017-05-12 14:09:46 -040041/** Helper for op test factories to pick a random stencil state. */
Robert Phillipsb97da532019-02-12 15:24:12 -050042const GrUserStencilSettings* GrGetRandomStencil(SkRandom* random, GrContext_Base*);
Brian Salomon17726632017-05-12 14:09:46 -040043
Brian Salomon5ec9def2016-12-20 15:34:05 -050044#endif
45#endif