• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "src/gpu/GrRenderTask.h"
12 
13 class GrTransferFromRenderTask final : public GrRenderTask {
14 public:
GrTransferFromRenderTask(sk_sp<GrSurfaceProxy> srcProxy,const SkIRect & srcRect,GrColorType surfaceColorType,GrColorType dstColorType,sk_sp<GrGpuBuffer> dstBuffer,size_t dstOffset)15     GrTransferFromRenderTask(sk_sp<GrSurfaceProxy> srcProxy,
16                              const SkIRect& srcRect,
17                              GrColorType surfaceColorType,
18                              GrColorType dstColorType,
19                              sk_sp<GrGpuBuffer> dstBuffer,
20                              size_t dstOffset)
21             : GrRenderTask()
22             , fSrcProxy(std::move(srcProxy))
23             , fSrcRect(srcRect)
24             , fSurfaceColorType(surfaceColorType)
25             , fDstColorType(dstColorType)
26             , fDstBuffer(std::move(dstBuffer))
27             , fDstOffset(dstOffset) {}
28 
29 private:
onIsUsed(GrSurfaceProxy * proxy)30     bool onIsUsed(GrSurfaceProxy* proxy) const override {
31         SkASSERT(!fTargetView.proxy());
32         return proxy == fSrcProxy.get();
33     }
34     // If fSrcProxy is uninstantiated at flush time we simply will skip doing the transfer.
handleInternalAllocationFailure()35     void handleInternalAllocationFailure() override {}
36     void gatherProxyIntervals(GrResourceAllocator*) const override;
37 
onMakeClosed(const GrCaps &,SkIRect *)38     ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect*) override {
39         return ExpectedOutcome::kTargetUnchanged;
40     }
41 
42     bool onExecute(GrOpFlushState*) override;
43 
44 #ifdef SK_DEBUG
visitProxies_debugOnly(const GrOp::VisitProxyFunc & fn)45     void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
46         fn(fSrcProxy.get(), GrMipMapped::kNo);
47     }
48 #endif
49 
50     sk_sp<GrSurfaceProxy> fSrcProxy;
51     SkIRect fSrcRect;
52     GrColorType fSurfaceColorType;
53     GrColorType fDstColorType;
54     sk_sp<GrGpuBuffer> fDstBuffer;
55     size_t fDstOffset;
56 
57 };
58 
59 #endif
60 
61