OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmapFactory.h" | 8 #include "SkBitmapFactory.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkImageCache.h" | 12 #include "SkImageCache.h" |
13 #include "SkImagePriv.h" | 13 #include "SkImagePriv.h" |
14 #include "SkLazyPixelRef.h" | 14 #include "SkLazyPixelRef.h" |
15 | 15 |
16 SK_DEFINE_INST_COUNT(SkBitmapFactory::CacheSelector) | |
17 | |
18 SkBitmapFactory::SkBitmapFactory(SkBitmapFactory::DecodeProc proc) | 16 SkBitmapFactory::SkBitmapFactory(SkBitmapFactory::DecodeProc proc) |
19 : fDecodeProc(proc) | 17 : fDecodeProc(proc) |
20 , fImageCache(NULL) | 18 , fImageCache(NULL) |
21 , fCacheSelector(NULL) { | 19 , fCacheSelector(NULL) { |
22 SkASSERT(fDecodeProc != NULL); | 20 SkASSERT(fDecodeProc != NULL); |
23 } | 21 } |
24 | 22 |
25 SkBitmapFactory::~SkBitmapFactory() { | 23 SkBitmapFactory::~SkBitmapFactory() { |
26 SkSafeUnref(fImageCache); | 24 SkSafeUnref(fImageCache); |
27 SkSafeUnref(fCacheSelector); | 25 SkSafeUnref(fCacheSelector); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef, | 69 SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef, |
72 (data, fDecodeProc, cach
e))); | 70 (data, fDecodeProc, cach
e))); |
73 dst->setPixelRef(lazyRef); | 71 dst->setPixelRef(lazyRef); |
74 return true; | 72 return true; |
75 } else { | 73 } else { |
76 dst->allocPixels(); | 74 dst->allocPixels(); |
77 target.fAddr = dst->getPixels(); | 75 target.fAddr = dst->getPixels(); |
78 return fDecodeProc(data->data(), data->size(), &info, &target); | 76 return fDecodeProc(data->data(), data->size(), &info, &target); |
79 } | 77 } |
80 } | 78 } |
OLD | NEW |