OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
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 "SkTypes.h" | 8 #include "SkTypes.h" |
9 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 9 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include <MobileCoreServices/MobileCoreServices.h> | 29 #include <MobileCoreServices/MobileCoreServices.h> |
30 #endif | 30 #endif |
31 | 31 |
32 static void data_unref_proc(void* skdata, const void*, size_t) { | 32 static void data_unref_proc(void* skdata, const void*, size_t) { |
33 SkASSERT(skdata); | 33 SkASSERT(skdata); |
34 static_cast<SkData*>(skdata)->unref(); | 34 static_cast<SkData*>(skdata)->unref(); |
35 } | 35 } |
36 | 36 |
37 static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) { | 37 static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) { |
38 // TODO: use callbacks, so we don't have to load all the data into RAM | 38 // TODO: use callbacks, so we don't have to load all the data into RAM |
39 SkData* skdata = SkCopyStreamToData(stream); | 39 SkData* skdata = SkCopyStreamToData(stream).release(); |
40 if (!skdata) { | 40 if (!skdata) { |
41 return nullptr; | 41 return nullptr; |
42 } | 42 } |
43 | 43 |
44 return CGDataProviderCreateWithData(skdata, skdata->data(), skdata->size(),
data_unref_proc); | 44 return CGDataProviderCreateWithData(skdata, skdata->data(), skdata->size(),
data_unref_proc); |
45 } | 45 } |
46 | 46 |
47 static CGImageSourceRef SkStreamToCGImageSource(SkStream* stream) { | 47 static CGImageSourceRef SkStreamToCGImageSource(SkStream* stream) { |
48 CGDataProviderRef data = SkStreamToDataProvider(stream); | 48 CGDataProviderRef data = SkStreamToDataProvider(stream); |
49 if (!data) { | 49 if (!data) { |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 const CFStringRef name = CGImageSourceGetType(imageSrc); | 402 const CFStringRef name = CGImageSourceGetType(imageSrc); |
403 if (nullptr == name) { | 403 if (nullptr == name) { |
404 return SkImageDecoder::kUnknown_Format; | 404 return SkImageDecoder::kUnknown_Format; |
405 } | 405 } |
406 return UTType_to_Format(name); | 406 return UTType_to_Format(name); |
407 } | 407 } |
408 | 408 |
409 static SkImageDecoder_FormatReg gFormatReg(get_format_cg); | 409 static SkImageDecoder_FormatReg gFormatReg(get_format_cg); |
410 | 410 |
411 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 411 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
OLD | NEW |