blob: ca44accd753b210032141edb29ccb1016dc9f251 [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"
Robert Phillips1a82a4e2021-07-01 10:27:44 -040013#include "src/gpu/GrResourceProvider.h"
Greg Danielbbfec9d2019-08-20 10:56:51 -040014
15void 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 Danielf41b2bd2019-08-22 16:19:24 -040017 // fEndOfOpsTaskOpIndices will remain in sync), so we create a fake op# to capture the fact that
Greg Danielbbfec9d2019-08-20 10:56:51 -040018 // we read fSrcProxy.
Adlai Holler7f7a5df2021-02-09 17:41:10 +000019 alloc->addInterval(fSrcProxy.get(), alloc->curOp(), alloc->curOp(),
20 GrResourceAllocator::ActualUse::kYes);
Greg Danielbbfec9d2019-08-20 10:56:51 -040021 alloc->incOps();
22}
23
24bool GrTransferFromRenderTask::onExecute(GrOpFlushState* flushState) {
25 if (!fSrcProxy->isInstantiated()) {
26 return false;
27 }
Brian Salomone2078f12021-05-24 12:40:46 -040028 return flushState->gpu()->transferPixelsFrom(fSrcProxy->peekSurface(),
29 fSrcRect,
30 fSurfaceColorType,
31 fDstColorType,
32 fDstBuffer,
33 fDstOffset);
Greg Danielbbfec9d2019-08-20 10:56:51 -040034}