• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 GrDrawAtlasOp_DEFINED
9 #define GrDrawAtlasOp_DEFINED
10 
11 #include "GrColor.h"
12 #include "GrDefaultGeoProcFactory.h"
13 #include "GrMeshDrawOp.h"
14 #include "GrSimpleMeshDrawOpHelper.h"
15 
16 class GrDrawAtlasOp final : public GrMeshDrawOp {
17 private:
18     using Helper = GrSimpleMeshDrawOpHelper;
19 
20 public:
21     DEFINE_OP_CLASS_ID
22 
Make(GrContext * context,GrPaint && paint,const SkMatrix & viewMatrix,GrAAType aaType,int spriteCount,const SkRSXform * xforms,const SkRect * rects,const SkColor * colors)23     static std::unique_ptr<GrDrawOp> Make(GrContext* context,
24                                           GrPaint&& paint,
25                                           const SkMatrix& viewMatrix,
26                                           GrAAType aaType,
27                                           int spriteCount,
28                                           const SkRSXform* xforms,
29                                           const SkRect* rects,
30                                           const SkColor* colors) {
31         return Helper::FactoryHelper<GrDrawAtlasOp>(context, std::move(paint), viewMatrix, aaType,
32                                                     spriteCount, xforms, rects, colors);
33     }
34 
35     GrDrawAtlasOp(const Helper::MakeArgs& helperArgs, const SkPMColor4f& color,
36                   const SkMatrix& viewMatrix, GrAAType, int spriteCount, const SkRSXform* xforms,
37                   const SkRect* rects, const SkColor* colors);
38 
name()39     const char* name() const override { return "DrawAtlasOp"; }
40 
visitProxies(const VisitProxyFunc & func,VisitorType)41     void visitProxies(const VisitProxyFunc& func, VisitorType) const override {
42         fHelper.visitProxies(func);
43     }
44 
45 #ifdef SK_DEBUG
46     SkString dumpInfo() const override;
47 #endif
48 
49     FixedFunctionFlags fixedFunctionFlags() const override;
50 
51     GrProcessorSet::Analysis finalize(const GrCaps& caps, const GrAppliedClip* clip) override;
52 
53 private:
54     void onPrepareDraws(Target*) override;
55 
color()56     const SkPMColor4f& color() const { return fColor; }
viewMatrix()57     const SkMatrix& viewMatrix() const { return fViewMatrix; }
hasColors()58     bool hasColors() const { return fHasColors; }
quadCount()59     int quadCount() const { return fQuadCount; }
60 
61     CombineResult onCombineIfPossible(GrOp* t, const GrCaps&) override;
62 
63     struct Geometry {
64         SkPMColor4f fColor;
65         SkTArray<uint8_t, true> fVerts;
66     };
67 
68     SkSTArray<1, Geometry, true> fGeoData;
69     Helper fHelper;
70     SkMatrix fViewMatrix;
71     SkPMColor4f fColor;
72     int fQuadCount;
73     bool fHasColors;
74 
75     typedef GrMeshDrawOp INHERITED;
76 };
77 
78 #endif
79