xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrTransferFromRenderTask.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2019 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 GrTransferFromRenderTask_DEFINED
9 #define GrTransferFromRenderTask_DEFINED
10 
11 #include "include/core/SkRect.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/gpu/GpuTypes.h"
14 #include "include/private/base/SkAssert.h"
15 #include "include/private/base/SkDebug.h"
16 #include "include/private/gpu/ganesh/GrTypesPriv.h"
17 #include "src/gpu/ganesh/GrGpuBuffer.h"
18 #include "src/gpu/ganesh/GrRenderTask.h"
19 #include "src/gpu/ganesh/GrSurfaceProxy.h"
20 
21 #include <cstddef>
22 #include <utility>
23 
24 class GrOpFlushState;
25 class GrRecordingContext;
26 class GrResourceAllocator;
27 
28 class GrTransferFromRenderTask final : public GrRenderTask {
29 public:
GrTransferFromRenderTask(sk_sp<GrSurfaceProxy> srcProxy,const SkIRect & srcRect,GrColorType surfaceColorType,GrColorType dstColorType,sk_sp<GrGpuBuffer> dstBuffer,size_t dstOffset)30     GrTransferFromRenderTask(sk_sp<GrSurfaceProxy> srcProxy,
31                              const SkIRect& srcRect,
32                              GrColorType surfaceColorType,
33                              GrColorType dstColorType,
34                              sk_sp<GrGpuBuffer> dstBuffer,
35                              size_t dstOffset)
36             : GrRenderTask()
37             , fSrcProxy(std::move(srcProxy))
38             , fSrcRect(srcRect)
39             , fSurfaceColorType(surfaceColorType)
40             , fDstColorType(dstColorType)
41             , fDstBuffer(std::move(dstBuffer))
42             , fDstOffset(dstOffset) {}
43 
44 private:
onIsUsed(GrSurfaceProxy * proxy)45     bool onIsUsed(GrSurfaceProxy* proxy) const override {
46         SkASSERT(0 == this->numTargets());
47         return proxy == fSrcProxy.get();
48     }
49     void gatherProxyIntervals(GrResourceAllocator*) const override;
50 
onMakeClosed(GrRecordingContext *,SkIRect *)51     ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override {
52         return ExpectedOutcome::kTargetUnchanged;
53     }
54 
55     bool onExecute(GrOpFlushState*) override;
56 
57 #if defined(GPU_TEST_UTILS)
name()58     const char* name() const final { return "TransferFrom"; }
59 #endif
60 #ifdef SK_DEBUG
visitProxies_debugOnly(const GrVisitProxyFunc & func)61     void visitProxies_debugOnly(const GrVisitProxyFunc& func) const override {
62         func(fSrcProxy.get(), skgpu::Mipmapped::kNo);
63     }
64 #endif
65 
66     sk_sp<GrSurfaceProxy> fSrcProxy;
67     SkIRect fSrcRect;
68     GrColorType fSurfaceColorType;
69     GrColorType fDstColorType;
70     sk_sp<GrGpuBuffer> fDstBuffer;
71     size_t fDstOffset;
72 
73 };
74 
75 #endif
76 
77