| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "GrResource.h" | 10 #include "GrGpuObject.h" |
| 11 #include "GrGpu.h" | 11 #include "GrGpu.h" |
| 12 | 12 |
| 13 GrResource::GrResource(GrGpu* gpu, bool isWrapped) { | 13 GrGpuObject::GrGpuObject(GrGpu* gpu, bool isWrapped) { |
| 14 fGpu = gpu; | 14 fGpu = gpu; |
| 15 fCacheEntry = NULL; | |
| 16 fDeferredRefCount = 0; | 15 fDeferredRefCount = 0; |
| 17 if (isWrapped) { | 16 if (isWrapped) { |
| 18 fFlags = kWrapped_FlagBit; | 17 fFlags = kWrapped_FlagBit; |
| 19 } else { | 18 } else { |
| 20 fFlags = 0; | 19 fFlags = 0; |
| 21 } | 20 } |
| 22 fGpu->insertResource(this); | 21 fGpu->insertObject(this); |
| 23 } | 22 } |
| 24 | 23 |
| 25 GrResource::~GrResource() { | 24 GrGpuObject::~GrGpuObject() { |
| 26 // subclass should have released this. | 25 // subclass should have released this. |
| 27 SkASSERT(0 == fDeferredRefCount); | 26 SkASSERT(0 == fDeferredRefCount); |
| 28 SkASSERT(!this->isValid()); | 27 SkASSERT(this->wasDestroyed()); |
| 29 } | 28 } |
| 30 | 29 |
| 31 void GrResource::release() { | 30 void GrGpuObject::release() { |
| 32 if (NULL != fGpu) { | 31 if (NULL != fGpu) { |
| 33 this->onRelease(); | 32 this->onRelease(); |
| 34 fGpu->removeResource(this); | 33 fGpu->removeObject(this); |
| 35 fGpu = NULL; | 34 fGpu = NULL; |
| 36 } | 35 } |
| 37 } | 36 } |
| 38 | 37 |
| 39 void GrResource::abandon() { | 38 void GrGpuObject::abandon() { |
| 40 if (NULL != fGpu) { | 39 if (NULL != fGpu) { |
| 41 this->onAbandon(); | 40 this->onAbandon(); |
| 42 fGpu->removeResource(this); | 41 fGpu->removeObject(this); |
| 43 fGpu = NULL; | 42 fGpu = NULL; |
| 44 } | 43 } |
| 45 } | 44 } |
| 46 | 45 |
| 47 const GrContext* GrResource::getContext() const { | 46 const GrContext* GrGpuObject::getContext() const { |
| 48 if (NULL != fGpu) { | 47 if (NULL != fGpu) { |
| 49 return fGpu->getContext(); | 48 return fGpu->getContext(); |
| 50 } else { | 49 } else { |
| 51 return NULL; | 50 return NULL; |
| 52 } | 51 } |
| 53 } | 52 } |
| 54 | 53 |
| 55 GrContext* GrResource::getContext() { | 54 GrContext* GrGpuObject::getContext() { |
| 56 if (NULL != fGpu) { | 55 if (NULL != fGpu) { |
| 57 return fGpu->getContext(); | 56 return fGpu->getContext(); |
| 58 } else { | 57 } else { |
| 59 return NULL; | 58 return NULL; |
| 60 } | 59 } |
| 61 } | 60 } |
| OLD | NEW |