OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "SkCachingPixelRef.h" | 8 #include "SkCachingPixelRef.h" |
9 #include "SkScaledImageCache.h" | 9 #include "SkScaledImageCache.h" |
10 | 10 |
11 | 11 |
12 bool SkCachingPixelRef::Install(SkImageGenerator* generator, | 12 bool SkCachingPixelRef::Install(SkImageGenerator* generator, |
13 SkBitmap* dst) { | 13 SkBitmap* dst) { |
14 SkImageInfo info; | 14 SkImageInfo info; |
| 15 SkASSERT(generator != NULL); |
15 SkASSERT(dst != NULL); | 16 SkASSERT(dst != NULL); |
16 if ((NULL == generator) | 17 if ((NULL == generator) |
17 || !(generator->getInfo(&info)) | 18 || !(generator->getInfo(&info)) |
18 || !dst->setConfig(info, 0)) { | 19 || !dst->setConfig(info, 0)) { |
19 SkDELETE(generator); | 20 SkDELETE(generator); |
20 return false; | 21 return false; |
21 } | 22 } |
22 SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef, | 23 SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef, |
23 (info, generator, dst->rowBytes()))); | 24 (info, generator, dst->rowBytes()))); |
24 dst->setPixelRef(ref); | 25 dst->setPixelRef(ref); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // reference to the concrete PixelRef while this record is | 86 // reference to the concrete PixelRef while this record is |
86 // locked. | 87 // locked. |
87 return pixels; | 88 return pixels; |
88 } | 89 } |
89 | 90 |
90 void SkCachingPixelRef::onUnlockPixels() { | 91 void SkCachingPixelRef::onUnlockPixels() { |
91 SkASSERT(fScaledCacheId != NULL); | 92 SkASSERT(fScaledCacheId != NULL); |
92 SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCach
eId)); | 93 SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCach
eId)); |
93 fScaledCacheId = NULL; | 94 fScaledCacheId = NULL; |
94 } | 95 } |
OLD | NEW |