OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrProgramElement.h" | 8 #include "GrProgramElement.h" |
9 #include "GrProgramResource.h" | 9 #include "GrProgramResource.h" |
10 | 10 |
| 11 uint32_t GrProgramElement::CreateUniqueID() { |
| 12 static int32_t gUniqueID = SK_InvalidUniqueID; |
| 13 uint32_t id; |
| 14 do { |
| 15 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 16 } while (id == SK_InvalidUniqueID); |
| 17 return id; |
| 18 } |
| 19 |
11 void GrProgramElement::convertRefToPendingExecution() const { | 20 void GrProgramElement::convertRefToPendingExecution() const { |
12 // This function makes it so that all the GrProgramResources own a single re
f to their | 21 // This function makes it so that all the GrProgramResources own a single re
f to their |
13 // underlying GrGpuResource if there are any refs to the GrProgramElement an
d a single | 22 // underlying GrGpuResource if there are any refs to the GrProgramElement an
d a single |
14 // pending read/write if there are any pending executions of the GrProgramEl
ement. The | 23 // pending read/write if there are any pending executions of the GrProgramEl
ement. The |
15 // GrProgramResource will give up its single ref and/or pending read/write i
n its destructor. | 24 // GrProgramResource will give up its single ref and/or pending read/write i
n its destructor. |
16 SkASSERT(fRefCnt > 0); | 25 SkASSERT(fRefCnt > 0); |
17 if (0 == fPendingExecutions) { | 26 if (0 == fPendingExecutions) { |
18 for (int i = 0; i < fProgramResources.count(); ++i) { | 27 for (int i = 0; i < fProgramResources.count(); ++i) { |
19 fProgramResources[i]->markPendingIO(); | 28 fProgramResources[i]->markPendingIO(); |
20 } | 29 } |
(...skipping 16 matching lines...) Expand all Loading... |
37 } else { | 46 } else { |
38 // Now our pending executions have ocurred and we still have refs. C
onvert | 47 // Now our pending executions have ocurred and we still have refs. C
onvert |
39 // ownership of our resources back to regular refs. | 48 // ownership of our resources back to regular refs. |
40 for (int i = 0; i < fProgramResources.count(); ++i) { | 49 for (int i = 0; i < fProgramResources.count(); ++i) { |
41 fProgramResources[i]->pendingIOComplete(); | 50 fProgramResources[i]->pendingIOComplete(); |
42 } | 51 } |
43 | 52 |
44 } | 53 } |
45 } | 54 } |
46 } | 55 } |
OLD | NEW |