xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrCopyRenderTask.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 GrCopyRenderTask_DEFINED
9 #define GrCopyRenderTask_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/SkDebug.h"
15 #include "include/private/gpu/ganesh/GrTypesPriv.h"
16 #include "src/gpu/ganesh/GrRenderTask.h"
17 #include "src/gpu/ganesh/GrSamplerState.h"
18 #include "src/gpu/ganesh/GrSurfaceProxy.h"
19 
20 class GrDrawingManager;
21 class GrOpFlushState;
22 class GrRecordingContext;
23 class GrResourceAllocator;
24 enum GrSurfaceOrigin : int;
25 
26 class GrCopyRenderTask final : public GrRenderTask {
27 public:
28     /**
29      * Copies pixels from srcRect in src to dstRect in dst. srcRect and dstRect must both be
30      * contained in their respective surface dimensions; they do not have to have the same size
31      * if the GPU supports scaling and filtering while copying. The src/dst share a common origin.
32      */
33     static sk_sp<GrRenderTask> Make(GrDrawingManager*,
34                                     sk_sp<GrSurfaceProxy> dst,
35                                     SkIRect dstRect,
36                                     sk_sp<GrSurfaceProxy> src,
37                                     SkIRect srcRect,
38                                     GrSamplerState::Filter filter,
39                                     GrSurfaceOrigin);
40 
41 private:
42     GrCopyRenderTask(GrDrawingManager*,
43                      sk_sp<GrSurfaceProxy> dst,
44                      SkIRect dstRect,
45                      sk_sp<GrSurfaceProxy> src,
46                      SkIRect srcRect,
47                      GrSamplerState::Filter filter,
48                      GrSurfaceOrigin);
49 
onMakeSkippable()50     void onMakeSkippable() override { fSrc.reset(); }
onIsUsed(GrSurfaceProxy * proxy)51     bool onIsUsed(GrSurfaceProxy* proxy) const override { return proxy == fSrc.get(); }
52     void gatherProxyIntervals(GrResourceAllocator*) const override;
53     ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override;
54     bool onExecute(GrOpFlushState*) override;
55 
56 #if defined(GPU_TEST_UTILS)
name()57     const char* name() const final { return "Copy"; }
58 #endif
59 #ifdef SK_DEBUG
visitProxies_debugOnly(const GrVisitProxyFunc & func)60     void visitProxies_debugOnly(const GrVisitProxyFunc& func) const override {
61         func(fSrc.get(), skgpu::Mipmapped::kNo);
62     }
63 #endif
64 
65     sk_sp<GrSurfaceProxy> fSrc;
66     SkIRect fSrcRect;
67     SkIRect fDstRect;
68     GrSamplerState::Filter fFilter;
69     GrSurfaceOrigin fOrigin;
70 };
71 
72 #endif
73 
74