| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "sk_canvas.h" | 8 #include "sk_canvas.h" |
| 9 #include "sk_data.h" | 9 #include "sk_data.h" |
| 10 #include "sk_image.h" | 10 #include "sk_image.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t* cinfo, const void* pi
xels, | 224 sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t* cinfo, const void* pi
xels, |
| 225 size_t rowBytes) { | 225 size_t rowBytes) { |
| 226 SkImageInfo info; | 226 SkImageInfo info; |
| 227 if (!from_c_info(*cinfo, &info)) { | 227 if (!from_c_info(*cinfo, &info)) { |
| 228 return NULL; | 228 return NULL; |
| 229 } | 229 } |
| 230 return (sk_image_t*)SkImage::NewRasterCopy(info, pixels, rowBytes); | 230 return (sk_image_t*)SkImage::NewRasterCopy(info, pixels, rowBytes); |
| 231 } | 231 } |
| 232 | 232 |
| 233 #include "SkDecodingImageGenerator.h" | |
| 234 | |
| 235 sk_image_t* sk_image_new_from_data(const sk_data_t* cdata) { | 233 sk_image_t* sk_image_new_from_data(const sk_data_t* cdata) { |
| 236 SkImageGenerator* gen = NULL; | 234 return ToImage(SkImage::NewFromData(AsData(cdata))); |
| 237 #if 0 | |
| 238 // enable this when SkDecodingImageGenerator is available in chrome (decode
codecs) | |
| 239 gen = SkDecodingImageGenerator::Create(AsData(cdata), SkDecodingImageGenerat
or::Options()); | |
| 240 #endif | |
| 241 if (NULL == gen) { | |
| 242 return NULL; | |
| 243 } | |
| 244 return ToImage(SkImage::NewFromGenerator(gen)); | |
| 245 } | 235 } |
| 246 | 236 |
| 247 sk_data_t* sk_image_encode(const sk_image_t* cimage) { | 237 sk_data_t* sk_image_encode(const sk_image_t* cimage) { |
| 248 return ToData(AsImage(cimage)->encode()); | 238 return ToData(AsImage(cimage)->encode()); |
| 249 } | 239 } |
| 250 | 240 |
| 251 void sk_image_ref(const sk_image_t* cimage) { | 241 void sk_image_ref(const sk_image_t* cimage) { |
| 252 AsImage(cimage)->ref(); | 242 AsImage(cimage)->ref(); |
| 253 } | 243 } |
| 254 | 244 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 sk_image_t* cimage = sk_surface_new_image_snapshot(csurface); | 680 sk_image_t* cimage = sk_surface_new_image_snapshot(csurface); |
| 691 | 681 |
| 692 // HERE WE CROSS THE C..C++ boundary | 682 // HERE WE CROSS THE C..C++ boundary |
| 693 canvas->drawImage((const SkImage*)cimage, 20, 20, NULL); | 683 canvas->drawImage((const SkImage*)cimage, 20, 20, NULL); |
| 694 | 684 |
| 695 sk_path_delete(cpath); | 685 sk_path_delete(cpath); |
| 696 sk_paint_delete(cpaint); | 686 sk_paint_delete(cpaint); |
| 697 sk_image_unref(cimage); | 687 sk_image_unref(cimage); |
| 698 sk_surface_unref(csurface); | 688 sk_surface_unref(csurface); |
| 699 } | 689 } |
| OLD | NEW |