| 1 |
/* |
| 2 |
* Copyright 2018 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 FillRectOp_DEFINED |
| 9 |
#define FillRectOp_DEFINED |
| 10 |
|
| 11 |
#include "src/gpu/ganesh/ops/GrOp.h" |
| 12 |
#include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelper.h" |
| 13 |
|
| 14 |
#include <cstdint> |
| 15 |
|
| 16 |
class GrClip; |
| 17 |
class GrPaint; |
| 18 |
class GrRecordingContext; |
| 19 |
class SkMatrix; |
| 20 |
enum class GrAAType : unsigned int; |
| 21 |
struct DrawQuad; |
| 22 |
struct GrQuadSetEntry; |
| 23 |
struct GrUserStencilSettings; |
| 24 |
struct SkRect; |
| 25 |
|
| 26 |
namespace skgpu::ganesh { |
| 27 |
|
| 28 |
class SurfaceDrawContext; |
| 29 |
|
| 30 |
/** |
| 31 |
* A set of factory functions for drawing filled rectangles either coverage-antialiased, or |
| 32 |
* non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories, |
| 33 |
* the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then |
| 34 |
* the paint is unmodified and may still be used. |
| 35 |
*/ |
| 36 |
class FillRectOp { |
| 37 |
public: |
| 38 |
using InputFlags = GrSimpleMeshDrawOpHelper::InputFlags; |
| 39 |
|
| 40 |
static GrOp::Owner Make(GrRecordingContext*, |
| 41 |
GrPaint&&, |
| 42 |
GrAAType, |
| 43 |
DrawQuad*, |
| 44 |
const GrUserStencilSettings* = nullptr, |
| 45 |
InputFlags = InputFlags::kNone); |
| 46 |
|
| 47 |
// Utility function to create a non-AA rect transformed by view. This is used commonly enough |
| 48 |
// in testing and GMs that manage ops without going through GrRTC that it's worth the |
| 49 |
// convenience. |
| 50 |
static GrOp::Owner MakeNonAARect(GrRecordingContext*, |
| 51 |
GrPaint&&, |
| 52 |
const SkMatrix& view, |
| 53 |
const SkRect&, |
| 54 |
const GrUserStencilSettings* = nullptr); |
| 55 |
|
| 56 |
// Bulk API for drawing quads with a single op |
| 57 |
// TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer |
| 58 |
static void AddFillRectOps(SurfaceDrawContext*, |
| 59 |
const GrClip*, |
| 60 |
GrRecordingContext*, |
| 61 |
GrPaint&&, |
| 62 |
GrAAType, |
| 63 |
const SkMatrix& viewMatrix, |
| 64 |
const GrQuadSetEntry quads[], |
| 65 |
int quadCount, |
| 66 |
const GrUserStencilSettings* = nullptr); |
| 67 |
|
| 68 |
#if defined(GPU_TEST_UTILS) |
| 69 |
static uint32_t ClassID(); |
| 70 |
#endif |
| 71 |
|
| 72 |
private: |
| 73 |
// Create a FillRectOp that uses as many quads as possible from 'quads' w/o exceeding |
| 74 |
// any index buffer size limits. |
| 75 |
static GrOp::Owner MakeOp(GrRecordingContext*, |
| 76 |
GrPaint&&, |
| 77 |
GrAAType, |
| 78 |
const SkMatrix& viewMatrix, |
| 79 |
const GrQuadSetEntry quads[], |
| 80 |
int quadCount, |
| 81 |
const GrUserStencilSettings*, |
| 82 |
int* numConsumed); |
| 83 |
}; |
| 84 |
|
| 85 |
} // namespace skgpu::ganesh |
| 86 |
|
| 87 |
#endif // FillRectOp_DEFINED |