Chromium Code Reviews| 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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 m_didFailToCreateImageBuffer = !m_imageBuffer; | 699 m_didFailToCreateImageBuffer = !m_imageBuffer; | 
| 700 } | 700 } | 
| 701 | 701 | 
| 702 PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe r) const | 702 PassRefPtr<Image> HTMLCanvasElement::copiedImage(SourceDrawingBuffer sourceBuffe r) const | 
| 703 { | 703 { | 
| 704 if (!canCreateImageBuffer(size())) | 704 if (!canCreateImageBuffer(size())) | 
| 705 return nullptr; | 705 return nullptr; | 
| 706 if (!m_context) | 706 if (!m_context) | 
| 707 return createTransparentImage(size()); | 707 return createTransparentImage(size()); | 
| 708 | 708 | 
| 709 if (!m_copiedImage && buffer()) { | 709 // The concept of BackBuffer is valid on only WebGL. | 
| 710 if (m_context && m_context->is3d()) | 710 if (m_context->is2d()) | 
| 
 
aandrey
2014/12/08 20:36:46
Seems like this code has no effect (unless a conte
 
dshwang
2014/12/08 20:46:25
That's right. It has no effect, because CanvasRend
 
 | |
| 711 m_context->paintRenderingResultsToCanvas(sourceBuffer); | 711 sourceBuffer = FrontBuffer; | 
| 712 | |
| 713 bool needToUpdate = !m_copiedImage; | |
| 714 if (m_context->is3d()) | |
| 715 needToUpdate |= m_context->paintRenderingResultsToCanvas(sourceBuffer); | |
| 
 
dshwang
2014/12/08 20:17:08
That's good question! After re-thinking, vector is
 
 | |
| 716 if (needToUpdate && buffer()) { | |
| 712 m_copiedImage = buffer()->copyImage(CopyBackingStore, Unscaled); | 717 m_copiedImage = buffer()->copyImage(CopyBackingStore, Unscaled); | 
| 713 updateExternallyAllocatedMemory(); | 718 updateExternallyAllocatedMemory(); | 
| 714 } | 719 } | 
| 715 return m_copiedImage; | 720 return m_copiedImage; | 
| 716 } | 721 } | 
| 717 | 722 | 
| 718 void HTMLCanvasElement::discardImageBuffer() | 723 void HTMLCanvasElement::discardImageBuffer() | 
| 719 { | 724 { | 
| 720 m_contextStateSaver.clear(); // uses context owned by m_imageBuffer | 725 m_contextStateSaver.clear(); // uses context owned by m_imageBuffer | 
| 721 m_imageBuffer.clear(); | 726 m_imageBuffer.clear(); | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 801 { | 806 { | 
| 802 return !originClean(); | 807 return !originClean(); | 
| 803 } | 808 } | 
| 804 | 809 | 
| 805 FloatSize HTMLCanvasElement::sourceSize() const | 810 FloatSize HTMLCanvasElement::sourceSize() const | 
| 806 { | 811 { | 
| 807 return FloatSize(width(), height()); | 812 return FloatSize(width(), height()); | 
| 808 } | 813 } | 
| 809 | 814 | 
| 810 } | 815 } | 
| OLD | NEW |