mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Canvas2DLayerManager shouldn't use a task observer
Previously, Canvas2DLayerManager was using addTaskObserver to jump the task queue. After this CL, it goes to the end of the queue like a normal task. R=ojan@chromium.org Review URL: https://codereview.chromium.org/673783005
This commit is contained in:
parent
94b71abca0
commit
893e0200b8
@ -43,7 +43,7 @@ Canvas2DLayerManager::Canvas2DLayerManager()
|
||||
: m_bytesAllocated(0)
|
||||
, m_maxBytesAllocated(DefaultMaxBytesAllocated)
|
||||
, m_targetBytesAllocated(DefaultTargetBytesAllocated)
|
||||
, m_taskObserverActive(false)
|
||||
, m_limitPendingFramesTimer(this, &Canvas2DLayerManager::limitPendingFramesTimerFired)
|
||||
{
|
||||
}
|
||||
|
||||
@ -51,7 +51,6 @@ Canvas2DLayerManager::~Canvas2DLayerManager()
|
||||
{
|
||||
ASSERT(!m_bytesAllocated);
|
||||
ASSERT(!m_layerList.head());
|
||||
ASSERT(!m_taskObserverActive);
|
||||
}
|
||||
|
||||
void Canvas2DLayerManager::init(size_t maxBytesAllocated, size_t targetBytesAllocated)
|
||||
@ -59,10 +58,8 @@ void Canvas2DLayerManager::init(size_t maxBytesAllocated, size_t targetBytesAllo
|
||||
ASSERT(maxBytesAllocated >= targetBytesAllocated);
|
||||
m_maxBytesAllocated = maxBytesAllocated;
|
||||
m_targetBytesAllocated = targetBytesAllocated;
|
||||
if (m_taskObserverActive) {
|
||||
Platform::current()->currentThread()->removeTaskObserver(this);
|
||||
m_taskObserverActive = false;
|
||||
}
|
||||
if (m_limitPendingFramesTimer.isActive())
|
||||
m_limitPendingFramesTimer.stop();
|
||||
}
|
||||
|
||||
Canvas2DLayerManager& Canvas2DLayerManager::get()
|
||||
@ -71,16 +68,8 @@ Canvas2DLayerManager& Canvas2DLayerManager::get()
|
||||
return manager;
|
||||
}
|
||||
|
||||
void Canvas2DLayerManager::willProcessTask()
|
||||
void Canvas2DLayerManager::limitPendingFramesTimerFired(Timer<Canvas2DLayerManager>*)
|
||||
{
|
||||
}
|
||||
|
||||
void Canvas2DLayerManager::didProcessTask()
|
||||
{
|
||||
// Called after the script action for the current frame has been processed.
|
||||
ASSERT(m_taskObserverActive);
|
||||
Platform::current()->currentThread()->removeTaskObserver(this);
|
||||
m_taskObserverActive = false;
|
||||
Canvas2DLayerBridge* layer = m_layerList.head();
|
||||
while (layer) {
|
||||
Canvas2DLayerBridge* currentLayer = layer;
|
||||
@ -100,11 +89,8 @@ void Canvas2DLayerManager::layerDidDraw(Canvas2DLayerBridge* layer)
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_taskObserverActive) {
|
||||
m_taskObserverActive = true;
|
||||
// Schedule a call to didProcessTask() after completion of the current script task.
|
||||
Platform::current()->currentThread()->addTaskObserver(this);
|
||||
}
|
||||
if (!m_limitPendingFramesTimer.isActive())
|
||||
m_limitPendingFramesTimer.startOneShot(0, FROM_HERE);
|
||||
}
|
||||
|
||||
void Canvas2DLayerManager::layerTransientResourceAllocationChanged(Canvas2DLayerBridge* layer, intptr_t deltaBytes)
|
||||
|
||||
@ -25,14 +25,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef Canvas2DLayerManager_h
|
||||
#define Canvas2DLayerManager_h
|
||||
|
||||
#include "platform/Timer.h"
|
||||
#include "platform/graphics/Canvas2DLayerBridge.h"
|
||||
#include "public/platform/WebThread.h"
|
||||
|
||||
class Canvas2DLayerManagerTest;
|
||||
|
||||
namespace blink {
|
||||
|
||||
class PLATFORM_EXPORT Canvas2DLayerManager : public WebThread::TaskObserver {
|
||||
class PLATFORM_EXPORT Canvas2DLayerManager {
|
||||
public:
|
||||
static Canvas2DLayerManager& get();
|
||||
|
||||
@ -49,13 +49,13 @@ private:
|
||||
// internal methods
|
||||
void freeMemoryIfNecessary();
|
||||
void addLayerToList(Canvas2DLayerBridge*);
|
||||
virtual void willProcessTask() OVERRIDE;
|
||||
virtual void didProcessTask() OVERRIDE;
|
||||
|
||||
void limitPendingFramesTimerFired(Timer<Canvas2DLayerManager>*);
|
||||
|
||||
size_t m_bytesAllocated;
|
||||
size_t m_maxBytesAllocated;
|
||||
size_t m_targetBytesAllocated;
|
||||
bool m_taskObserverActive;
|
||||
Timer<Canvas2DLayerManager> m_limitPendingFramesTimer;
|
||||
DoublyLinkedList<Canvas2DLayerBridge> m_layerList;
|
||||
|
||||
friend class ::Canvas2DLayerManagerTest; // for unit testing
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user