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

Side by Side Diff: src/gpu/GrLayerCache.h

Issue 431603002: Fix ref counting of cached layer's texture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove incorrect comment Created 6 years, 4 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 | « no previous file | src/gpu/GrLayerCache.cpp » ('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 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 #ifndef GrLayerCache_DEFINED 8 #ifndef GrLayerCache_DEFINED
9 #define GrLayerCache_DEFINED 9 #define GrLayerCache_DEFINED
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // GrCachedLayer proper 75 // GrCachedLayer proper
76 GrCachedLayer(uint32_t pictureID, int layerID) 76 GrCachedLayer(uint32_t pictureID, int layerID)
77 : fKey(pictureID, layerID) 77 : fKey(pictureID, layerID)
78 , fTexture(NULL) 78 , fTexture(NULL)
79 , fRect(GrIRect16::MakeEmpty()) 79 , fRect(GrIRect16::MakeEmpty())
80 , fPlot(NULL) 80 , fPlot(NULL)
81 , fLocked(false) { 81 , fLocked(false) {
82 SkASSERT(SK_InvalidGenID != pictureID && layerID >= 0); 82 SkASSERT(SK_InvalidGenID != pictureID && layerID >= 0);
83 } 83 }
84 84
85 ~GrCachedLayer() {
86 SkSafeUnref(fTexture);
87 }
88
85 uint32_t pictureID() const { return fKey.getPictureID(); } 89 uint32_t pictureID() const { return fKey.getPictureID(); }
86 int layerID() const { return fKey.getLayerID(); } 90 int layerID() const { return fKey.getLayerID(); }
87 91
88 // This call takes over the caller's ref
89 void setTexture(GrTexture* texture, const GrIRect16& rect) { 92 void setTexture(GrTexture* texture, const GrIRect16& rect) {
90 if (NULL != fTexture) { 93 SkRefCnt_SafeAssign(fTexture, texture);
91 fTexture->unref();
92 }
93
94 fTexture = texture; // just take over caller's ref
95 fRect = rect; 94 fRect = rect;
96 } 95 }
97 GrTexture* texture() { return fTexture; } 96 GrTexture* texture() { return fTexture; }
98 const GrIRect16& rect() const { return fRect; } 97 const GrIRect16& rect() const { return fRect; }
99 98
100 void setPlot(GrPlot* plot) { 99 void setPlot(GrPlot* plot) {
101 SkASSERT(NULL == fPlot); 100 SkASSERT(NULL == fPlot);
102 fPlot = plot; 101 fPlot = plot;
103 } 102 }
104 GrPlot* plot() { return fPlot; } 103 GrPlot* plot() { return fPlot; }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Try to find a purgeable plot and clear it out. Return true if a plot 218 // Try to find a purgeable plot and clear it out. Return true if a plot
220 // was purged; false otherwise. 219 // was purged; false otherwise.
221 bool purgePlot(); 220 bool purgePlot();
222 221
223 // for testing 222 // for testing
224 friend class TestingAccess; 223 friend class TestingAccess;
225 int numLayers() const { return fLayerHash.count(); } 224 int numLayers() const { return fLayerHash.count(); }
226 }; 225 };
227 226
228 #endif 227 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrLayerCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698