GrSmallPathRenderer.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2014 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 GrSmallPathRenderer_DEFINED
  8. #define GrSmallPathRenderer_DEFINED
  9. #include "src/gpu/GrDrawOpAtlas.h"
  10. #include "src/gpu/GrOnFlushResourceProvider.h"
  11. #include "src/gpu/GrPathRenderer.h"
  12. #include "src/gpu/geometry/GrRect.h"
  13. #include "src/gpu/geometry/GrShape.h"
  14. #include "src/core/SkOpts.h"
  15. #include "src/core/SkTDynamicHash.h"
  16. class GrRecordingContext;
  17. class ShapeData;
  18. class ShapeDataKey;
  19. class GrSmallPathRenderer : public GrPathRenderer, public GrOnFlushCallbackObject {
  20. public:
  21. GrSmallPathRenderer();
  22. ~GrSmallPathRenderer() override;
  23. // GrOnFlushCallbackObject overrides
  24. //
  25. // Note: because this class is associated with a path renderer we want it to be removed from
  26. // the list of active OnFlushBackkbackObjects in an freeGpuResources call (i.e., we accept the
  27. // default retainOnFreeGpuResources implementation).
  28. void preFlush(GrOnFlushResourceProvider* onFlushResourceProvider, const uint32_t*, int,
  29. SkTArray<sk_sp<GrRenderTargetContext>>*) override {
  30. if (fAtlas) {
  31. fAtlas->instantiate(onFlushResourceProvider);
  32. }
  33. }
  34. void postFlush(GrDeferredUploadToken startTokenForNextFlush,
  35. const uint32_t* /*opListIDs*/, int /*numOpListIDs*/) override {
  36. if (fAtlas) {
  37. fAtlas->compact(startTokenForNextFlush);
  38. }
  39. }
  40. using ShapeCache = SkTDynamicHash<ShapeData, ShapeDataKey>;
  41. typedef SkTInternalLList<ShapeData> ShapeDataList;
  42. static std::unique_ptr<GrDrawOp> createOp_TestingOnly(GrRecordingContext*,
  43. GrPaint&&,
  44. const GrShape&,
  45. const SkMatrix& viewMatrix,
  46. GrDrawOpAtlas* atlas,
  47. ShapeCache*,
  48. ShapeDataList*,
  49. bool gammaCorrect,
  50. const GrUserStencilSettings*);
  51. struct PathTestStruct;
  52. private:
  53. class SmallPathOp;
  54. StencilSupport onGetStencilSupport(const GrShape&) const override {
  55. return GrPathRenderer::kNoSupport_StencilSupport;
  56. }
  57. CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
  58. bool onDrawPath(const DrawPathArgs&) override;
  59. static void HandleEviction(GrDrawOpAtlas::AtlasID, void*);
  60. std::unique_ptr<GrDrawOpAtlas> fAtlas;
  61. ShapeCache fShapeCache;
  62. ShapeDataList fShapeList;
  63. typedef GrPathRenderer INHERITED;
  64. };
  65. #endif