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