IntPoint and PluginMainThreadScheduler

来源:互联网 发布:华气厚普数据导出 编辑:程序博客网 时间:2024/05/20 09:45
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);
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 整容证明开不了怎么办 无法开整容证明怎么办 整容后换身份证怎么办 换身份证了驾照怎么办 网易云安装不了怎么办 上网站看不到东西怎么办 电脑显示应用程序错误怎么办 电脑出现应用程序错误怎么办 老师教错了怎么办 老师不让坐位上怎么办 老师问学生家长借钱怎么办 学生向老师借钱怎么办 老师向家长借钱怎么办 癌症身上很痒怎么办 花生地有老鼠怎么办 国企不涨工资怎么办 mpacc写作写不好怎么办 宝宝惊着了怎么办 半夜到昆明机场怎么办 离婚了老公纠缠怎么办 网络写手侵权怎么办 etc卡不能用怎么办 在海上遇到大浪怎么办 数学太差了怎么办 四年级数学成绩差怎么办 小学科学成绩差怎么办 小学科学成绩不好怎么办 高中数理化学不好怎么办 初中生长痘痘怎么办 怎么办朱杰mp3微盘 摄像机镜头起雾怎么办 显卡风扇声音大怎么办 卧室灯不在中间怎么办 小龙头发乱了怎么办 孩子头睡平了怎么办 一只眼失明找不到工作怎么办 幼儿园的小朋友不听话怎么办 密码日记本忘记密码怎么办 怀孕33周早产怎么办 怀孕35周便秘怎么办 六个月宝宝干咳怎么办