1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2019 Google LLC
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#ifndef GrCopyRenderTask_DEFINED
9cb93a386Sopenharmony_ci#define GrCopyRenderTask_DEFINED
10cb93a386Sopenharmony_ci
11cb93a386Sopenharmony_ci#include "src/gpu/GrRenderTask.h"
12cb93a386Sopenharmony_ci
13cb93a386Sopenharmony_ciclass GrCopyRenderTask final : public GrRenderTask {
14cb93a386Sopenharmony_cipublic:
15cb93a386Sopenharmony_ci    /**
16cb93a386Sopenharmony_ci     * Copies pixels from srcRect in src to SkIRect::MakePtSize(dstPoint, srcRect.dimensions) in
17cb93a386Sopenharmony_ci     * dst. The src/dst share a common origin.
18cb93a386Sopenharmony_ci     */
19cb93a386Sopenharmony_ci    static sk_sp<GrRenderTask> Make(GrDrawingManager*,
20cb93a386Sopenharmony_ci                                    sk_sp<GrSurfaceProxy> src,
21cb93a386Sopenharmony_ci                                    SkIRect srcRect,
22cb93a386Sopenharmony_ci                                    sk_sp<GrSurfaceProxy> dst,
23cb93a386Sopenharmony_ci                                    SkIPoint dstPoint,
24cb93a386Sopenharmony_ci                                    GrSurfaceOrigin);
25cb93a386Sopenharmony_ci
26cb93a386Sopenharmony_ciprivate:
27cb93a386Sopenharmony_ci    GrCopyRenderTask(GrDrawingManager*,
28cb93a386Sopenharmony_ci                     sk_sp<GrSurfaceProxy> src,
29cb93a386Sopenharmony_ci                     SkIRect srcRect,
30cb93a386Sopenharmony_ci                     sk_sp<GrSurfaceProxy> dst,
31cb93a386Sopenharmony_ci                     SkIPoint dstPoint,
32cb93a386Sopenharmony_ci                     GrSurfaceOrigin);
33cb93a386Sopenharmony_ci
34cb93a386Sopenharmony_ci    void onMakeSkippable() override { fSrc.reset(); }
35cb93a386Sopenharmony_ci    bool onIsUsed(GrSurfaceProxy* proxy) const override { return proxy == fSrc.get(); }
36cb93a386Sopenharmony_ci    void gatherProxyIntervals(GrResourceAllocator*) const override;
37cb93a386Sopenharmony_ci    ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override;
38cb93a386Sopenharmony_ci    bool onExecute(GrOpFlushState*) override;
39cb93a386Sopenharmony_ci
40cb93a386Sopenharmony_ci#if GR_TEST_UTILS
41cb93a386Sopenharmony_ci    const char* name() const final { return "Copy"; }
42cb93a386Sopenharmony_ci#endif
43cb93a386Sopenharmony_ci#ifdef SK_DEBUG
44cb93a386Sopenharmony_ci    void visitProxies_debugOnly(const GrVisitProxyFunc& func) const override {
45cb93a386Sopenharmony_ci        func(fSrc.get(), GrMipmapped::kNo);
46cb93a386Sopenharmony_ci    }
47cb93a386Sopenharmony_ci#endif
48cb93a386Sopenharmony_ci
49cb93a386Sopenharmony_ci    sk_sp<GrSurfaceProxy> fSrc;
50cb93a386Sopenharmony_ci    SkIRect fSrcRect;
51cb93a386Sopenharmony_ci    SkIPoint fDstPoint;
52cb93a386Sopenharmony_ci    GrSurfaceOrigin fOrigin;
53cb93a386Sopenharmony_ci};
54cb93a386Sopenharmony_ci
55cb93a386Sopenharmony_ci#endif
56cb93a386Sopenharmony_ci
57