blob: 7a6c95d9871b724417b125fd53a8386d087801bb [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 Hollerb80fb082021-02-08 12:47:00 -050018 alloc->addInterval(fSrcProxy.get(), alloc->curOp(), alloc->curOp());
Greg Danielbbfec9d2019-08-20 10:56:51 -040019 alloc->incOps();
20}
21
22bool GrTransferFromRenderTask::onExecute(GrOpFlushState* flushState) {
23 if (!fSrcProxy->isInstantiated()) {
24 return false;
25 }
Greg Daniele227fe42019-08-21 13:52:24 -040026 return flushState->gpu()->transferPixelsFrom(
Greg Danielbbfec9d2019-08-20 10:56:51 -040027 fSrcProxy->peekSurface(), fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.width(),
Greg Daniel5ad5a372021-02-01 13:34:04 -050028 fSrcRect.height(), fSurfaceColorType, fDstColorType, fDstBuffer, fDstOffset);
Greg Danielbbfec9d2019-08-20 10:56:51 -040029}