OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 default: | 237 default: |
238 ASSERT_NOT_REACHED(); | 238 ASSERT_NOT_REACHED(); |
239 return "?"; | 239 return "?"; |
240 }; | 240 }; |
241 } | 241 } |
242 | 242 |
243 std::unique_ptr<JSONObject> objectForBitmapData(const SkBitmap& bitmap) | 243 std::unique_ptr<JSONObject> objectForBitmapData(const SkBitmap& bitmap) |
244 { | 244 { |
245 Vector<unsigned char> output; | 245 Vector<unsigned char> output; |
246 | 246 |
247 if (RefPtr<SkImage> image = fromSkSp(SkImage::MakeFromBitmap(bitmap))) { | 247 if (sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap)) { |
248 ImagePixelLocker pixelLocker(image, kUnpremul_SkAlphaType, kRGBA_8888_Sk
ColorType); | 248 ImagePixelLocker pixelLocker(image, kUnpremul_SkAlphaType, kRGBA_8888_Sk
ColorType); |
249 ImageDataBuffer imageData(IntSize(image->width(), image->height()), | 249 ImageDataBuffer imageData(IntSize(image->width(), image->height()), |
250 static_cast<const unsigned char*>(pixelLocker.pixels())); | 250 static_cast<const unsigned char*>(pixelLocker.pixels())); |
251 | 251 |
252 PNGImageEncoder::encode(imageData, &output); | 252 PNGImageEncoder::encode(imageData, &output); |
253 } | 253 } |
254 | 254 |
255 std::unique_ptr<JSONObject> dataItem = JSONObject::create(); | 255 std::unique_ptr<JSONObject> dataItem = JSONObject::create(); |
256 dataItem->setString("base64", WTF::base64Encode(reinterpret_cast<char*>(outp
ut.data()), output.size())); | 256 dataItem->setString("base64", WTF::base64Encode(reinterpret_cast<char*>(outp
ut.data()), output.size())); |
257 dataItem->setString("mimeType", "image/png"); | 257 dataItem->setString("mimeType", "image/png"); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 return pictureAsJSON->toPrettyJSONString(); | 860 return pictureAsJSON->toPrettyJSONString(); |
861 } | 861 } |
862 | 862 |
863 void showSkPicture(const SkPicture* picture) | 863 void showSkPicture(const SkPicture* picture) |
864 { | 864 { |
865 WTFLogAlways("%s\n", pictureAsDebugString(picture).utf8().data()); | 865 WTFLogAlways("%s\n", pictureAsDebugString(picture).utf8().data()); |
866 } | 866 } |
867 #endif | 867 #endif |
868 | 868 |
869 } // namespace blink | 869 } // namespace blink |
OLD | NEW |