OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
8 * met: | 8 * met: |
9 * | 9 * |
10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 lookUpTable[SkColorGetB(color)]); | 249 lookUpTable[SkColorGetB(color)]); |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 PassRefPtr<SkColorFilter> ImageBuffer::createColorSpaceFilter(ColorSpace srcColo
rSpace, | 254 PassRefPtr<SkColorFilter> ImageBuffer::createColorSpaceFilter(ColorSpace srcColo
rSpace, |
255 ColorSpace dstColorSpace) | 255 ColorSpace dstColorSpace) |
256 { | 256 { |
257 const uint8_t* lut = ColorSpaceUtilities::getConversionLUT(dstColorSpace, sr
cColorSpace); | 257 const uint8_t* lut = ColorSpaceUtilities::getConversionLUT(dstColorSpace, sr
cColorSpace); |
258 if (!lut) | 258 if (!lut) |
259 return 0; | 259 return nullptr; |
260 | 260 |
261 return adoptRef(SkTableColorFilter::CreateARGB(0, lut, lut, lut)); | 261 return adoptRef(SkTableColorFilter::CreateARGB(0, lut, lut, lut)); |
262 } | 262 } |
263 | 263 |
264 template <Multiply multiplied> | 264 template <Multiply multiplied> |
265 PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, GraphicsContext*
context, const IntSize& size) | 265 PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, GraphicsContext*
context, const IntSize& size) |
266 { | 266 { |
267 float area = 4.0f * rect.width() * rect.height(); | 267 float area = 4.0f * rect.width() * rect.height(); |
268 if (area > static_cast<float>(std::numeric_limits<int>::max())) | 268 if (area > static_cast<float>(std::numeric_limits<int>::max())) |
269 return 0; | 269 return nullptr; |
270 | 270 |
271 RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(re
ct.width() * rect.height() * 4); | 271 RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(re
ct.width() * rect.height() * 4); |
272 | 272 |
273 unsigned char* data = result->data(); | 273 unsigned char* data = result->data(); |
274 | 274 |
275 if (rect.x() < 0 | 275 if (rect.x() < 0 |
276 || rect.y() < 0 | 276 || rect.y() < 0 |
277 || rect.maxX() > size.width() | 277 || rect.maxX() > size.width() |
278 || rect.maxY() > size.height()) | 278 || rect.maxY() > size.height()) |
279 result->zeroFill(); | 279 result->zeroFill(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 399 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
400 return "data:,"; | 400 return "data:,"; |
401 | 401 |
402 Vector<char> base64Data; | 402 Vector<char> base64Data; |
403 base64Encode(encodedImage, base64Data); | 403 base64Encode(encodedImage, base64Data); |
404 | 404 |
405 return "data:" + mimeType + ";base64," + base64Data; | 405 return "data:" + mimeType + ";base64," + base64Data; |
406 } | 406 } |
407 | 407 |
408 } // namespace WebCore | 408 } // namespace WebCore |
OLD | NEW |