Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: src/gpu/GrProgramElement.cpp

Issue 612293003: Fix ref cnt'ing issue in GrProgramElement. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrProgramElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrGpuResourceRef.h" 9 #include "GrGpuResourceRef.h"
10 10
(...skipping 13 matching lines...) Expand all
24 // GrGpuResourceRef will give up its single ref and/or pending read/write in its destructor. 24 // GrGpuResourceRef will give up its single ref and/or pending read/write in its destructor.
25 SkASSERT(fRefCnt > 0); 25 SkASSERT(fRefCnt > 0);
26 if (0 == fPendingExecutions) { 26 if (0 == fPendingExecutions) {
27 for (int i = 0; i < fGpuResources.count(); ++i) { 27 for (int i = 0; i < fGpuResources.count(); ++i) {
28 fGpuResources[i]->markPendingIO(); 28 fGpuResources[i]->markPendingIO();
29 } 29 }
30 } 30 }
31 ++fPendingExecutions; 31 ++fPendingExecutions;
32 this->unref(); 32 this->unref();
33 if (0 == fRefCnt) { 33 if (0 == fRefCnt) {
34 for (int i = 0; i < fGpuResources.count(); ++i) { 34 this->removeRefs();
35 fGpuResources[i]->removeRef();
36 }
37 } 35 }
38 } 36 }
39 37
40 void GrProgramElement::completedExecution() const { 38 void GrProgramElement::completedExecution() const {
41 this->validate(); 39 this->validate();
42 --fPendingExecutions; 40 --fPendingExecutions;
43 if (0 == fPendingExecutions) { 41 if (0 == fPendingExecutions) {
44 if (0 == fRefCnt) { 42 if (0 == fRefCnt) {
45 SkDELETE(this); 43 SkDELETE(this);
46 } else { 44 } else {
47 // Now our pending executions have ocurred and we still have refs. C onvert 45 // Now our pending executions have ocurred and we still have refs. C onvert
48 // ownership of our resources back to regular refs. 46 // ownership of our resources back to regular refs.
49 for (int i = 0; i < fGpuResources.count(); ++i) { 47 for (int i = 0; i < fGpuResources.count(); ++i) {
50 fGpuResources[i]->pendingIOComplete(); 48 fGpuResources[i]->pendingIOComplete();
51 } 49 }
52 50
53 } 51 }
54 } 52 }
55 } 53 }
54
55 void GrProgramElement::removeRefs() const {
56 for (int i = 0; i < fGpuResources.count(); ++i) {
57 fGpuResources[i]->removeRef();
58 }
59 }
OLDNEW
« no previous file with comments | « include/gpu/GrProgramElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698