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