1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2019 Google LLC 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#include "src/gpu/GrWaitRenderTask.h" 9cb93a386Sopenharmony_ci 10cb93a386Sopenharmony_ci#include "src/gpu/GrGpu.h" 11cb93a386Sopenharmony_ci#include "src/gpu/GrOpFlushState.h" 12cb93a386Sopenharmony_ci#include "src/gpu/GrResourceAllocator.h" 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_civoid GrWaitRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const { 15cb93a386Sopenharmony_ci // This renderTask doesn't have "normal" ops. In this case we still need to add an interval (so 16cb93a386Sopenharmony_ci // fEndOfOpsTaskOpIndices will remain in sync), so we create a fake op# to capture the fact that 17cb93a386Sopenharmony_ci // we manipulate our target's proxy. 18cb93a386Sopenharmony_ci SkASSERT(0 == this->numTargets()); 19cb93a386Sopenharmony_ci auto fakeOp = alloc->curOp(); 20cb93a386Sopenharmony_ci alloc->addInterval(fWaitedOn.proxy(), fakeOp, fakeOp, 21cb93a386Sopenharmony_ci GrResourceAllocator::ActualUse::kYes); 22cb93a386Sopenharmony_ci alloc->incOps(); 23cb93a386Sopenharmony_ci} 24cb93a386Sopenharmony_ci 25cb93a386Sopenharmony_cibool GrWaitRenderTask::onExecute(GrOpFlushState* flushState) { 26cb93a386Sopenharmony_ci for (int i = 0; i < fNumSemaphores; ++i) { 27cb93a386Sopenharmony_ci // If we don't have a semaphore here it means we failed to wrap it. That happens if the 28cb93a386Sopenharmony_ci // client didn't give us a valid semaphore to begin with. Therefore, it is fine to not wait 29cb93a386Sopenharmony_ci // on it. 30cb93a386Sopenharmony_ci if (fSemaphores[i]) { 31cb93a386Sopenharmony_ci flushState->gpu()->waitSemaphore(fSemaphores[i].get()); 32cb93a386Sopenharmony_ci } 33cb93a386Sopenharmony_ci } 34cb93a386Sopenharmony_ci return true; 35cb93a386Sopenharmony_ci} 36