blob: 515077eb85ca487e2bfe779e14c60ffa17a13bdf [file] [log] [blame]
/*
* Copyright 2019 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrCopyRenderTask_DEFINED
#define GrCopyRenderTask_DEFINED
#include "src/gpu/GrRenderTask.h"
class GrCopyRenderTask final : public GrRenderTask {
public:
/**
* Copies pixels from srcRect in src to SkIRect::MakePtSize(dstPoint, srcRect.dimensions) in
* dst. The src/dst share a common origin.
*/
static sk_sp<GrRenderTask> Make(GrDrawingManager*,
sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
SkIPoint dstPoint,
GrSurfaceOrigin);
private:
GrCopyRenderTask(GrDrawingManager*,
sk_sp<GrSurfaceProxy> src,
SkIRect srcRect,
sk_sp<GrSurfaceProxy> dst,
SkIPoint dstPoint,
GrSurfaceOrigin);
bool onIsUsed(GrSurfaceProxy* proxy) const override { return proxy == fSrc.get(); }
// If instantiation failed, at flush time we simply will skip doing the copy.
void handleInternalAllocationFailure() override {}
void gatherProxyIntervals(GrResourceAllocator*) const override;
ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override;
bool onExecute(GrOpFlushState*) override;
#if GR_TEST_UTILS
const char* name() const final { return "Copy"; }
#endif
#ifdef SK_DEBUG
void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
fn(fSrc.get(), GrMipmapped::kNo);
}
#endif
sk_sp<GrSurfaceProxy> fSrc;
SkIRect fSrcRect;
SkIPoint fDstPoint;
GrSurfaceOrigin fOrigin;
};
#endif