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

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

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 | « 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 context->flush(); 94 context->flush();
95 95
96 SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPrem ul_SkAlphaType); 96 SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPrem ul_SkAlphaType);
97 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst)); 97 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
98 SkSafeUnref(dst); 98 SkSafeUnref(dst);
99 return pixelRef; 99 return pixelRef;
100 } 100 }
101 101
102 /////////////////////////////////////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////////////
103 103
104 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface) : INHERI TED(info) { 104 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
105 bool transferCacheLock) : INHERITED(info) {
105 // For surfaces that are both textures and render targets, the texture owns the 106 // For surfaces that are both textures and render targets, the texture owns the
106 // render target but not vice versa. So we ref the texture to keep both aliv e for 107 // render target but not vice versa. So we ref the texture to keep both aliv e for
107 // the lifetime of this pixel ref. 108 // the lifetime of this pixel ref.
108 fSurface = SkSafeRef(surface->asTexture()); 109 fSurface = SkSafeRef(surface->asTexture());
109 if (NULL == fSurface) { 110 if (NULL == fSurface) {
110 fSurface = SkSafeRef(surface); 111 fSurface = SkSafeRef(surface);
111 } 112 }
113 fUnlock = transferCacheLock;
112 114
113 if (fSurface) { 115 if (fSurface) {
114 SkASSERT(info.width() <= fSurface->width()); 116 SkASSERT(info.width() <= fSurface->width());
115 SkASSERT(info.height() <= fSurface->height()); 117 SkASSERT(info.height() <= fSurface->height());
116 } 118 }
117 } 119 }
118 120
119 SkGrPixelRef::~SkGrPixelRef() { 121 SkGrPixelRef::~SkGrPixelRef() {
122 if (fUnlock) {
123 GrContext* context = fSurface->getContext();
124 GrTexture* texture = fSurface->asTexture();
125 if (context && texture) {
126 context->unlockScratchTexture(texture);
127 }
128 }
120 SkSafeUnref(fSurface); 129 SkSafeUnref(fSurface);
121 } 130 }
122 131
123 GrTexture* SkGrPixelRef::getTexture() { 132 GrTexture* SkGrPixelRef::getTexture() {
124 if (fSurface) { 133 if (fSurface) {
125 return fSurface->asTexture(); 134 return fSurface->asTexture();
126 } 135 }
127 return NULL; 136 return NULL;
128 } 137 }
129 138
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 cachedBitmap.setImmutable(); 199 cachedBitmap.setImmutable();
191 //Add to the cache 200 //Add to the cache
192 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap); 201 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap);
193 202
194 dst->swap(cachedBitmap); 203 dst->swap(cachedBitmap);
195 } 204 }
196 205
197 return true; 206 return true;
198 207
199 } 208 }
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