OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrContext_DEFINED | 8 #ifndef GrContext_DEFINED |
9 #define GrContext_DEFINED | 9 #define GrContext_DEFINED |
10 | 10 |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 if (NULL == fTexture) { | 1112 if (NULL == fTexture) { |
1113 return NULL; | 1113 return NULL; |
1114 } | 1114 } |
1115 GrTexture* texture = fTexture; | 1115 GrTexture* texture = fTexture; |
1116 fTexture = NULL; | 1116 fTexture = NULL; |
1117 | 1117 |
1118 // This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, wh
ich we give up now. | 1118 // This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, wh
ich we give up now. |
1119 // The cache also has a ref which we are lending to the caller of detach
(). When the caller | 1119 // The cache also has a ref which we are lending to the caller of detach
(). When the caller |
1120 // lets go of the ref and the ref count goes to 0 internal_dispose will
see this flag is | 1120 // lets go of the ref and the ref count goes to 0 internal_dispose will
see this flag is |
1121 // set and re-ref the texture, thereby restoring the cache's ref. | 1121 // set and re-ref the texture, thereby restoring the cache's ref. |
1122 SkASSERT(texture->getRefCnt() > 1); | 1122 SkASSERT(!texture->unique()); |
1123 texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_
FlagBit); | 1123 texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_
FlagBit); |
1124 texture->unref(); | 1124 texture->unref(); |
1125 SkASSERT(NULL != texture->getCacheEntry()); | 1125 SkASSERT(NULL != texture->getCacheEntry()); |
1126 | 1126 |
1127 return texture; | 1127 return texture; |
1128 } | 1128 } |
1129 | 1129 |
1130 GrTexture* set(GrContext* context, | 1130 GrTexture* set(GrContext* context, |
1131 const GrTextureDesc& desc, | 1131 const GrTextureDesc& desc, |
1132 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch
TexMatch) { | 1132 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch
TexMatch) { |
(...skipping 12 matching lines...) Expand all Loading... |
1145 } | 1145 } |
1146 | 1146 |
1147 GrTexture* texture() { return fTexture; } | 1147 GrTexture* texture() { return fTexture; } |
1148 | 1148 |
1149 private: | 1149 private: |
1150 GrContext* fContext; | 1150 GrContext* fContext; |
1151 GrTexture* fTexture; | 1151 GrTexture* fTexture; |
1152 }; | 1152 }; |
1153 | 1153 |
1154 #endif | 1154 #endif |
OLD | NEW |