blob: 7c3bceb1e0bfe3733fd40eccc756ae379ce84995 [file] [log] [blame]
jvanverth14b88032015-08-07 12:18:54 -07001/*
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
Brian Salomonfc527d22016-12-14 21:07:01 -05008#ifndef GrDrawAtlasOp_DEFINED
9#define GrDrawAtlasOp_DEFINED
jvanverth14b88032015-08-07 12:18:54 -070010
jvanverth14b88032015-08-07 12:18:54 -070011#include "GrColor.h"
12#include "GrDefaultGeoProcFactory.h"
Brian Salomondad29232016-12-01 16:40:24 -050013#include "GrMeshDrawOp.h"
Brian Salomon0088f942017-07-12 11:51:27 -040014#include "GrSimpleMeshDrawOpHelper.h"
jvanverth14b88032015-08-07 12:18:54 -070015
Brian Salomon0088f942017-07-12 11:51:27 -040016class GrDrawAtlasOp final : public GrMeshDrawOp {
17private:
18 using Helper = GrSimpleMeshDrawOpHelper;
19
jvanverth14b88032015-08-07 12:18:54 -070020public:
Brian Salomon25a88092016-12-01 09:36:50 -050021 DEFINE_OP_CLASS_ID
reed1b55a962015-09-17 20:16:13 -070022
Brian Salomon0088f942017-07-12 11:51:27 -040023 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);
Brian Salomonfc527d22016-12-14 21:07:01 -050028 }
halcanary9d524f22016-03-29 09:03:52 -070029
Brian Salomon0088f942017-07-12 11:51:27 -040030 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
Brian Salomonfc527d22016-12-14 21:07:01 -050034 const char* name() const override { return "DrawAtlasOp"; }
halcanary9d524f22016-03-29 09:03:52 -070035
Brian Salomon0088f942017-07-12 11:51:27 -040036 SkString dumpInfo() const override;
37
38 FixedFunctionFlags fixedFunctionFlags() const override;
39
40 RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override;
Brian Salomon7c3e7182016-12-01 09:35:30 -050041
jvanverth14b88032015-08-07 12:18:54 -070042private:
Brian Salomon91326c32017-08-09 16:02:19 -040043 void onPrepareDraws(Target*) override;
bsalomon75398562015-08-17 12:55:38 -070044
jvanverth14b88032015-08-07 12:18:54 -070045 GrColor color() const { return fColor; }
jvanverth14b88032015-08-07 12:18:54 -070046 const SkMatrix& viewMatrix() const { return fViewMatrix; }
47 bool hasColors() const { return fHasColors; }
jvanverth5a4d2352015-08-12 08:15:31 -070048 int quadCount() const { return fQuadCount; }
halcanary9d524f22016-03-29 09:03:52 -070049
Brian Salomon25a88092016-12-01 09:36:50 -050050 bool onCombineIfPossible(GrOp* t, const GrCaps&) override;
bsalomon0432dd62016-06-30 07:19:27 -070051
52 struct Geometry {
Brian Salomonfc527d22016-12-14 21:07:01 -050053 GrColor fColor;
bsalomon0432dd62016-06-30 07:19:27 -070054 SkTArray<uint8_t, true> fVerts;
55 };
56
jvanverth14b88032015-08-07 12:18:54 -070057 SkSTArray<1, Geometry, true> fGeoData;
Brian Salomon0088f942017-07-12 11:51:27 -040058 Helper fHelper;
jvanverth14b88032015-08-07 12:18:54 -070059 SkMatrix fViewMatrix;
Brian Salomonfc527d22016-12-14 21:07:01 -050060 GrColor fColor;
61 int fQuadCount;
Brian Salomonfc527d22016-12-14 21:07:01 -050062 bool fHasColors;
reed1b55a962015-09-17 20:16:13 -070063
Brian Salomon0088f942017-07-12 11:51:27 -040064 typedef GrMeshDrawOp INHERITED;
jvanverth14b88032015-08-07 12:18:54 -070065};
66
67#endif