• 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 GrCopyRenderTask_DEFINED
9 #define GrCopyRenderTask_DEFINED
10 
11 #include "src/gpu/GrRenderTask.h"
12 
13 class GrCopyRenderTask final : public GrRenderTask {
14 public:
15     /**
16      * Copies pixels from srcRect in src to SkIRect::MakePtSize(dstPoint, srcRect.dimensions) in
17      * dst. The src/dst share a common origin.
18      */
19     static sk_sp<GrRenderTask> Make(GrDrawingManager*,
20                                     sk_sp<GrSurfaceProxy> src,
21                                     SkIRect srcRect,
22                                     sk_sp<GrSurfaceProxy> dst,
23                                     SkIPoint dstPoint,
24                                     GrSurfaceOrigin);
25 
26 private:
27     GrCopyRenderTask(GrDrawingManager*,
28                      sk_sp<GrSurfaceProxy> src,
29                      SkIRect srcRect,
30                      sk_sp<GrSurfaceProxy> dst,
31                      SkIPoint dstPoint,
32                      GrSurfaceOrigin);
33 
onMakeSkippable()34     void onMakeSkippable() override { fSrc.reset(); }
onIsUsed(GrSurfaceProxy * proxy)35     bool onIsUsed(GrSurfaceProxy* proxy) const override { return proxy == fSrc.get(); }
36     void gatherProxyIntervals(GrResourceAllocator*) const override;
37     ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override;
38     bool onExecute(GrOpFlushState*) override;
39 
40 #if GR_TEST_UTILS
name()41     const char* name() const final { return "Copy"; }
42 #endif
43 #ifdef SK_DEBUG
visitProxies_debugOnly(const GrOp::VisitProxyFunc & fn)44     void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
45         fn(fSrc.get(), GrMipmapped::kNo);
46     }
47 #endif
48 
49     sk_sp<GrSurfaceProxy> fSrc;
50     SkIRect fSrcRect;
51     SkIPoint fDstPoint;
52     GrSurfaceOrigin fOrigin;
53 };
54 
55 #endif
56 
57