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 GrTestMeshDrawOp_DEFINED 9 #define GrTestMeshDrawOp_DEFINED 10 11 #include "GrGeometryProcessor.h" 12 #include "GrOpFlushState.h" 13 14 #include "ops/GrMeshDrawOp.h" 15 16 /* 17 * A simple solid color GrMeshDrawOp for testing purposes which doesn't ever combine. Subclassing 18 * this in tests saves having to fill out some boiler plate methods. 19 */ 20 class GrTestMeshDrawOp : public GrMeshDrawOp { 21 public: 22 const char* name() const override = 0; 23 24 protected: GrTestMeshDrawOp(uint32_t classID,const SkRect & bounds,GrColor color)25 GrTestMeshDrawOp(uint32_t classID, const SkRect& bounds, GrColor color) 26 : INHERITED(classID), fColor(color) { 27 // Choose some conservative values for aa bloat and zero area. 28 this->setBounds(bounds, HasAABloat::kYes, IsZeroArea::kYes); 29 } 30 color()31 GrColor color() const { return fColor; } 32 usesLocalCoords()33 bool usesLocalCoords() const { return fUsesLocalCoords; } 34 35 private: getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor * color,GrPipelineAnalysisCoverage * coverage)36 void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, 37 GrPipelineAnalysisCoverage* coverage) const override { 38 color->setToConstant(fColor); 39 *coverage = GrPipelineAnalysisCoverage::kSingleChannel; 40 } 41 applyPipelineOptimizations(const GrPipelineOptimizations & optimizations)42 void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { 43 optimizations.getOverrideColorIfSet(&fColor); 44 fUsesLocalCoords = optimizations.readsLocalCoords(); 45 } 46 onCombineIfPossible(GrOp *,const GrCaps &)47 bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; } 48 49 GrColor fColor; 50 bool fUsesLocalCoords = false; 51 52 typedef GrMeshDrawOp INHERITED; 53 }; 54 55 #endif 56