From 14b8803b7c49b736c756988fe1f5912da907b474 Mon Sep 17 00:00:00 2001 From: jvanverth Date: Fri, 7 Aug 2015 12:18:54 -0700 Subject: Move GrDrawAtlasBatch to separate file Committed: https://skia.googlesource.com/skia/+/b091c44c33edbad3466601b29d60bc2eaa4453fa Review URL: https://codereview.chromium.org/1274013003 --- src/gpu/batches/GrDrawAtlasBatch.h | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/gpu/batches/GrDrawAtlasBatch.h (limited to 'src/gpu/batches/GrDrawAtlasBatch.h') 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 fPositions; + SkTDArray fColors; + SkTDArray 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 -- cgit v1.2.3