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