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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 visitor->trace(m_observers); | 687 visitor->trace(m_observers); |
688 visitor->trace(m_context); | 688 visitor->trace(m_context); |
689 #endif | 689 #endif |
690 DocumentVisibilityObserver::trace(visitor); | 690 DocumentVisibilityObserver::trace(visitor); |
691 HTMLElement::trace(visitor); | 691 HTMLElement::trace(visitor); |
692 } | 692 } |
693 | 693 |
694 void HTMLCanvasElement::updateExternallyAllocatedMemory() const | 694 void HTMLCanvasElement::updateExternallyAllocatedMemory() const |
695 { | 695 { |
696 int bufferCount = 0; | 696 int bufferCount = 0; |
697 if (m_imageBuffer) | 697 if (m_imageBuffer) { |
698 bufferCount++; | 698 bufferCount++; |
| 699 if (m_imageBuffer->isAccelerated()) { |
| 700 // The number of internal GPU buffers vary between one (stable |
| 701 // non-displayed state) and three (triple-buffered animations). |
| 702 // Adding 2 is a pessimistic but relevant estimate. |
| 703 // Note: These buffers might be allocated in GPU memory. |
| 704 bufferCount += 2; |
| 705 } |
| 706 } |
699 if (m_copiedImage) | 707 if (m_copiedImage) |
700 bufferCount++; | 708 bufferCount++; |
701 | 709 |
| 710 // Four bytes per pixel per buffer. |
702 Checked<intptr_t, RecordOverflow> checkedExternallyAllocatedMemory = 4 * buf
ferCount; | 711 Checked<intptr_t, RecordOverflow> checkedExternallyAllocatedMemory = 4 * buf
ferCount; |
703 if (is3D()) | 712 if (is3D()) |
704 checkedExternallyAllocatedMemory += toWebGLRenderingContext(m_context.ge
t())->externallyAllocatedBytesPerPixel(); | 713 checkedExternallyAllocatedMemory += toWebGLRenderingContext(m_context.ge
t())->externallyAllocatedBytesPerPixel(); |
705 | 714 |
706 checkedExternallyAllocatedMemory *= width(); | 715 checkedExternallyAllocatedMemory *= width(); |
707 checkedExternallyAllocatedMemory *= height(); | 716 checkedExternallyAllocatedMemory *= height(); |
708 intptr_t externallyAllocatedMemory; | 717 intptr_t externallyAllocatedMemory; |
709 if (checkedExternallyAllocatedMemory.safeGet(externallyAllocatedMemory) == C
heckedState::DidOverflow) | 718 if (checkedExternallyAllocatedMemory.safeGet(externallyAllocatedMemory) == C
heckedState::DidOverflow) |
710 externallyAllocatedMemory = std::numeric_limits<intptr_t>::max(); | 719 externallyAllocatedMemory = std::numeric_limits<intptr_t>::max(); |
711 | 720 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 { | 874 { |
866 return !originClean(); | 875 return !originClean(); |
867 } | 876 } |
868 | 877 |
869 FloatSize HTMLCanvasElement::sourceSize() const | 878 FloatSize HTMLCanvasElement::sourceSize() const |
870 { | 879 { |
871 return FloatSize(width(), height()); | 880 return FloatSize(width(), height()); |
872 } | 881 } |
873 | 882 |
874 } | 883 } |
OLD | NEW |