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

Side by Side Diff: src/gpu/SkGrPixelRef.cpp

Issue 608883003: GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: remove todo 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 | « src/gpu/SkGr.cpp ('k') | src/gpu/effects/GrTextureStripAtlas.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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 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 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 GrContext::kFlushWrites_PixelOp); 92 GrContext::kFlushWrites_PixelOp);
93 93
94 SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPrem ul_SkAlphaType); 94 SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPrem ul_SkAlphaType);
95 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst)); 95 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
96 SkSafeUnref(dst); 96 SkSafeUnref(dst);
97 return pixelRef; 97 return pixelRef;
98 } 98 }
99 99
100 /////////////////////////////////////////////////////////////////////////////// 100 ///////////////////////////////////////////////////////////////////////////////
101 101
102 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface, 102 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface) : INHERI TED(info) {
103 bool transferCacheLock) : INHERITED(info) {
104 // For surfaces that are both textures and render targets, the texture owns the 103 // For surfaces that are both textures and render targets, the texture owns the
105 // render target but not vice versa. So we ref the texture to keep both aliv e for 104 // render target but not vice versa. So we ref the texture to keep both aliv e for
106 // the lifetime of this pixel ref. 105 // the lifetime of this pixel ref.
107 fSurface = SkSafeRef(surface->asTexture()); 106 fSurface = SkSafeRef(surface->asTexture());
108 if (NULL == fSurface) { 107 if (NULL == fSurface) {
109 fSurface = SkSafeRef(surface); 108 fSurface = SkSafeRef(surface);
110 } 109 }
111 fUnlock = transferCacheLock;
112 110
113 if (fSurface) { 111 if (fSurface) {
114 SkASSERT(info.width() <= fSurface->width()); 112 SkASSERT(info.width() <= fSurface->width());
115 SkASSERT(info.height() <= fSurface->height()); 113 SkASSERT(info.height() <= fSurface->height());
116 } 114 }
117 } 115 }
118 116
119 SkGrPixelRef::~SkGrPixelRef() { 117 SkGrPixelRef::~SkGrPixelRef() {
120 if (fUnlock) {
121 GrContext* context = fSurface->getContext();
122 GrTexture* texture = fSurface->asTexture();
123 if (context && texture) {
124 context->unlockScratchTexture(texture);
125 }
126 }
127 SkSafeUnref(fSurface); 118 SkSafeUnref(fSurface);
128 } 119 }
129 120
130 GrTexture* SkGrPixelRef::getTexture() { 121 GrTexture* SkGrPixelRef::getTexture() {
131 if (fSurface) { 122 if (fSurface) {
132 return fSurface->asTexture(); 123 return fSurface->asTexture();
133 } 124 }
134 return NULL; 125 return NULL;
135 } 126 }
136 127
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 cachedBitmap.setImmutable(); 188 cachedBitmap.setImmutable();
198 //Add to the cache 189 //Add to the cache
199 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap); 190 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap);
200 191
201 dst->swap(cachedBitmap); 192 dst->swap(cachedBitmap);
202 } 193 }
203 194
204 return true; 195 return true;
205 196
206 } 197 }
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/gpu/effects/GrTextureStripAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698