| 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 "SkCGUtils.h" | 8 #include "SkCGUtils.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
| 11 #include "SkImageEncoder.h" | 11 #include "SkImageEncoder.h" |
| 12 #include "SkMovie.h" | 12 #include "SkMovie.h" |
| 13 #include "SkStream.h" | 13 #include "SkStream.h" |
| 14 #include "SkStreamHelpers.h" | 14 #include "SkStreamPriv.h" |
| 15 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
| 16 #include "SkUnPreMultiply.h" | 16 #include "SkUnPreMultiply.h" |
| 17 | 17 |
| 18 #ifdef SK_BUILD_FOR_MAC | 18 #ifdef SK_BUILD_FOR_MAC |
| 19 #include <ApplicationServices/ApplicationServices.h> | 19 #include <ApplicationServices/ApplicationServices.h> |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #ifdef SK_BUILD_FOR_IOS | 22 #ifdef SK_BUILD_FOR_IOS |
| 23 #include <CoreGraphics/CoreGraphics.h> | 23 #include <CoreGraphics/CoreGraphics.h> |
| 24 #include <ImageIO/ImageIO.h> | 24 #include <ImageIO/ImageIO.h> |
| 25 #include <MobileCoreServices/MobileCoreServices.h> | 25 #include <MobileCoreServices/MobileCoreServices.h> |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 static void malloc_release_proc(void* info, const void* data, size_t size) { | 28 static void malloc_release_proc(void* info, const void* data, size_t size) { |
| 29 sk_free(info); | 29 sk_free(info); |
| 30 } | 30 } |
| 31 | 31 |
| 32 static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) { | 32 static CGDataProviderRef SkStreamToDataProvider(SkStream* stream) { |
| 33 // TODO: use callbacks, so we don't have to load all the data into RAM | 33 // TODO: use callbacks, so we don't have to load all the data into RAM |
| 34 SkAutoMalloc storage; | 34 SkAutoMalloc storage; |
| 35 const size_t len = CopyStreamToStorage(&storage, stream); | 35 const size_t len = SkCopyStreamToStorage(&storage, stream); |
| 36 void* data = storage.detach(); | 36 void* data = storage.detach(); |
| 37 | 37 |
| 38 return CGDataProviderCreateWithData(data, data, len, malloc_release_proc); | 38 return CGDataProviderCreateWithData(data, data, len, malloc_release_proc); |
| 39 } | 39 } |
| 40 | 40 |
| 41 static CGImageSourceRef SkStreamToCGImageSource(SkStream* stream) { | 41 static CGImageSourceRef SkStreamToCGImageSource(SkStream* stream) { |
| 42 CGDataProviderRef data = SkStreamToDataProvider(stream); | 42 CGDataProviderRef data = SkStreamToDataProvider(stream); |
| 43 CGImageSourceRef imageSrc = CGImageSourceCreateWithDataProvider(data, 0); | 43 CGImageSourceRef imageSrc = CGImageSourceCreateWithDataProvider(data, 0); |
| 44 CGDataProviderRelease(data); | 44 CGDataProviderRelease(data); |
| 45 return imageSrc; | 45 return imageSrc; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 282 |
| 283 SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc); | 283 SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc); |
| 284 const CFStringRef name = CGImageSourceGetType(imageSrc); | 284 const CFStringRef name = CGImageSourceGetType(imageSrc); |
| 285 if (NULL == name) { | 285 if (NULL == name) { |
| 286 return SkImageDecoder::kUnknown_Format; | 286 return SkImageDecoder::kUnknown_Format; |
| 287 } | 287 } |
| 288 return UTType_to_Format(name); | 288 return UTType_to_Format(name); |
| 289 } | 289 } |
| 290 | 290 |
| 291 static SkImageDecoder_FormatReg gFormatReg(get_format_cg); | 291 static SkImageDecoder_FormatReg gFormatReg(get_format_cg); |
| OLD | NEW |