blob: fe8047cbb2b2169baaedf29c2dec8b64fd671663 [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;
Brian Salomon17726632017-05-12 14:09:46 -040020class GrRenderTargetContext;
21struct 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. */
25void GrDrawRandomOp(SkRandom*, GrRenderTargetContext*, 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 Phillipsb97da532019-02-12 15:24:12 -050029 std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&& paint, SkRandom* random, \
Chris Dalton6ce447a2019-06-23 18:07:38 -060030 GrRecordingContext* context, int numSamples)
Robert Phillipsb97da532019-02-12 15:24:12 -050031#define GR_DRAW_OP_TEST_FRIEND(Op) \
32 friend std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&& paint, SkRandom* random, \
Chris Dalton6ce447a2019-06-23 18:07:38 -060033 GrRecordingContext* context, int numSamples)
Brian Salomon5ec9def2016-12-20 15:34:05 -050034
Brian Salomon17726632017-05-12 14:09:46 -040035/** Helper for op test factories to pick a random stencil state. */
Robert Phillipsb97da532019-02-12 15:24:12 -050036const GrUserStencilSettings* GrGetRandomStencil(SkRandom* random, GrContext_Base*);
Brian Salomon17726632017-05-12 14:09:46 -040037
Brian Salomon5ec9def2016-12-20 15:34:05 -050038#endif
39#endif