GrGeometryProcessor.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2013 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. #ifndef GrGeometryProcessor_DEFINED
  8. #define GrGeometryProcessor_DEFINED
  9. #include "src/gpu/GrPrimitiveProcessor.h"
  10. /**
  11. * A GrGeometryProcessor is a flexible method for rendering a primitive. The GrGeometryProcessor
  12. * has complete control over vertex attributes and uniforms(aside from the render target) but it
  13. * must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and
  14. * coverage into the fragment shader. Where this color and coverage come from is completely the
  15. * responsibility of the GrGeometryProcessor.
  16. */
  17. class GrGeometryProcessor : public GrPrimitiveProcessor {
  18. public:
  19. GrGeometryProcessor(ClassID classID)
  20. : INHERITED(classID)
  21. , fWillUseGeoShader(false) {}
  22. bool willUseGeoShader() const final { return fWillUseGeoShader; }
  23. protected:
  24. void setWillUseGeoShader() { fWillUseGeoShader = true; }
  25. // GPs that need to use either half-float or ubyte colors can just call this to get a correctly
  26. // configured Attribute struct
  27. static Attribute MakeColorAttribute(const char* name, bool wideColor) {
  28. return { name,
  29. wideColor ? kHalf4_GrVertexAttribType : kUByte4_norm_GrVertexAttribType,
  30. kHalf4_GrSLType };
  31. }
  32. private:
  33. bool fWillUseGeoShader;
  34. typedef GrPrimitiveProcessor INHERITED;
  35. };
  36. #endif