GrTextureOpList.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2016 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 GrTexureOpList_DEFINED
  8. #define GrTexureOpList_DEFINED
  9. #include "include/gpu/GrGpuResource.h"
  10. #include "src/gpu/GrOpList.h"
  11. #include "src/gpu/GrSurfaceProxy.h"
  12. #include "include/private/SkTArray.h"
  13. class GrAuditTrail;
  14. class GrGpu;
  15. class GrOp;
  16. class GrTextureProxy;
  17. struct SkIPoint;
  18. struct SkIRect;
  19. class GrTextureOpList final : public GrOpList {
  20. public:
  21. GrTextureOpList(sk_sp<GrOpMemoryPool>, sk_sp<GrTextureProxy>, GrAuditTrail*);
  22. ~GrTextureOpList() override;
  23. /**
  24. * Empties the draw buffer of any queued ops.
  25. */
  26. void endFlush() override;
  27. /**
  28. * Together these two functions flush all queued ops to GrGpuCommandBuffer. The return value
  29. * of executeOps() indicates whether any commands were actually issued to the GPU.
  30. */
  31. void onPrepare(GrOpFlushState* flushState) override;
  32. bool onExecute(GrOpFlushState* flushState) override;
  33. /**
  34. * Copies a pixel rectangle from one surface to another. This call may finalize
  35. * reserved vertex/index data (as though a draw call was made). The src pixels
  36. * copied are specified by srcRect. They are copied to a rect of the same
  37. * size in dst with top left at dstPoint. If the src rect is clipped by the
  38. * src bounds then pixel values in the dst rect corresponding to area clipped
  39. * by the src rect are not overwritten. This method is not guaranteed to succeed
  40. * depending on the type of surface, configs, etc, and the backend-specific
  41. * limitations.
  42. */
  43. bool copySurface(GrRecordingContext*,
  44. GrSurfaceProxy* dst,
  45. GrSurfaceProxy* src,
  46. const SkIRect& srcRect,
  47. const SkIPoint& dstPoint) override;
  48. GrTextureOpList* asTextureOpList() override { return this; }
  49. SkDEBUGCODE(void dump(bool printDependencies) const override;)
  50. private:
  51. bool onIsUsed(GrSurfaceProxy*) const override;
  52. void deleteOp(int index);
  53. void deleteOps();
  54. void purgeOpsWithUninstantiatedProxies() override;
  55. void gatherProxyIntervals(GrResourceAllocator*) const override;
  56. void recordOp(std::unique_ptr<GrOp>);
  57. // The memory for the ops in 'fOpChains' is actually stored in 'fOpMemoryPool'
  58. SkSTArray<2, std::unique_ptr<GrOp>, true> fRecordedOps;
  59. typedef GrOpList INHERITED;
  60. };
  61. #endif