OLD | NEW |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // render target but not vice versa. So we ref the texture to keep both aliv
e for | 112 // render target but not vice versa. So we ref the texture to keep both aliv
e for |
113 // the lifetime of this pixel ref. | 113 // the lifetime of this pixel ref. |
114 fSurface = SkSafeRef(surface->asTexture()); | 114 fSurface = SkSafeRef(surface->asTexture()); |
115 if (NULL == fSurface) { | 115 if (NULL == fSurface) { |
116 fSurface = SkSafeRef(surface); | 116 fSurface = SkSafeRef(surface); |
117 } | 117 } |
118 fUnlock = transferCacheLock; | 118 fUnlock = transferCacheLock; |
119 | 119 |
120 if (fSurface) { | 120 if (fSurface) { |
121 SkASSERT(info.width() <= fSurface->width()); | 121 SkASSERT(info.width() <= fSurface->width()); |
122 SkASSERT(info.height() <= fSurface->height()); | 122 SkASSERT(info.height() <= (fSurface->height() * SkMax32(fSurface->desc()
.fDepth, 1))); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 SkGrPixelRef::~SkGrPixelRef() { | 126 SkGrPixelRef::~SkGrPixelRef() { |
127 if (fUnlock) { | 127 if (fUnlock) { |
128 GrContext* context = fSurface->getContext(); | 128 GrContext* context = fSurface->getContext(); |
129 GrTexture* texture = fSurface->asTexture(); | 129 GrTexture* texture = fSurface->asTexture(); |
130 if (context && texture) { | 130 if (context && texture) { |
131 context->unlockScratchTexture(texture); | 131 context->unlockScratchTexture(texture); |
132 } | 132 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 cachedBitmap.setImmutable(); | 204 cachedBitmap.setImmutable(); |
205 //Add to the cache | 205 //Add to the cache |
206 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap); | 206 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap); |
207 | 207 |
208 dst->swap(cachedBitmap); | 208 dst->swap(cachedBitmap); |
209 } | 209 } |
210 | 210 |
211 return true; | 211 return true; |
212 | 212 |
213 } | 213 } |
OLD | NEW |