blob: f1f3f413434a6d69618e3c9d11114bdc256e7ae3 [file] [log] [blame]
bsalomon95740982014-09-04 13:12:37 -07001/*
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
bsalomon95740982014-09-04 13:12:37 -07008#include "GrProgramElement.h"
bsalomonf96ba022014-09-17 08:05:40 -07009#include "GrGpuResourceRef.h"
mtkleind9dd4282016-04-18 08:09:11 -070010#include "SkAtomics.h"
bsalomon95740982014-09-04 13:12:37 -070011
bsalomon52e9d632014-09-05 12:23:12 -070012uint32_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
bsalomonae59b772014-11-19 08:23:49 -080021void GrProgramElement::addPendingIOs() const {
22 for (int i = 0; i < fGpuResources.count(); ++i) {
23 fGpuResources[i]->markPendingIO();
bsalomonac8d6192014-09-04 14:13:44 -070024 }
25}
bsalomond0128772014-10-03 05:31:41 -070026
27void GrProgramElement::removeRefs() const {
28 for (int i = 0; i < fGpuResources.count(); ++i) {
29 fGpuResources[i]->removeRef();
30 }
31}
bsalomonae59b772014-11-19 08:23:49 -080032
33void GrProgramElement::pendingIOComplete() const {
34 for (int i = 0; i < fGpuResources.count(); ++i) {
35 fGpuResources[i]->pendingIOComplete();
36 }
37}