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