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

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

Issue 611383003: Revert of GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: 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 | « gm/yuvtorgbeffect.cpp ('k') | include/gpu/GrGpuResource.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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 * 288 *
289 * Textures created by createAndLockTexture() hide the complications of 289 * Textures created by createAndLockTexture() hide the complications of
290 * tiling non-power-of-two textures on APIs that don't support this (e.g. 290 * tiling non-power-of-two textures on APIs that don't support this (e.g.
291 * unextended GLES2). Tiling a NPOT texture created by lockScratchTexture on 291 * unextended GLES2). Tiling a NPOT texture created by lockScratchTexture on
292 * such an API will create gaps in the tiling pattern. This includes clamp 292 * such an API will create gaps in the tiling pattern. This includes clamp
293 * mode. (This may be addressed in a future update.) 293 * mode. (This may be addressed in a future update.)
294 */ 294 */
295 GrTexture* lockAndRefScratchTexture(const GrTextureDesc&, ScratchTexMatch ma tch); 295 GrTexture* lockAndRefScratchTexture(const GrTextureDesc&, ScratchTexMatch ma tch);
296 296
297 /** 297 /**
298 * When done with an entry, call unlockScratchTexture(entry) on it, which r eturns
299 * it to the cache, where it may be purged. This does not unref the texture .
300 */
301 void unlockScratchTexture(GrTexture* texture);
302
303 /**
298 * Creates a texture that is outside the cache. Does not count against 304 * Creates a texture that is outside the cache. Does not count against
299 * cache's budget. 305 * cache's budget.
300 */ 306 */
301 GrTexture* createUncachedTexture(const GrTextureDesc& desc, 307 GrTexture* createUncachedTexture(const GrTextureDesc& desc,
302 void* srcData, 308 void* srcData,
303 size_t rowBytes); 309 size_t rowBytes);
304 310
305 /** 311 /**
306 * Returns true if the specified use of an indexed texture is supported. 312 * Returns true if the specified use of an indexed texture is supported.
307 * Support may depend upon whether the texture params indicate that the 313 * Support may depend upon whether the texture params indicate that the
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1044
1039 void internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path, 1045 void internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path,
1040 const GrStrokeInfo& stroke); 1046 const GrStrokeInfo& stroke);
1041 1047
1042 GrTexture* createResizedTexture(const GrTextureDesc& desc, 1048 GrTexture* createResizedTexture(const GrTextureDesc& desc,
1043 const GrCacheID& cacheID, 1049 const GrCacheID& cacheID,
1044 const void* srcData, 1050 const void* srcData,
1045 size_t rowBytes, 1051 size_t rowBytes,
1046 bool filter); 1052 bool filter);
1047 1053
1048 bool createNewScratchTexture(const GrTextureDesc& desc); 1054 // Needed so GrTexture's returnToCache helper function can call
1055 // addExistingTextureToCache
1056 friend class GrTexture;
1057 friend class GrStencilAndCoverPathRenderer;
1058 friend class GrStencilAndCoverTextContext;
1059
1060 // Add an existing texture to the texture cache. This is intended solely
1061 // for use with textures released from an GrAutoScratchTexture.
1062 void addExistingTextureToCache(GrTexture* texture);
1049 1063
1050 /** 1064 /**
1051 * These functions create premul <-> unpremul effects if it is possible to g enerate a pair 1065 * These functions create premul <-> unpremul effects if it is possible to g enerate a pair
1052 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O therwise, they 1066 * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. O therwise, they
1053 * return NULL. 1067 * return NULL.
1054 */ 1068 */
1055 const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, c onst SkMatrix&); 1069 const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, c onst SkMatrix&);
1056 const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, c onst SkMatrix&); 1070 const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, c onst SkMatrix&);
1057 1071
1058 /** 1072 /**
1059 * This callback allows the resource cache to callback into the GrContext 1073 * This callback allows the resource cache to callback into the GrContext
1060 * when the cache is still overbudget after a purge. 1074 * when the cache is still overbudget after a purge.
1061 */ 1075 */
1062 static bool OverbudgetCB(void* data); 1076 static bool OverbudgetCB(void* data);
1063 1077
1064 typedef SkRefCnt INHERITED; 1078 typedef SkRefCnt INHERITED;
1065 }; 1079 };
1066 1080
1067 /** 1081 /**
1068 * This is deprecated. Don't use it. 1082 * Gets and locks a scratch texture from a descriptor using either exact or appr oximate criteria.
1083 * Unlocks texture in the destructor.
1069 */ 1084 */
1070 class GrAutoScratchTexture : public ::SkNoncopyable { 1085 class GrAutoScratchTexture : public ::SkNoncopyable {
1071 public: 1086 public:
1072 GrAutoScratchTexture() 1087 GrAutoScratchTexture()
1073 : fContext(NULL) 1088 : fContext(NULL)
1074 , fTexture(NULL) { 1089 , fTexture(NULL) {
1075 } 1090 }
1076 1091
1077 GrAutoScratchTexture(GrContext* context, 1092 GrAutoScratchTexture(GrContext* context,
1078 const GrTextureDesc& desc, 1093 const GrTextureDesc& desc,
1079 GrContext::ScratchTexMatch match = GrContext::kApprox_S cratchTexMatch) 1094 GrContext::ScratchTexMatch match = GrContext::kApprox_S cratchTexMatch)
1080 : fContext(NULL) 1095 : fContext(NULL)
1081 , fTexture(NULL) { 1096 , fTexture(NULL) {
1082 this->set(context, desc, match); 1097 this->set(context, desc, match);
1083 } 1098 }
1084 1099
1085 ~GrAutoScratchTexture() { 1100 ~GrAutoScratchTexture() {
1086 this->reset(); 1101 this->reset();
1087 } 1102 }
1088 1103
1089 void reset() { 1104 void reset() {
1090 if (fContext && fTexture) { 1105 if (fContext && fTexture) {
1106 fContext->unlockScratchTexture(fTexture);
1091 fTexture->unref(); 1107 fTexture->unref();
1092 fTexture = NULL; 1108 fTexture = NULL;
1093 } 1109 }
1094 } 1110 }
1095 1111
1096 GrTexture* detach() { 1112 /*
1097 GrTexture* texture = fTexture; 1113 * When detaching a texture we do not unlock it in the texture cache but
1098 fTexture = NULL; 1114 * we do set the returnToCache flag. In this way the texture remains
1099 return texture; 1115 * "locked" in the texture cache until it is freed and recycled in
1100 } 1116 * GrTexture::internal_dispose. In reality, the texture has been removed
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
1119 * reattached in GrTexture::internal_dispose.
1120 *
1121 * Note that the caller is assumed to accept and manage the ref to the
1122 * returned texture.
1123 */
1124 GrTexture* detach();
1101 1125
1102 GrTexture* set(GrContext* context, 1126 GrTexture* set(GrContext* context,
1103 const GrTextureDesc& desc, 1127 const GrTextureDesc& desc,
1104 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch TexMatch) { 1128 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch TexMatch) {
1105 this->reset(); 1129 this->reset();
1106 1130
1107 fContext = context; 1131 fContext = context;
1108 if (fContext) { 1132 if (fContext) {
1109 fTexture = fContext->lockAndRefScratchTexture(desc, match); 1133 fTexture = fContext->lockAndRefScratchTexture(desc, match);
1110 if (NULL == fTexture) { 1134 if (NULL == fTexture) {
1111 fContext = NULL; 1135 fContext = NULL;
1112 } 1136 }
1113 return fTexture; 1137 return fTexture;
1114 } else { 1138 } else {
1115 return NULL; 1139 return NULL;
1116 } 1140 }
1117 } 1141 }
1118 1142
1119 GrTexture* texture() { return fTexture; } 1143 GrTexture* texture() { return fTexture; }
1120 1144
1121 private: 1145 private:
1122 GrContext* fContext; 1146 GrContext* fContext;
1123 GrTexture* fTexture; 1147 GrTexture* fTexture;
1124 }; 1148 };
1125 1149
1126 #endif 1150 #endif
OLDNEW
« no previous file with comments | « gm/yuvtorgbeffect.cpp ('k') | include/gpu/GrGpuResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698