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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 m_didFailToCreateImageBuffer = !m_imageBuffer; | 730 m_didFailToCreateImageBuffer = !m_imageBuffer; |
731 } | 731 } |
732 | 732 |
733 PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe
r) const | 733 PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe
r) const |
734 { | 734 { |
735 if (!isPaintable()) | 735 if (!isPaintable()) |
736 return nullptr; | 736 return nullptr; |
737 if (!m_context) | 737 if (!m_context) |
738 return createTransparentImage(size()); | 738 return createTransparentImage(size()); |
739 | 739 |
740 if (!m_copiedImage && buffer()) { | 740 bool needToUpdate = !m_copiedImage; |
741 if (m_context && m_context->is3d()) | 741 // The concept of SourceDrawingBuffer is valid on only WebGL. |
742 m_context->paintRenderingResultsToCanvas(sourceBuffer); | 742 if (m_context->is3d()) |
| 743 needToUpdate |= m_context->paintRenderingResultsToCanvas(sourceBuffer); |
| 744 if (needToUpdate && buffer()) { |
743 m_copiedImage = buffer()->copyImage(CopyBackingStore, Unscaled); | 745 m_copiedImage = buffer()->copyImage(CopyBackingStore, Unscaled); |
744 updateExternallyAllocatedMemory(); | 746 updateExternallyAllocatedMemory(); |
745 } | 747 } |
746 return m_copiedImage; | 748 return m_copiedImage; |
747 } | 749 } |
748 | 750 |
749 void HTMLCanvasElement::discardImageBuffer() | 751 void HTMLCanvasElement::discardImageBuffer() |
750 { | 752 { |
751 m_contextStateSaver.clear(); // uses context owned by m_imageBuffer | 753 m_contextStateSaver.clear(); // uses context owned by m_imageBuffer |
752 m_imageBuffer.clear(); | 754 m_imageBuffer.clear(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 { | 834 { |
833 return !originClean(); | 835 return !originClean(); |
834 } | 836 } |
835 | 837 |
836 FloatSize HTMLCanvasElement::sourceSize() const | 838 FloatSize HTMLCanvasElement::sourceSize() const |
837 { | 839 { |
838 return FloatSize(width(), height()); | 840 return FloatSize(width(), height()); |
839 } | 841 } |
840 | 842 |
841 } | 843 } |
OLD | NEW |