xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrTransferFromRenderTask.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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/ganesh/GrTransferFromRenderTask.h"
9 
10 #include "src/gpu/ganesh/GrGpu.h"
11 #include "src/gpu/ganesh/GrOpFlushState.h"
12 #include "src/gpu/ganesh/GrResourceAllocator.h"
13 
gatherProxyIntervals(GrResourceAllocator * alloc) const14 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     // fEndOfOpsTaskOpIndices 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                        GrResourceAllocator::AllowRecycling::kYes);
21     alloc->incOps();
22 }
23 
onExecute(GrOpFlushState * flushState)24 bool GrTransferFromRenderTask::onExecute(GrOpFlushState* flushState) {
25     if (!fSrcProxy->isInstantiated()) {
26         return false;
27     }
28     return flushState->gpu()->transferPixelsFrom(fSrcProxy->peekSurface(),
29                                                  fSrcRect,
30                                                  fSurfaceColorType,
31                                                  fDstColorType,
32                                                  fDstBuffer,
33                                                  fDstOffset);
34 }
35