xref: /aosp_15_r20/external/skia/src/gpu/graphite/task/ClearBuffersTask.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2022 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/graphite/task/ClearBuffersTask.h"
9 
10 #include "src/gpu/graphite/CommandBuffer.h"
11 
12 namespace skgpu::graphite {
13 
Make(skia_private::TArray<BindBufferInfo> clearList)14 sk_sp<ClearBuffersTask> ClearBuffersTask::Make(skia_private::TArray<BindBufferInfo> clearList) {
15     return sk_sp<ClearBuffersTask>(new ClearBuffersTask(std::move(clearList)));
16 }
17 
~ClearBuffersTask()18 ClearBuffersTask::~ClearBuffersTask(){};
19 
addCommands(Context *,CommandBuffer * commandBuffer,ReplayTargetData)20 Task::Status ClearBuffersTask::addCommands(Context*,
21                                            CommandBuffer* commandBuffer,
22                                            ReplayTargetData) {
23     bool result = true;
24     for (const auto& c : fClearList) {
25         result &= commandBuffer->clearBuffer(c.fBuffer, c.fOffset, c.fSize);
26     }
27     return result ? Status::kSuccess : Status::kFail;
28 }
29 
30 }  // namespace skgpu::graphite
31