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

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

Powered by Google App Engine
This is Rietveld 408576698