Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -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 | #include "src/gpu/GrTransferFromRenderTask.h" |
| 9 | |
| 10 | #include "src/gpu/GrGpu.h" |
| 11 | #include "src/gpu/GrOpFlushState.h" |
| 12 | #include "src/gpu/GrResourceAllocator.h" |
Robert Phillips | 1a82a4e | 2021-07-01 10:27:44 -0400 | [diff] [blame] | 13 | #include "src/gpu/GrResourceProvider.h" |
Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -0400 | [diff] [blame] | 14 | |
| 15 | void GrTransferFromRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const { |
| 16 | // This renderTask doesn't have "normal" ops. In this case we still need to add an interval (so |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 17 | // fEndOfOpsTaskOpIndices will remain in sync), so we create a fake op# to capture the fact that |
Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -0400 | [diff] [blame] | 18 | // we read fSrcProxy. |
Adlai Holler | 7f7a5df | 2021-02-09 17:41:10 +0000 | [diff] [blame] | 19 | alloc->addInterval(fSrcProxy.get(), alloc->curOp(), alloc->curOp(), |
| 20 | GrResourceAllocator::ActualUse::kYes); |
Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -0400 | [diff] [blame] | 21 | alloc->incOps(); |
| 22 | } |
| 23 | |
| 24 | bool GrTransferFromRenderTask::onExecute(GrOpFlushState* flushState) { |
| 25 | if (!fSrcProxy->isInstantiated()) { |
| 26 | return false; |
| 27 | } |
Brian Salomon | e2078f1 | 2021-05-24 12:40:46 -0400 | [diff] [blame] | 28 | return flushState->gpu()->transferPixelsFrom(fSrcProxy->peekSurface(), |
| 29 | fSrcRect, |
| 30 | fSurfaceColorType, |
| 31 | fDstColorType, |
| 32 | fDstBuffer, |
| 33 | fDstOffset); |
Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -0400 | [diff] [blame] | 34 | } |