Greg Daniel | 02c4590 | 2020-03-09 10:58:09 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 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/d3d/GrD3DResourceProvider.h" |
| 9 | |
Greg Daniel | e52c978 | 2020-03-23 14:18:37 -0400 | [diff] [blame] | 10 | #include "src/gpu/d3d/GrD3DCommandList.h" |
Greg Daniel | 02c4590 | 2020-03-09 10:58:09 -0400 | [diff] [blame] | 11 | #include "src/gpu/d3d/GrD3DGpu.h" |
| 12 | |
Greg Daniel | 85da336 | 2020-03-09 15:18:35 -0400 | [diff] [blame] | 13 | GrD3DResourceProvider::GrD3DResourceProvider(GrD3DGpu* gpu) : fGpu(gpu) { |
Greg Daniel | 85da336 | 2020-03-09 15:18:35 -0400 | [diff] [blame] | 14 | } |
| 15 | |
Greg Daniel | e52c978 | 2020-03-23 14:18:37 -0400 | [diff] [blame] | 16 | std::unique_ptr<GrD3DDirectCommandList> GrD3DResourceProvider::findOrCreateDirectCommandList() { |
Greg Daniel | 7a5f1fa | 2020-03-24 14:50:19 -0400 | [diff] [blame^] | 17 | if (fAvailableDirectCommandLists.count()) { |
| 18 | std::unique_ptr<GrD3DDirectCommandList> list = |
| 19 | std::move(fAvailableDirectCommandLists.back()); |
| 20 | fAvailableDirectCommandLists.pop_back(); |
| 21 | return list; |
| 22 | } |
Greg Daniel | 83ed213 | 2020-03-24 13:15:33 -0400 | [diff] [blame] | 23 | return GrD3DDirectCommandList::Make(fGpu->device()); |
Greg Daniel | 85da336 | 2020-03-09 15:18:35 -0400 | [diff] [blame] | 24 | } |
Greg Daniel | 7a5f1fa | 2020-03-24 14:50:19 -0400 | [diff] [blame^] | 25 | |
| 26 | void GrD3DResourceProvider::recycleDirectCommandList( |
| 27 | std::unique_ptr<GrD3DDirectCommandList> commandList) { |
| 28 | commandList.reset(); |
| 29 | fAvailableDirectCommandLists.push_back(std::move(commandList)); |
| 30 | } |