SkDeferredDisplayList.h 2.4 KB

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