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 |
16 SkBitmapFactory::SkBitmapFactory(SkBitmapFactory::DecodeProc proc) | 18 SkBitmapFactory::SkBitmapFactory(SkBitmapFactory::DecodeProc proc) |
17 : fDecodeProc(proc) | 19 : fDecodeProc(proc) |
18 , fImageCache(NULL) | 20 , fImageCache(NULL) |
19 , fCacheSelector(NULL) { | 21 , fCacheSelector(NULL) { |
20 SkASSERT(fDecodeProc != NULL); | 22 SkASSERT(fDecodeProc != NULL); |
21 } | 23 } |
22 | 24 |
23 SkBitmapFactory::~SkBitmapFactory() { | 25 SkBitmapFactory::~SkBitmapFactory() { |
24 SkSafeUnref(fImageCache); | 26 SkSafeUnref(fImageCache); |
25 SkSafeUnref(fCacheSelector); | 27 SkSafeUnref(fCacheSelector); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef, | 74 SkAutoTUnref<SkLazyPixelRef> lazyRef(SkNEW_ARGS(SkLazyPixelRef, |
73 (data, fDecodeProc, cach
e))); | 75 (data, fDecodeProc, cach
e))); |
74 dst->setPixelRef(lazyRef); | 76 dst->setPixelRef(lazyRef); |
75 return true; | 77 return true; |
76 } else { | 78 } else { |
77 dst->allocPixels(); | 79 dst->allocPixels(); |
78 target.fAddr = dst->getPixels(); | 80 target.fAddr = dst->getPixels(); |
79 return fDecodeProc(data->data(), data->size(), &info, &target); | 81 return fDecodeProc(data->data(), data->size(), &info, &target); |
80 } | 82 } |
81 } | 83 } |
OLD | NEW |