More Related Content
Similar to Chromium多线程滚动 (20)
Chromium多线程滚动
- 3. LayerChromium CCLayerImpl
scrollLayer scrollLayer
同步数据
NonCompositor ContentRoot NonCompositor ContentRoot
webcore更新 通知更新完成 滚动事件 上屏
- 4. visibleRect
当发生滚动时,可视区域会
发生改变,会根据可视区域
计算当前需要显示的Layer,
若该Layer没有同步到cc层,
就会创建空的SolidQuad显
示,同时会将滚动的偏移增
量同步给webcore线程,通
知其刷新重绘,当其刷新完
成就会上屏显示
- 5. 通知webcore对
LayerChromium树更新
scrollDelta
CCLayerTreeHostImpl
setNeedsCommitOnImplThread
ScrollBy
setNeedsRedrawOnImplThread
m_scrollLayer
调用CCLayerImpl::ScrollBy方法设置其m_scrollDelta值
drawQuad上屏
- 6. CCScheduler是个状态机,处理
5种状态,并有一个定时器
CCScheduler
CCFrameRateController出发,
webcore 1/60秒触发一次 Compositor
ACTIVE_NONE
Layout,去webcore中更
ACTIVE_BEGIN_FRAME 新LayerChromium树
将更新数据导入到纹理中 ACTIVE_BEGIN_UPDATE
_MORE_RESOURCES
同步LayerChromium树到 ACTIVE_COMMIT
CCLayerImpl树
drawQuads以及swapbuffer ACTIVE_DRAW
- 7. 对于双线程滚动来说,滚动的位置,以
及双线程之间滚动数据的同步主要是操
作这四个变量
m_scrollDelta
滚动的偏移增量,最终上屏的
Layer位置是:
m_scrollPosition – m_scrollDelta
双线程滚动主要是在Compositor
m_sentScrollDelta 线程操作这个变量来实现滚动
这个是Compositor线程传给webcore
线程的偏移增量
m_position
当前滚动的偏移,主要是针对
webcore中的LayerChromium树位置
m_scrollPosition 当前滚动的偏移,主要是针对
compositor中的CCLayerImpl树
- 8. compositor webcore
CCLayerTreeHostImpl::processScrollDelta
将scrollLayer的scrollDelta设置成sentScrollDelta,
准备数据的传递
CCThreadProxy::createBeginFrameAndCommitTaskOnImplThread
将sentScrollDelta数据封装CCScrollAndScaleSet
CCThreadProxy::beginFrameAndCommit
将得到的sentScrollDelta传给webcore处理
WebViewImpl::applyScrollAndScale
- 9. webcore compositor
LayerChromium::pushPropertiesTo
Layer->setPosition(m_position)
Layer->setScrollPosition(m_scrollPosition)
Layer->setScrollDelta(layer->scrollDelta() – layer->sentScrollDelta())
Layer->setSentScrollDelta(IntSize())