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