| 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 "GrGpuResourceRef.h" | 8 #include "GrGpuResourceRef.h" |
| 9 | 9 |
| 10 GrGpuResourceRef::GrGpuResourceRef() { | 10 GrGpuResourceRef::GrGpuResourceRef() { |
| 11 fResource = NULL; | 11 fResource = nullptr; |
| 12 fOwnRef = false; | 12 fOwnRef = false; |
| 13 fPendingIO = false; | 13 fPendingIO = false; |
| 14 } | 14 } |
| 15 | 15 |
| 16 GrGpuResourceRef::GrGpuResourceRef(GrGpuResource* resource, GrIOType ioType) { | 16 GrGpuResourceRef::GrGpuResourceRef(GrGpuResource* resource, GrIOType ioType) { |
| 17 fResource = NULL; | 17 fResource = nullptr; |
| 18 fOwnRef = false; | 18 fOwnRef = false; |
| 19 fPendingIO = false; | 19 fPendingIO = false; |
| 20 this->setResource(resource, ioType); | 20 this->setResource(resource, ioType); |
| 21 } | 21 } |
| 22 | 22 |
| 23 GrGpuResourceRef::~GrGpuResourceRef() { | 23 GrGpuResourceRef::~GrGpuResourceRef() { |
| 24 if (fOwnRef) { | 24 if (fOwnRef) { |
| 25 SkASSERT(fResource); | 25 SkASSERT(fResource); |
| 26 fResource->unref(); | 26 fResource->unref(); |
| 27 } | 27 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 void GrGpuResourceRef::reset() { | 44 void GrGpuResourceRef::reset() { |
| 45 SkASSERT(!fPendingIO); | 45 SkASSERT(!fPendingIO); |
| 46 SkASSERT(SkToBool(fResource) == fOwnRef); | 46 SkASSERT(SkToBool(fResource) == fOwnRef); |
| 47 if (fOwnRef) { | 47 if (fOwnRef) { |
| 48 fResource->unref(); | 48 fResource->unref(); |
| 49 fOwnRef = false; | 49 fOwnRef = false; |
| 50 fResource = NULL; | 50 fResource = nullptr; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 void GrGpuResourceRef::setResource(GrGpuResource* resource, GrIOType ioType) { | 54 void GrGpuResourceRef::setResource(GrGpuResource* resource, GrIOType ioType) { |
| 55 SkASSERT(!fPendingIO); | 55 SkASSERT(!fPendingIO); |
| 56 SkASSERT(SkToBool(fResource) == fOwnRef); | 56 SkASSERT(SkToBool(fResource) == fOwnRef); |
| 57 SkSafeUnref(fResource); | 57 SkSafeUnref(fResource); |
| 58 if (NULL == resource) { | 58 if (nullptr == resource) { |
| 59 fResource = NULL; | 59 fResource = nullptr; |
| 60 fOwnRef = false; | 60 fOwnRef = false; |
| 61 } else { | 61 } else { |
| 62 fResource = resource; | 62 fResource = resource; |
| 63 fOwnRef = true; | 63 fOwnRef = true; |
| 64 fIOType = ioType; | 64 fIOType = ioType; |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 void GrGpuResourceRef::markPendingIO() const { | 68 void GrGpuResourceRef::markPendingIO() const { |
| 69 // This should only be called when the owning GrProgramElement gets its firs
t | 69 // This should only be called when the owning GrProgramElement gets its firs
t |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 void GrGpuResourceRef::removeRef() const { | 109 void GrGpuResourceRef::removeRef() const { |
| 110 // This should only be called once, when the owners last ref goes away and | 110 // This should only be called once, when the owners last ref goes away and |
| 111 // there is a pending execution. | 111 // there is a pending execution. |
| 112 SkASSERT(fOwnRef); | 112 SkASSERT(fOwnRef); |
| 113 SkASSERT(fPendingIO); | 113 SkASSERT(fPendingIO); |
| 114 SkASSERT(fResource); | 114 SkASSERT(fResource); |
| 115 fResource->unref(); | 115 fResource->unref(); |
| 116 fOwnRef = false; | 116 fOwnRef = false; |
| 117 } | 117 } |
| OLD | NEW |