| 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" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 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 = SkCopyStreamToStorage(&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 SkASSERT(data); |
| 43 CGImageSourceRef imageSrc = CGImageSourceCreateWithDataProvider(data, 0); | 44 CGImageSourceRef imageSrc = CGImageSourceCreateWithDataProvider(data, 0); |
| 44 CGDataProviderRelease(data); | 45 CGDataProviderRelease(data); |
| 45 return imageSrc; | 46 return imageSrc; |
| 46 } | 47 } |
| 47 | 48 |
| 48 class SkImageDecoder_CG : public SkImageDecoder { | 49 class SkImageDecoder_CG : public SkImageDecoder { |
| 49 protected: | 50 protected: |
| 50 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode); | 51 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode); |
| 51 }; | 52 }; |
| 52 | 53 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 346 |
| 346 SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc); | 347 SkAutoTCallVProc<const void, CFRelease> arsrc(imageSrc); |
| 347 const CFStringRef name = CGImageSourceGetType(imageSrc); | 348 const CFStringRef name = CGImageSourceGetType(imageSrc); |
| 348 if (NULL == name) { | 349 if (NULL == name) { |
| 349 return SkImageDecoder::kUnknown_Format; | 350 return SkImageDecoder::kUnknown_Format; |
| 350 } | 351 } |
| 351 return UTType_to_Format(name); | 352 return UTType_to_Format(name); |
| 352 } | 353 } |
| 353 | 354 |
| 354 static SkImageDecoder_FormatReg gFormatReg(get_format_cg); | 355 static SkImageDecoder_FormatReg gFormatReg(get_format_cg); |
| OLD | NEW |