blob: 4c1d8487991c511c308425f12cd32cbf5057945f [file] [log] [blame]
Greg Danielbbfec9d2019-08-20 10:56:51 -04001/*
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
14void GrTransferFromRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
15 // This renderTask doesn't have "normal" ops. In this case we still need to add an interval (so
Greg Danielf41b2bd2019-08-22 16:19:24 -040016 // fEndOfOpsTaskOpIndices will remain in sync), so we create a fake op# to capture the fact that
Greg Danielbbfec9d2019-08-20 10:56:51 -040017 // we read fSrcProxy.
Adlai Holler7f7a5df2021-02-09 17:41:10 +000018 alloc->addInterval(fSrcProxy.get(), alloc->curOp(), alloc->curOp(),
19 GrResourceAllocator::ActualUse::kYes);
Greg Danielbbfec9d2019-08-20 10:56:51 -040020 alloc->incOps();
21}
22
23bool GrTransferFromRenderTask::onExecute(GrOpFlushState* flushState) {
24 if (!fSrcProxy->isInstantiated()) {
25 return false;
26 }
Greg Daniele227fe42019-08-21 13:52:24 -040027 return flushState->gpu()->transferPixelsFrom(
Greg Danielbbfec9d2019-08-20 10:56:51 -040028 fSrcProxy->peekSurface(), fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.width(),
Greg Daniel5ad5a372021-02-01 13:34:04 -050029 fSrcRect.height(), fSurfaceColorType, fDstColorType, fDstBuffer, fDstOffset);
Greg Danielbbfec9d2019-08-20 10:56:51 -040030}