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 "LazyDecodeBitmap.h" | 8 #include "LazyDecodeBitmap.h" |
9 | 9 |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Fits SkPicture::InstallPixelRefProc call signature. | 24 // Fits SkPicture::InstallPixelRefProc call signature. |
25 // Used in SkPicturePlayback::CreateFromStream | 25 // Used in SkPicturePlayback::CreateFromStream |
26 bool sk_tools::LazyDecodeBitmap(const void* src, | 26 bool sk_tools::LazyDecodeBitmap(const void* src, |
27 size_t length, | 27 size_t length, |
28 SkBitmap* dst) { | 28 SkBitmap* dst) { |
29 SkAutoDataUnref data(SkData::NewWithCopy(src, length)); | 29 SkAutoDataUnref data(SkData::NewWithCopy(src, length)); |
30 if (NULL == data.get()) { | 30 if (NULL == data.get()) { |
31 return false; | 31 return false; |
32 } | 32 } |
33 | 33 |
34 SkAutoTDelete<SkImageGenerator> gen(SkNEW_ARGS(SkDecodingImageGenerator, | 34 SkAutoTDelete<SkImageGenerator> gen( |
35 (data))); | 35 SkDecodingImageGenerator::Create( |
| 36 data, SkDecodingImageGenerator::Options())); |
36 SkImageInfo info; | 37 SkImageInfo info; |
37 if (!gen->getInfo(&info)) { | 38 if ((NULL == gen.get()) || !gen->getInfo(&info)) { |
38 return false; | 39 return false; |
39 } | 40 } |
40 SkDiscardableMemory::Factory* pool = NULL; | 41 SkDiscardableMemory::Factory* pool = NULL; |
41 if ((!FLAGS_useVolatileCache) || (info.fWidth * info.fHeight < 32 * 1024)) { | 42 if ((!FLAGS_useVolatileCache) || (info.fWidth * info.fHeight < 32 * 1024)) { |
42 // how to do switching with SkDiscardableMemory. | 43 // how to do switching with SkDiscardableMemory. |
43 pool = SkGetGlobalDiscardableMemoryPool(); | 44 pool = SkGetGlobalDiscardableMemoryPool(); |
44 // Only meaningful if platform has a default discardable | 45 // Only meaningful if platform has a default discardable |
45 // memory implementation that differs from the global DM pool. | 46 // memory implementation that differs from the global DM pool. |
46 } | 47 } |
47 return SkInstallDiscardablePixelRef(gen.detach(), dst, pool); | 48 return SkInstallDiscardablePixelRef(gen.detach(), dst, pool); |
48 } | 49 } |
OLD | NEW |