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 bool SkCachingPixelRef::Install(SkImageGenerator* generator, | 11 bool SkCachingPixelRef::Install(SkImageGenerator* generator, |
12 SkBitmap* dst) { | 12 SkBitmap* dst) { |
13 SkImageInfo info; | 13 SkImageInfo info; |
14 SkASSERT(dst != NULL); | 14 SkASSERT(dst != NULL); |
15 if ((NULL == generator) | 15 if (!generator || !generator->getInfo(&info)) { |
16 || !(generator->getInfo(&info)) | |
17 || !dst->setConfig(info, 0)) { | |
18 SkDELETE(generator); | 16 SkDELETE(generator); |
19 return false; | 17 return false; |
20 } | 18 } |
21 SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef, | 19 SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef, |
22 (info, generator, dst->rowBytes()))); | 20 (info, generator, dst->rowBytes()))); |
23 dst->setPixelRef(ref); | 21 dst->installPixelRef(ref); |
24 return true; | 22 return true; |
25 } | 23 } |
26 | 24 |
27 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info, | 25 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info, |
28 SkImageGenerator* generator, | 26 SkImageGenerator* generator, |
29 size_t rowBytes) | 27 size_t rowBytes) |
30 : INHERITED(info) | 28 : INHERITED(info) |
31 , fImageGenerator(generator) | 29 , fImageGenerator(generator) |
32 , fErrorInDecoding(false) | 30 , fErrorInDecoding(false) |
33 , fScaledCacheId(NULL) | 31 , fScaledCacheId(NULL) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 rec->fColorTable = NULL; | 86 rec->fColorTable = NULL; |
89 rec->fRowBytes = bitmap.rowBytes(); | 87 rec->fRowBytes = bitmap.rowBytes(); |
90 return true; | 88 return true; |
91 } | 89 } |
92 | 90 |
93 void SkCachingPixelRef::onUnlockPixels() { | 91 void SkCachingPixelRef::onUnlockPixels() { |
94 SkASSERT(fScaledCacheId != NULL); | 92 SkASSERT(fScaledCacheId != NULL); |
95 SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCach
eId)); | 93 SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCach
eId)); |
96 fScaledCacheId = NULL; | 94 fScaledCacheId = NULL; |
97 } | 95 } |
OLD | NEW |