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" |
| 13 | |
| 14 | void GrTransferFromRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const { |
| 15 | // This renderTask doesn't have "normal" ops. In this case we still need to add an interval (so |
| 16 | // fEndOfOpListOpIndices will remain in sync), so we create a fake op# to capture the fact that |
| 17 | // we read fSrcProxy. |
| 18 | alloc->addInterval(fSrcProxy.get(), alloc->curOp(), alloc->curOp(), |
| 19 | GrResourceAllocator::ActualUse::kYes); |
| 20 | alloc->incOps(); |
| 21 | } |
| 22 | |
| 23 | bool GrTransferFromRenderTask::onExecute(GrOpFlushState* flushState) { |
| 24 | if (!fSrcProxy->isInstantiated()) { |
| 25 | return false; |
| 26 | } |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame^] | 27 | return flushState->gpu()->transferPixelsFrom( |
Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -0400 | [diff] [blame] | 28 | fSrcProxy->peekSurface(), fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.width(), |
| 29 | fSrcRect.height(), fSurfaceColorType, fDstColorType, fDstBuffer.get(), fDstOffset); |
Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -0400 | [diff] [blame] | 30 | } |