| 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 #ifndef GrGpuResource_DEFINED | 8 #ifndef GrGpuResource_DEFINED |
| 9 #define GrGpuResource_DEFINED | 9 #define GrGpuResource_DEFINED |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 void validate() const { | 74 void validate() const { |
| 75 #ifdef SK_DEBUG | 75 #ifdef SK_DEBUG |
| 76 SkASSERT(fRefCnt >= 0); | 76 SkASSERT(fRefCnt >= 0); |
| 77 SkASSERT(fPendingReads >= 0); | 77 SkASSERT(fPendingReads >= 0); |
| 78 SkASSERT(fPendingWrites >= 0); | 78 SkASSERT(fPendingWrites >= 0); |
| 79 SkASSERT(fRefCnt + fPendingReads + fPendingWrites > 0); | 79 SkASSERT(fRefCnt + fPendingReads + fPendingWrites > 0); |
| 80 #endif | 80 #endif |
| 81 } | 81 } |
| 82 | 82 |
| 83 |
| 83 protected: | 84 protected: |
| 84 GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) {} | 85 GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) {} |
| 85 | 86 |
| 87 bool internalHasPendingRead() const { return SkToBool(fPendingReads); } |
| 88 bool internalHasPendingWrite() const { return SkToBool(fPendingWrites); } |
| 89 bool internalHasPendingIO() const { return SkToBool(fPendingWrites | fPendin
gReads); } |
| 90 |
| 86 private: | 91 private: |
| 87 void addPendingRead() const { | 92 void addPendingRead() const { |
| 88 this->validate(); | 93 this->validate(); |
| 89 ++fPendingReads; | 94 ++fPendingReads; |
| 90 } | 95 } |
| 91 | 96 |
| 92 void completedRead() const { | 97 void completedRead() const { |
| 93 this->validate(); | 98 this->validate(); |
| 94 --fPendingReads; | 99 --fPendingReads; |
| 95 if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) { | 100 if (0 == fRefCnt && 0 == fPendingReads && 0 == fPendingWrites) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 250 |
| 246 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache | 251 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache |
| 247 const uint32_t fUniqueID; | 252 const uint32_t fUniqueID; |
| 248 | 253 |
| 249 GrResourceKey fScratchKey; | 254 GrResourceKey fScratchKey; |
| 250 | 255 |
| 251 typedef GrIORef INHERITED; | 256 typedef GrIORef INHERITED; |
| 252 }; | 257 }; |
| 253 | 258 |
| 254 #endif | 259 #endif |
| OLD | NEW |