SkDeferredDisplayList.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2017 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 SkDeferredDisplayList_DEFINED
  8. #define SkDeferredDisplayList_DEFINED
  9. #include "include/core/SkRefCnt.h"
  10. #include "include/core/SkSurfaceCharacterization.h"
  11. #include "include/core/SkTypes.h"
  12. class SkDeferredDisplayListPriv;
  13. #if SK_SUPPORT_GPU
  14. #include "include/private/SkTArray.h"
  15. #include <map>
  16. class GrOpList;
  17. class GrRenderTargetProxy;
  18. struct GrCCPerOpListPaths;
  19. #endif
  20. /*
  21. * This class contains pre-processed gpu operations that can be replayed into
  22. * an SkSurface via draw(SkDeferredDisplayList*).
  23. *
  24. * TODO: we probably need to expose this class so users can query it for memory usage.
  25. */
  26. class SkDeferredDisplayList {
  27. public:
  28. #if SK_SUPPORT_GPU
  29. // This object is the source from which the lazy proxy backing the DDL will pull its backing
  30. // texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy
  31. // can outlive the DDL.
  32. class SK_API LazyProxyData : public SkRefCnt {
  33. public:
  34. // Upon being replayed - this field will be filled in (by the DrawingManager) with the proxy
  35. // backing the destination SkSurface. Note that, since there is no good place to clear it
  36. // it can become a dangling pointer.
  37. GrRenderTargetProxy* fReplayDest = nullptr;
  38. };
  39. #else
  40. class SK_API LazyProxyData : public SkRefCnt {};
  41. #endif
  42. SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
  43. sk_sp<LazyProxyData>);
  44. SK_API ~SkDeferredDisplayList();
  45. SK_API const SkSurfaceCharacterization& characterization() const {
  46. return fCharacterization;
  47. }
  48. // Provides access to functions that aren't part of the public API.
  49. SkDeferredDisplayListPriv priv();
  50. const SkDeferredDisplayListPriv priv() const;
  51. private:
  52. friend class GrDrawingManager; // for access to 'fOpLists' and 'fLazyProxyData'
  53. friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
  54. friend class SkDeferredDisplayListPriv;
  55. const SkSurfaceCharacterization fCharacterization;
  56. #if SK_SUPPORT_GPU
  57. // This needs to match the same type in GrCoverageCountingPathRenderer.h
  58. using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpListPaths>>;
  59. SkTArray<sk_sp<GrOpList>> fOpLists;
  60. PendingPathsMap fPendingPaths; // This is the path data from CCPR.
  61. #endif
  62. sk_sp<LazyProxyData> fLazyProxyData;
  63. };
  64. #endif