| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 lookUpTable[SkColorGetG(color)], | 161 lookUpTable[SkColorGetG(color)], |
| 162 lookUpTable[SkColorGetB(color)]); | 162 lookUpTable[SkColorGetB(color)]); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 template <Multiply multiplied> | 167 template <Multiply multiplied> |
| 168 PassRefPtr<ByteArray> getImageData(const IntRect& rect, SkDevice& srcDevice, | 168 PassRefPtr<ByteArray> getImageData(const IntRect& rect, SkDevice& srcDevice, |
| 169 const IntSize& size) | 169 const IntSize& size) |
| 170 { | 170 { |
| 171 float area = 4.0f * rect.width() * rect.height(); |
| 172 if (area > static_cast<float>(std::numeric_limits<int>::max())) |
| 173 return 0; |
| 174 |
| 171 RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() *
4); | 175 RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() *
4); |
| 172 | 176 |
| 173 SkBitmap::Config srcConfig = srcDevice.accessBitmap(false).config(); | 177 SkBitmap::Config srcConfig = srcDevice.accessBitmap(false).config(); |
| 174 | 178 |
| 175 if (srcConfig == SkBitmap::kNo_Config) { | 179 if (srcConfig == SkBitmap::kNo_Config) { |
| 176 // This is an empty SkBitmap that could not be configured. | 180 // This is an empty SkBitmap that could not be configured. |
| 177 ASSERT(!size.width() || !size.height()); | 181 ASSERT(!size.width() || !size.height()); |
| 178 return result.release(); | 182 return result.release(); |
| 179 } | 183 } |
| 180 | 184 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 389 |
| 386 return ImageToDataURL(bitmap, mimeType, quality); | 390 return ImageToDataURL(bitmap, mimeType, quality); |
| 387 } | 391 } |
| 388 | 392 |
| 389 String ImageDataToDataURL(const ImageData& source, const String& mimeType, const
double* quality) | 393 String ImageDataToDataURL(const ImageData& source, const String& mimeType, const
double* quality) |
| 390 { | 394 { |
| 391 return ImageToDataURL(source, mimeType, quality); | 395 return ImageToDataURL(source, mimeType, quality); |
| 392 } | 396 } |
| 393 | 397 |
| 394 } // namespace WebCore | 398 } // namespace WebCore |
| OLD | NEW |