diff options
author | jvanverth <jvanverth@google.com> | 2015-08-07 12:18:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-07 12:18:54 -0700 |
commit | 14b8803b7c49b736c756988fe1f5912da907b474 (patch) | |
tree | 6321e4ccc8864c6a663ca6daf308798fd17a0061 /src/gpu/batches/GrDrawAtlasBatch.h | |
parent | 1694a936f65cc53729affe18c17497af821cc262 (diff) |
Move GrDrawAtlasBatch to separate file
Committed: https://skia.googlesource.com/skia/+/b091c44c33edbad3466601b29d60bc2eaa4453fa
Review URL: https://codereview.chromium.org/1274013003
Diffstat (limited to 'src/gpu/batches/GrDrawAtlasBatch.h')
-rw-r--r-- | src/gpu/batches/GrDrawAtlasBatch.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/gpu/batches/GrDrawAtlasBatch.h b/src/gpu/batches/GrDrawAtlasBatch.h new file mode 100644 index 0000000000..3a47b718cf --- /dev/null +++ b/src/gpu/batches/GrDrawAtlasBatch.h @@ -0,0 +1,75 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrDrawAtlasBatch_DEFINED +#define GrDrawAtlasBatch_DEFINED + +#include "GrBatch.h" +#include "GrColor.h" +#include "GrDefaultGeoProcFactory.h" + +class GrDrawAtlasBatch : public GrBatch { +public: + struct Geometry { + GrColor fColor; + SkTDArray<SkPoint> fPositions; + SkTDArray<GrColor> fColors; + SkTDArray<SkPoint> fLocalCoords; + }; + + static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix, + const SkPoint* positions, int vertexCount, + const GrColor* colors, const SkPoint* localCoords, + const SkRect& bounds) { + return SkNEW_ARGS(GrDrawAtlasBatch, (geometry, viewMatrix, positions, + vertexCount, colors, localCoords, bounds)); + } + + const char* name() const override { return "DrawAtlasBatch"; } + + void getInvariantOutputColor(GrInitInvariantOutput* out) const override { + // When this is called on a batch, there is only one geometry bundle + if (this->hasColors()) { + out->setUnknownFourComponents(); + } else { + out->setKnownFourComponents(fGeoData[0].fColor); + } + } + + void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { + out->setKnownSingleComponent(0xff); + } + + void initBatchTracker(const GrPipelineInfo& init) override; + void generateGeometry(GrBatchTarget* batchTarget) override; + + SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } + +private: + GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix, + const SkPoint* positions, int vertexCount, + const GrColor* colors, const SkPoint* localCoords, const SkRect& bounds); + + GrColor color() const { return fColor; } + bool colorIgnored() const { return fColorIgnored; } + const SkMatrix& viewMatrix() const { return fViewMatrix; } + bool hasColors() const { return fHasColors; } + int vertexCount() const { return fVertexCount; } + bool coverageIgnored() const { return fCoverageIgnored; } + + bool onCombineIfPossible(GrBatch* t) override; + SkSTArray<1, Geometry, true> fGeoData; + + SkMatrix fViewMatrix; + GrColor fColor; + int fVertexCount; + bool fColorIgnored; + bool fCoverageIgnored; + bool fHasColors; +}; + +#endif |