Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: Source/core/html/HTMLCanvasElement.cpp

Issue 910613003: Trigger hardware accelerated canvas GC more aggressively. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Better comment Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698