• 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(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(GrPaint&& paint, const SkMatrix& viewMatrix,
24                                           GrAAType aaType, int spriteCount, const SkRSXform* xforms,
25                                           const SkRect* rects, const SkColor* colors) {
26         return Helper::FactoryHelper<GrDrawAtlasOp>(std::move(paint), viewMatrix, aaType,
27                                                     spriteCount, xforms, rects, colors);
28     }
29 
30     GrDrawAtlasOp(const Helper::MakeArgs& helperArgs, GrColor color, const SkMatrix& viewMatrix,
31                   GrAAType, int spriteCount, const SkRSXform* xforms, const SkRect* rects,
32                   const SkColor* colors);
33 
name()34     const char* name() const override { return "DrawAtlasOp"; }
35 
36     SkString dumpInfo() const override;
37 
38     FixedFunctionFlags fixedFunctionFlags() const override;
39 
40     RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override;
41 
42 private:
43     void onPrepareDraws(Target*) const override;
44 
color()45     GrColor color() const { return fColor; }
viewMatrix()46     const SkMatrix& viewMatrix() const { return fViewMatrix; }
hasColors()47     bool hasColors() const { return fHasColors; }
quadCount()48     int quadCount() const { return fQuadCount; }
49 
50     bool onCombineIfPossible(GrOp* t, const GrCaps&) override;
51 
52     struct Geometry {
53         GrColor fColor;
54         SkTArray<uint8_t, true> fVerts;
55     };
56 
57     SkSTArray<1, Geometry, true> fGeoData;
58     Helper fHelper;
59     SkMatrix fViewMatrix;
60     GrColor fColor;
61     int fQuadCount;
62     bool fHasColors;
63 
64     typedef GrMeshDrawOp INHERITED;
65 };
66 
67 #endif
68