GrDrawAtlasOp.h revision f1748f5a9238a0d3e189d50fc5e57ae8b8ec087c
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
16class GrDrawAtlasOp final : public GrMeshDrawOp {
17private:
18    using Helper = GrSimpleMeshDrawOpHelper;
19
20public:
21    DEFINE_OP_CLASS_ID
22
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
34    const char* name() const override { return "DrawAtlasOp"; }
35
36    void visitProxies(const VisitProxyFunc& func) const override {
37        fHelper.visitProxies(func);
38    }
39
40    SkString dumpInfo() const override;
41
42    FixedFunctionFlags fixedFunctionFlags() const override;
43
44    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override;
45
46private:
47    void onPrepareDraws(Target*) override;
48
49    GrColor color() const { return fColor; }
50    const SkMatrix& viewMatrix() const { return fViewMatrix; }
51    bool hasColors() const { return fHasColors; }
52    int quadCount() const { return fQuadCount; }
53
54    bool onCombineIfPossible(GrOp* t, const GrCaps&) override;
55
56    struct Geometry {
57        GrColor fColor;
58        SkTArray<uint8_t, true> fVerts;
59    };
60
61    SkSTArray<1, Geometry, true> fGeoData;
62    Helper fHelper;
63    SkMatrix fViewMatrix;
64    GrColor fColor;
65    int fQuadCount;
66    bool fHasColors;
67
68    typedef GrMeshDrawOp INHERITED;
69};
70
71#endif
72