xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrBufferTransferRenderTask.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1  /*
2   * Copyright 2022 Google LLC
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  
8  #ifndef GrBufferTransferRenderTask_DEFINED
9  #define GrBufferTransferRenderTask_DEFINED
10  
11  #include "include/core/SkRefCnt.h"
12  #include "include/private/base/SkDebug.h"
13  #include "include/private/gpu/ganesh/GrTypesPriv.h"
14  #include "src/gpu/ganesh/GrRenderTask.h"
15  
16  #include <cstddef>
17  
18  class GrGpuBuffer;
19  class GrOpFlushState;
20  class GrRecordingContext;
21  class GrResourceAllocator;
22  class GrSurfaceProxy;
23  struct SkIRect;
24  
25  class GrBufferTransferRenderTask final : public GrRenderTask {
26  public:
27      static sk_sp<GrRenderTask> Make(sk_sp<GrGpuBuffer> src,
28                                      size_t srcOffset,
29                                      sk_sp<GrGpuBuffer> dst,
30                                      size_t dstOffset,
31                                      size_t size);
32  
33      ~GrBufferTransferRenderTask() override;
34  
35  private:
36      GrBufferTransferRenderTask(sk_sp<GrGpuBuffer> src,
37                                 size_t srcOffset,
38                                 sk_sp<GrGpuBuffer> dst,
39                                 size_t dstOffset,
40                                 size_t size);
41  
onIsUsed(GrSurfaceProxy * proxy)42      bool onIsUsed(GrSurfaceProxy* proxy) const override { return false; }
gatherProxyIntervals(GrResourceAllocator *)43      void gatherProxyIntervals(GrResourceAllocator*) const override {} // no proxies
onMakeClosed(GrRecordingContext *,SkIRect * targetUpdateBounds)44      ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override {
45          return ExpectedOutcome::kTargetUnchanged;  // no target
46      }
47      bool onExecute(GrOpFlushState*) override;
48  
49  #if defined(GPU_TEST_UTILS)
name()50      const char* name() const final { return "BufferTransfer"; }
51  #endif
52  #ifdef SK_DEBUG
visitProxies_debugOnly(const GrVisitProxyFunc &)53      void visitProxies_debugOnly(const GrVisitProxyFunc&) const override {}
54  #endif
55  
56      sk_sp<GrGpuBuffer> fSrc;
57      sk_sp<GrGpuBuffer> fDst;
58  
59      size_t fSrcOffset;
60      size_t fDstOffset;
61      size_t fSize;
62  };
63  
64  #endif
65