GrPath.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2012 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 GrPath_DEFINED
  8. #define GrPath_DEFINED
  9. #include "include/core/SkPath.h"
  10. #include "include/core/SkRect.h"
  11. #include "include/gpu/GrGpuResource.h"
  12. #include "src/gpu/GrPathRendering.h"
  13. #include "src/gpu/GrStyle.h"
  14. class GrShape;
  15. class GrPath : public GrGpuResource {
  16. public:
  17. /**
  18. * Initialize to a path with a fixed stroke. Stroke must not be hairline.
  19. */
  20. GrPath(GrGpu* gpu, const SkPath& skPath, const GrStyle& style)
  21. : INHERITED(gpu)
  22. , fBounds(SkRect::MakeEmpty())
  23. , fFillType(GrPathRendering::kWinding_FillType)
  24. #ifdef SK_DEBUG
  25. , fSkPath(skPath)
  26. , fStyle(style)
  27. #endif
  28. {
  29. }
  30. static void ComputeKey(const GrShape&, GrUniqueKey* key, bool* outIsVolatile);
  31. const SkRect& getBounds() const { return fBounds; }
  32. GrPathRendering::FillType getFillType() const { return fFillType; }
  33. #ifdef SK_DEBUG
  34. bool isEqualTo(const SkPath& path, const GrStyle& style) const;
  35. #endif
  36. protected:
  37. // Subclass should init these.
  38. SkRect fBounds;
  39. GrPathRendering::FillType fFillType;
  40. #ifdef SK_DEBUG
  41. SkPath fSkPath;
  42. GrStyle fStyle;
  43. #endif
  44. private:
  45. const char* getResourceType() const override { return "Path Data"; }
  46. typedef GrGpuResource INHERITED;
  47. };
  48. #endif