IntPoint and PluginMainThreadScheduler

IntPoint 描述一個點
有x、y兩個變量,支持move、expandedTo、shrunkTo等方法
IntSize 描述一個大小
有width,height兩個變量,支持scale、expand等接口
IntRect  描述一個巨星
有一個m_location和一個size,location是這個矩形左上角的座標
right和bottom這個點,並不在這個矩形裏面。
inflateX(int dx),向左右各擴x
intersect(IntRect other)求兩個矩形的相交矩形

IntPoint Widget::convertToContainingView(const IntPoint& localPoint)
對於Widget中一個點,這個點的位置是相對自己而言的。
函數目的是要得到這個點在其父窗口的位置,具體實現就是加上自身在父窗口位置。
比如Widget相對父窗口爲(1,1),point相對自己爲(2,2)
那麼調用convertChildToSelf(widget, localPoint(2,2))
//傳入child和child中的一個point,得到point在parent中位置
在其實現過程中,(2,2)moveto(1,1),返回(3,3)

IntPoint Widget::convertToContainingWindow(const IntPoint& localPoint) const
對於Widget中的一個點,其座標是相對widget而言,獲取其在根窗口中的位置。
其實現,就是不停得調用上面的函數,直到parent爲null

IntPoint Widget::convertFromContainingView(const IntPoint& parentPoint) const
對於Widget中的一個點,這個點的位置是相對自己直接父類而言的。
函數目的是要得到這個點相對自己的位置,其實現就是用parentPoint減掉自己的位置。

IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const
對於一個Widget,傳入一個相對根窗口的絕對位置的點,返回這個點在這個widget中的位置。
其實現是不停得減掉這個widget的ParentView的位置。

Widget
PlatformWidget m_widget;
在Android中爲WebCoreViewBridge


ScrollView
viewPoint = contentsPoint - scrollOffset();
contentsPoint 只對於整個ScrollView而言
windowClipRect 返回一個區域
windowClipRectForLayer 返回一個與Layer相關區域
返回這2個Rect的交集

ClipRects
裏面有三個IntRect
    IntRect m_overflowClipRect;
    IntRect m_fixedClipRect;
    IntRect m_posClipRect;

PluginView::platformPluginWidget
返回m_window,對於Android而言PluginWidgetAndroid
它包含了Android平臺適配的成員和方法
pluginView、webViewCore、draw、sendEvent等等
不少是與skia有關的
SkIRect                 m_pluginBounds; // relative to the page
SkIRect                 m_visibleDocRect; // relative to the page
SkIRect                 m_requestedVisibleRect; // relative to the page

PlatformWidget
對於Android平臺而言WebCoreViewBridge
裏面有三個Rect    
WebCore::IntRect    m_bounds;
WebCore::IntRect    m_windowBounds;
WebCore::IntRect    m_visibleBounds;
PluginView
IntRect m_clipRect; // The clip rect to apply to a windowed plug-in
IntRect m_windowRect; // Our window rect.
IntRect m_pageRect;

PluginView
platformPluginWidget PluginWidgetAndroid m_window
PlatformWidget  WebCoreViewBridge


PluginMainThreadScheduler
Call 封裝了一個函數指針和用戶數據
performCall調用這個函數指針傳入用戶數據
PluginMainThreadScheduler  有一個“HashMap<NPP, Deque<Call> > CallQueueMap”的map
PluginMainThreadScheduler::registerPlugin(NPP npp)
在哈希map中加入NPP
PluginMainThreadScheduler::scheduleCall(NPP npp, MainThreadFunction function, void* userData)
在哈希map中找到NPP,加入function和userData,調用callOnMainThread
在主函數中調度。(會檢查所有未執行的函數進行執行)
void PluginMainThreadScheduler::dispatchCallsForPlugin(NPP npp, const Deque<Call>& calls)
傳入一個call隊列,調用裏面的函數。
void PluginMainThreadScheduler::dispatchCalls()
將map中的每一個隊列取出,調用各個隊列的各個call函數



Schedule process:
PluginMainThreadScheduler::scheduleCall(NPP npp, MainThreadFunction function, void* userData)
-void callOnMainThread(MainThreadFunction* function, void* context)
  functionQueue().append(FunctionWithContext(function, context));
  scheduleDispatchFunctionsOnMainThread
--MainThreadAndroid::scheduleDispatchFunctionsOnMainThread
    AndroidThreading::scheduleDispatchFunctionsOnMainThread();
---PlatformBridge void AndroidThreading::scheduleDispatchFunctionsOnMainThread()
     JavaSharedClient::EnqueueFunctionPtr(timeoutFired, 0);
----void JavaSharedClient::EnqueueFunctionPtr(void (*proc)(void* payload),
                                              void* payload)
       gTimerClient->signalServiceFuncPtrQueue();
-----void JavaBridge::signalServiceFuncPtrQueue()
        env->CallVoidMethod(obj.get(), mSignalFuncPtrQueue);
------JWebCoreJavaBridge .private void signalServiceFuncPtrQueue()
           sendMessage(msg);//key point, make sure run on the main thread
          nativeServiceFuncPtrQueue
-------JavaBridge::ServiceFuncPtrQueue
           JavaSharedClient::ServiceFunctionPtrQueue();
--------void JavaSharedClient::ServiceFunctionPtrQueue()
             proc(payload);
---------timeoutFired 
               dispatchFunctionsFromMainThread
----------dispatchFunctionsFromMainThread
                invocation.function(invocation.context);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章