blob: aa80be4bf9546286fbc47a31b5d3878f9e77cba4 [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 GrTransferFromRenderTask_DEFINED
#define GrTransferFromRenderTask_DEFINED
#include "src/gpu/GrRenderTask.h"
class GrTransferFromRenderTask final : public GrRenderTask {
GrTransferFromRenderTask(sk_sp<GrSurfaceProxy> srcProxy,
const SkIRect& srcRect,
GrColorType surfaceColorType,
GrColorType dstColorType,
sk_sp<GrGpuBuffer> dstBuffer,
size_t dstOffset)
: GrRenderTask()
, fSrcProxy(std::move(srcProxy))
, fSrcRect(srcRect)
, fSurfaceColorType(surfaceColorType)
, fDstColorType(dstColorType)
, fDstBuffer(std::move(dstBuffer))
, fDstOffset(dstOffset) {}
bool onIsUsed(GrSurfaceProxy* proxy) const override {
SkASSERT(0 == this->numTargets());
return proxy == fSrcProxy.get();
// If fSrcProxy is uninstantiated at flush time we simply will skip doing the transfer.
void handleInternalAllocationFailure() override {}
void gatherProxyIntervals(GrResourceAllocator*) const override;
ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect*) override {
return ExpectedOutcome::kTargetUnchanged;
bool onExecute(GrOpFlushState*) override;
const char* name() const final { return "TransferFrom"; }
#ifdef SK_DEBUG
void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
fn(fSrcProxy.get(), GrMipmapped::kNo);
sk_sp<GrSurfaceProxy> fSrcProxy;
SkIRect fSrcRect;
GrColorType fSurfaceColorType;
GrColorType fDstColorType;
sk_sp<GrGpuBuffer> fDstBuffer;
size_t fDstOffset;