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

Side by Side Diff: include/gpu/GrContext.h

Issue 596053002: Make "priv" classes for GrTexure and GrSurface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add SK_API Created 6 years, 2 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 | « gyp/gpu.gypi ('k') | include/gpu/GrSurface.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 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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 */ 1075 */
1076 static bool OverbudgetCB(void* data); 1076 static bool OverbudgetCB(void* data);
1077 1077
1078 typedef SkRefCnt INHERITED; 1078 typedef SkRefCnt INHERITED;
1079 }; 1079 };
1080 1080
1081 /** 1081 /**
1082 * Gets and locks a scratch texture from a descriptor using either exact or appr oximate criteria. 1082 * Gets and locks a scratch texture from a descriptor using either exact or appr oximate criteria.
1083 * Unlocks texture in the destructor. 1083 * Unlocks texture in the destructor.
1084 */ 1084 */
1085 class GrAutoScratchTexture : public ::SkNoncopyable { 1085 class SK_API GrAutoScratchTexture : public ::SkNoncopyable {
1086 public: 1086 public:
1087 GrAutoScratchTexture() 1087 GrAutoScratchTexture()
1088 : fContext(NULL) 1088 : fContext(NULL)
1089 , fTexture(NULL) { 1089 , fTexture(NULL) {
1090 } 1090 }
1091 1091
1092 GrAutoScratchTexture(GrContext* context, 1092 GrAutoScratchTexture(GrContext* context,
1093 const GrTextureDesc& desc, 1093 const GrTextureDesc& desc,
1094 GrContext::ScratchTexMatch match = GrContext::kApprox_S cratchTexMatch) 1094 GrContext::ScratchTexMatch match = GrContext::kApprox_S cratchTexMatch)
1095 : fContext(NULL) 1095 : fContext(NULL)
(...skipping 18 matching lines...) Expand all
1114 * we do set the returnToCache flag. In this way the texture remains 1114 * we do set the returnToCache flag. In this way the texture remains
1115 * "locked" in the texture cache until it is freed and recycled in 1115 * "locked" in the texture cache until it is freed and recycled in
1116 * GrTexture::internal_dispose. In reality, the texture has been removed 1116 * GrTexture::internal_dispose. In reality, the texture has been removed
1117 * from the cache (because this is in AutoScratchTexture) and by not 1117 * from the cache (because this is in AutoScratchTexture) and by not
1118 * calling unlockScratchTexture we simply don't re-add it. It will be 1118 * calling unlockScratchTexture we simply don't re-add it. It will be
1119 * reattached in GrTexture::internal_dispose. 1119 * reattached in GrTexture::internal_dispose.
1120 * 1120 *
1121 * Note that the caller is assumed to accept and manage the ref to the 1121 * Note that the caller is assumed to accept and manage the ref to the
1122 * returned texture. 1122 * returned texture.
1123 */ 1123 */
1124 GrTexture* detach() { 1124 GrTexture* detach();
1125 if (NULL == fTexture) {
1126 return NULL;
1127 }
1128 GrTexture* texture = fTexture;
1129 fTexture = NULL;
1130
1131 // This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, wh ich we give up now.
1132 // The cache also has a ref which we are lending to the caller of detach (). When the caller
1133 // lets go of the ref and the ref count goes to 0 internal_dispose will see this flag is
1134 // set and re-ref the texture, thereby restoring the cache's ref.
1135 SkASSERT(!texture->unique());
1136 texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_ FlagBit);
1137 texture->unref();
1138 SkASSERT(texture->getCacheEntry());
1139
1140 return texture;
1141 }
1142 1125
1143 GrTexture* set(GrContext* context, 1126 GrTexture* set(GrContext* context,
1144 const GrTextureDesc& desc, 1127 const GrTextureDesc& desc,
1145 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch TexMatch) { 1128 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch TexMatch) {
1146 this->reset(); 1129 this->reset();
1147 1130
1148 fContext = context; 1131 fContext = context;
1149 if (fContext) { 1132 if (fContext) {
1150 fTexture = fContext->lockAndRefScratchTexture(desc, match); 1133 fTexture = fContext->lockAndRefScratchTexture(desc, match);
1151 if (NULL == fTexture) { 1134 if (NULL == fTexture) {
1152 fContext = NULL; 1135 fContext = NULL;
1153 } 1136 }
1154 return fTexture; 1137 return fTexture;
1155 } else { 1138 } else {
1156 return NULL; 1139 return NULL;
1157 } 1140 }
1158 } 1141 }
1159 1142
1160 GrTexture* texture() { return fTexture; } 1143 GrTexture* texture() { return fTexture; }
1161 1144
1162 private: 1145 private:
1163 GrContext* fContext; 1146 GrContext* fContext;
1164 GrTexture* fTexture; 1147 GrTexture* fTexture;
1165 }; 1148 };
1166 1149
1167 #endif 1150 #endif
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrSurface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698