OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
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 | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 385 |
386 if (m_size.isEmpty() || !buffer()) | 386 if (m_size.isEmpty() || !buffer()) |
387 return String("data:,"); | 387 return String("data:,"); |
388 | 388 |
389 String encodingMimeType = toEncodingMimeType(mimeType); | 389 String encodingMimeType = toEncodingMimeType(mimeType); |
390 | 390 |
391 // Try to get ImageData first, as that may avoid lossy conversions. | 391 // Try to get ImageData first, as that may avoid lossy conversions. |
392 RefPtr<ImageData> imageData = getImageData(); | 392 RefPtr<ImageData> imageData = getImageData(); |
393 | 393 |
394 if (imageData) | 394 if (imageData) |
395 return ImageDataToDataURL(*imageData, encodingMimeType, quality); | 395 return ImageDataToDataURL(ImageDataBuffer(imageData->size(), imageData->
data()), encodingMimeType, quality); |
396 | 396 |
397 if (m_context) | 397 if (m_context) |
398 m_context->paintRenderingResultsToCanvas(); | 398 m_context->paintRenderingResultsToCanvas(); |
399 | 399 |
400 return buffer()->toDataURL(encodingMimeType, quality); | 400 return buffer()->toDataURL(encodingMimeType, quality); |
401 } | 401 } |
402 | 402 |
403 PassRefPtr<ImageData> HTMLCanvasElement::getImageData() | 403 PassRefPtr<ImageData> HTMLCanvasElement::getImageData() |
404 { | 404 { |
405 if (!m_context || !m_context->is3d()) | 405 if (!m_context || !m_context->is3d()) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 ASSERT(m_hasCreatedImageBuffer); | 552 ASSERT(m_hasCreatedImageBuffer); |
553 IntSize unscaledSize = size(); | 553 IntSize unscaledSize = size(); |
554 IntSize size = convertLogicalToDevice(unscaledSize); | 554 IntSize size = convertLogicalToDevice(unscaledSize); |
555 AffineTransform transform; | 555 AffineTransform transform; |
556 if (size.width() && size.height()) | 556 if (size.width() && size.height()) |
557 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig
ht() / unscaledSize.height()); | 557 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig
ht() / unscaledSize.height()); |
558 return m_imageBuffer->baseTransform() * transform; | 558 return m_imageBuffer->baseTransform() * transform; |
559 } | 559 } |
560 | 560 |
561 } | 561 } |
OLD | NEW |