Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 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: |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 15 | /** |
| 16 | * Copies pixels from srcRect in src to SkIRect::MakePtSize(dstPoint, srcRect.dimensions) in |
Brian Salomon | 0f9f800 | 2021-01-22 16:30:50 -0500 | [diff] [blame] | 17 | * dst. The src/dst share a common origin. |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 18 | */ |
Adlai Holler | d71b7b0 | 2020-06-08 15:55:00 -0400 | [diff] [blame] | 19 | static sk_sp<GrRenderTask> Make(GrDrawingManager*, |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 20 | sk_sp<GrSurfaceProxy> src, |
| 21 | SkIRect srcRect, |
| 22 | sk_sp<GrSurfaceProxy> dst, |
| 23 | SkIPoint dstPoint, |
Brian Salomon | 0f9f800 | 2021-01-22 16:30:50 -0500 | [diff] [blame] | 24 | GrSurfaceOrigin); |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 25 | |
| 26 | private: |
Adlai Holler | d71b7b0 | 2020-06-08 15:55:00 -0400 | [diff] [blame] | 27 | GrCopyRenderTask(GrDrawingManager*, |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 28 | sk_sp<GrSurfaceProxy> src, |
| 29 | SkIRect srcRect, |
| 30 | sk_sp<GrSurfaceProxy> dst, |
Brian Salomon | 0f9f800 | 2021-01-22 16:30:50 -0500 | [diff] [blame] | 31 | SkIPoint dstPoint, |
| 32 | GrSurfaceOrigin); |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 33 | |
Adlai Holler | e9ea414 | 2021-04-27 14:31:56 -0400 | [diff] [blame] | 34 | void onMakeSkippable() override { fSrc.reset(); } |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 35 | bool onIsUsed(GrSurfaceProxy* proxy) const override { return proxy == fSrc.get(); } |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 36 | void gatherProxyIntervals(GrResourceAllocator*) const override; |
Chris Dalton | aa938ce | 2021-06-23 18:13:59 -0600 | [diff] [blame] | 37 | ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override; |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 38 | bool onExecute(GrOpFlushState*) override; |
| 39 | |
John Stiles | 1e0136e | 2020-08-12 18:44:00 -0400 | [diff] [blame] | 40 | #if GR_TEST_UTILS |
Robert Phillips | 44e2c5f | 2020-04-14 13:00:04 -0400 | [diff] [blame] | 41 | const char* name() const final { return "Copy"; } |
John Stiles | 1e0136e | 2020-08-12 18:44:00 -0400 | [diff] [blame] | 42 | #endif |
| 43 | #ifdef SK_DEBUG |
Robert Phillips | 294723d | 2021-06-17 09:23:58 -0400 | [diff] [blame] | 44 | void visitProxies_debugOnly(const GrVisitProxyFunc& func) const override { |
| 45 | func(fSrc.get(), GrMipmapped::kNo); |
Chris Dalton | c4b4735 | 2019-08-23 10:10:36 -0600 | [diff] [blame] | 46 | } |
| 47 | #endif |
| 48 | |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 49 | sk_sp<GrSurfaceProxy> fSrc; |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 50 | SkIRect fSrcRect; |
| 51 | SkIPoint fDstPoint; |
Brian Salomon | 0f9f800 | 2021-01-22 16:30:50 -0500 | [diff] [blame] | 52 | GrSurfaceOrigin fOrigin; |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | #endif |
| 56 | |