bsalomon | 9574098 | 2014-09-04 13:12:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 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 | |
bsalomon | 9574098 | 2014-09-04 13:12:37 -0700 | [diff] [blame] | 8 | #include "GrProgramElement.h" |
bsalomon | f96ba02 | 2014-09-17 08:05:40 -0700 | [diff] [blame] | 9 | #include "GrGpuResourceRef.h" |
mtklein | d9dd428 | 2016-04-18 08:09:11 -0700 | [diff] [blame^] | 10 | #include "SkAtomics.h" |
bsalomon | 9574098 | 2014-09-04 13:12:37 -0700 | [diff] [blame] | 11 | |
bsalomon | 52e9d63 | 2014-09-05 12:23:12 -0700 | [diff] [blame] | 12 | uint32_t GrProgramElement::CreateUniqueID() { |
| 13 | static int32_t gUniqueID = SK_InvalidUniqueID; |
| 14 | uint32_t id; |
| 15 | do { |
| 16 | id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 17 | } while (id == SK_InvalidUniqueID); |
| 18 | return id; |
| 19 | } |
| 20 | |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 21 | void GrProgramElement::addPendingIOs() const { |
| 22 | for (int i = 0; i < fGpuResources.count(); ++i) { |
| 23 | fGpuResources[i]->markPendingIO(); |
bsalomon | ac8d619 | 2014-09-04 14:13:44 -0700 | [diff] [blame] | 24 | } |
| 25 | } |
bsalomon | d012877 | 2014-10-03 05:31:41 -0700 | [diff] [blame] | 26 | |
| 27 | void GrProgramElement::removeRefs() const { |
| 28 | for (int i = 0; i < fGpuResources.count(); ++i) { |
| 29 | fGpuResources[i]->removeRef(); |
| 30 | } |
| 31 | } |
bsalomon | ae59b77 | 2014-11-19 08:23:49 -0800 | [diff] [blame] | 32 | |
| 33 | void GrProgramElement::pendingIOComplete() const { |
| 34 | for (int i = 0; i < fGpuResources.count(); ++i) { |
| 35 | fGpuResources[i]->pendingIOComplete(); |
| 36 | } |
| 37 | } |