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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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 | « src/gpu/GrGpuResource.cpp ('k') | src/gpu/GrImmediateDrawTarget.h » ('j') | 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 "GrGpuResourceRef.h" 8 #include "GrGpuResourceRef.h"
9 9
10 GrGpuResourceRef::GrGpuResourceRef() { 10 GrGpuResourceRef::GrGpuResourceRef() {
11 fResource = nullptr; 11 fResource = nullptr;
12 fOwnRef = false; 12 fOwnRef = false;
13 fPendingIO = false; 13 fPendingIO = false;
14 fDst = NULL;
14 } 15 }
15 16
16 GrGpuResourceRef::GrGpuResourceRef(GrGpuResource* resource, GrIOType ioType) { 17 GrGpuResourceRef::GrGpuResourceRef(GrGpuResource* resource, GrIOType ioType, GrG puResource* dst) {
17 fResource = nullptr; 18 fResource = nullptr;
18 fOwnRef = false; 19 fOwnRef = false;
19 fPendingIO = false; 20 fPendingIO = false;
20 this->setResource(resource, ioType); 21 fDst = NULL;
22 this->setResource(resource, ioType, dst);
21 } 23 }
22 24
23 GrGpuResourceRef::~GrGpuResourceRef() { 25 GrGpuResourceRef::~GrGpuResourceRef() {
24 if (fOwnRef) { 26 if (fOwnRef) {
25 SkASSERT(fResource); 27 SkASSERT(fResource);
26 fResource->unref(); 28 fResource->unref();
27 } 29 }
28 if (fPendingIO) { 30 if (fPendingIO) {
29 switch (fIOType) { 31 switch (fIOType) {
30 case kRead_GrIOType: 32 case kRead_GrIOType:
(...skipping 11 matching lines...) Expand all
42 } 44 }
43 45
44 void GrGpuResourceRef::reset() { 46 void GrGpuResourceRef::reset() {
45 SkASSERT(!fPendingIO); 47 SkASSERT(!fPendingIO);
46 SkASSERT(SkToBool(fResource) == fOwnRef); 48 SkASSERT(SkToBool(fResource) == fOwnRef);
47 if (fOwnRef) { 49 if (fOwnRef) {
48 fResource->unref(); 50 fResource->unref();
49 fOwnRef = false; 51 fOwnRef = false;
50 fResource = nullptr; 52 fResource = nullptr;
51 } 53 }
54 fDst = NULL;
52 } 55 }
53 56
54 void GrGpuResourceRef::setResource(GrGpuResource* resource, GrIOType ioType) { 57 void GrGpuResourceRef::setResource(GrGpuResource* resource, GrIOType ioType, GrG puResource* dst) {
55 SkASSERT(!fPendingIO); 58 SkASSERT(!fPendingIO);
56 SkASSERT(SkToBool(fResource) == fOwnRef); 59 SkASSERT(SkToBool(fResource) == fOwnRef);
57 SkSafeUnref(fResource); 60 SkSafeUnref(fResource);
58 if (nullptr == resource) { 61 if (nullptr == resource) {
62 SkASSERT(nullptr == dst);
59 fResource = nullptr; 63 fResource = nullptr;
60 fOwnRef = false; 64 fOwnRef = false;
65 fDst = NULL;
61 } else { 66 } else {
62 fResource = resource; 67 fResource = resource;
63 fOwnRef = true; 68 fOwnRef = true;
64 fIOType = ioType; 69 fIOType = ioType;
70 if (fIOType == kRead_GrIOType || fIOType == kRW_GrIOType) {
71 SkASSERT(dst);
72 fDst = dst;
73 } else {
74 fDst = NULL;
75 }
65 } 76 }
66 } 77 }
67 78
68 void GrGpuResourceRef::markPendingIO() const { 79 void GrGpuResourceRef::markPendingIO() const {
69 // This should only be called when the owning GrProgramElement gets its firs t 80 // This should only be called when the owning GrProgramElement gets its firs t
70 // pendingExecution ref. 81 // pendingExecution ref.
71 SkASSERT(!fPendingIO); 82 SkASSERT(!fPendingIO);
72 SkASSERT(fResource); 83 SkASSERT(fResource);
73 fPendingIO = true; 84 fPendingIO = true;
74 switch (fIOType) { 85 switch (fIOType) {
75 case kRead_GrIOType: 86 case kRead_GrIOType:
76 fResource->addPendingRead(); 87 SkASSERT(fDst);
88 fResource->addPendingRead(fDst);
77 break; 89 break;
78 case kWrite_GrIOType: 90 case kWrite_GrIOType:
79 fResource->addPendingWrite(); 91 fResource->addPendingWrite();
80 break; 92 break;
81 case kRW_GrIOType: 93 case kRW_GrIOType:
82 fResource->addPendingRead(); 94 SkASSERT(fDst);
95 fResource->addPendingRead(fDst);
83 fResource->addPendingWrite(); 96 fResource->addPendingWrite();
84 break; 97 break;
85 } 98 }
86 } 99 }
87 100
88 void GrGpuResourceRef::pendingIOComplete() const { 101 void GrGpuResourceRef::pendingIOComplete() const {
89 // This should only be called when the owner's pending executions have ocurr ed but it is still 102 // This should only be called when the owner's pending executions have ocurr ed but it is still
90 // reffed. 103 // reffed.
91 SkASSERT(fOwnRef); 104 SkASSERT(fOwnRef);
92 SkASSERT(fPendingIO); 105 SkASSERT(fPendingIO);
(...skipping 15 matching lines...) Expand all
108 121
109 void GrGpuResourceRef::removeRef() const { 122 void GrGpuResourceRef::removeRef() const {
110 // This should only be called once, when the owners last ref goes away and 123 // This should only be called once, when the owners last ref goes away and
111 // there is a pending execution. 124 // there is a pending execution.
112 SkASSERT(fOwnRef); 125 SkASSERT(fOwnRef);
113 SkASSERT(fPendingIO); 126 SkASSERT(fPendingIO);
114 SkASSERT(fResource); 127 SkASSERT(fResource);
115 fResource->unref(); 128 fResource->unref();
116 fOwnRef = false; 129 fOwnRef = false;
117 } 130 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpuResource.cpp ('k') | src/gpu/GrImmediateDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698