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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 return AtomicString(toDataURLInternal("image/png", 0, FrontBuffer)); | 477 return AtomicString(toDataURLInternal("image/png", 0, FrontBuffer)); |
478 } | 478 } |
479 | 479 |
480 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double
* quality, SourceDrawingBuffer sourceBuffer) const | 480 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double
* quality, SourceDrawingBuffer sourceBuffer) const |
481 { | 481 { |
482 if (!isPaintable()) | 482 if (!isPaintable()) |
483 return String("data:,"); | 483 return String("data:,"); |
484 | 484 |
485 String encodingMimeType = toEncodingMimeType(mimeType); | 485 String encodingMimeType = toEncodingMimeType(mimeType); |
486 if (!m_context) { | 486 if (!m_context) { |
487 RefPtrWillBeRawPtr<ImageData> imageData = ImageData::create(m_size); | 487 ImageData* imageData = ImageData::create(m_size); |
| 488 ScopedDisposal<ImageData> disposer(imageData); |
488 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toD
ataURL(encodingMimeType, quality); | 489 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toD
ataURL(encodingMimeType, quality); |
489 } | 490 } |
490 | 491 |
491 if (m_context->is3d()) { | 492 if (m_context->is3d()) { |
492 // Get non-premultiplied data because of inaccurate premultiplied alpha
conversion of buffer()->toDataURL(). | 493 // Get non-premultiplied data because of inaccurate premultiplied alpha
conversion of buffer()->toDataURL(). |
493 RefPtrWillBeRawPtr<ImageData> imageData = | 494 ImageData* imageData = toWebGLRenderingContextBase(m_context.get())->pai
ntRenderingResultsToImageData(sourceBuffer); |
494 toWebGLRenderingContextBase(m_context.get())->paintRenderingResultsT
oImageData(sourceBuffer); | 495 ScopedDisposal<ImageData> disposer(imageData); |
495 if (imageData) | 496 if (imageData) |
496 return ImageDataBuffer(imageData->size(), imageData->data()->data())
.toDataURL(encodingMimeType, quality); | 497 return ImageDataBuffer(imageData->size(), imageData->data()->data())
.toDataURL(encodingMimeType, quality); |
497 m_context->paintRenderingResultsToCanvas(sourceBuffer); | 498 m_context->paintRenderingResultsToCanvas(sourceBuffer); |
498 } | 499 } |
499 | 500 |
500 return buffer()->toDataURL(encodingMimeType, quality); | 501 return buffer()->toDataURL(encodingMimeType, quality); |
501 } | 502 } |
502 | 503 |
503 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q
ualityArgument, ExceptionState& exceptionState) const | 504 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q
ualityArgument, ExceptionState& exceptionState) const |
504 { | 505 { |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 { | 878 { |
878 return FloatSize(width(), height()); | 879 return FloatSize(width(), height()); |
879 } | 880 } |
880 | 881 |
881 bool HTMLCanvasElement::isOpaque() const | 882 bool HTMLCanvasElement::isOpaque() const |
882 { | 883 { |
883 return m_context && !m_context->hasAlpha(); | 884 return m_context && !m_context->hasAlpha(); |
884 } | 885 } |
885 | 886 |
886 } // blink | 887 } // blink |
OLD | NEW |