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 "SkBitmapCache.h" | 9 #include "SkBitmapCache.h" |
10 #include "SkRect.h" | 10 #include "SkRect.h" |
11 | 11 |
12 bool SkCachingPixelRef::Install(SkImageGenerator* generator, | 12 bool SkCachingPixelRef::Install(SkImageGenerator* generator, |
13 SkBitmap* dst) { | 13 SkBitmap* dst) { |
14 SkImageInfo info; | |
15 SkASSERT(dst != NULL); | 14 SkASSERT(dst != NULL); |
16 if ((NULL == generator) | 15 if (NULL == generator) { |
17 || !(generator->getInfo(&info)) | 16 return false; |
18 || !dst->setInfo(info)) { | 17 } |
| 18 const SkImageInfo info = generator->getInfo(); |
| 19 if (!dst->setInfo(info)) { |
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); |
25 return true; | 26 return true; |
26 } | 27 } |
27 | 28 |
28 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info, | 29 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 SkASSERT(pixels != NULL); | 72 SkASSERT(pixels != NULL); |
72 rec->fPixels = pixels; | 73 rec->fPixels = pixels; |
73 rec->fColorTable = NULL; | 74 rec->fColorTable = NULL; |
74 rec->fRowBytes = fLockedBitmap.rowBytes(); | 75 rec->fRowBytes = fLockedBitmap.rowBytes(); |
75 return true; | 76 return true; |
76 } | 77 } |
77 | 78 |
78 void SkCachingPixelRef::onUnlockPixels() { | 79 void SkCachingPixelRef::onUnlockPixels() { |
79 fLockedBitmap.reset(); | 80 fLockedBitmap.reset(); |
80 } | 81 } |
OLD | NEW |