zoukankan      html  css  js  c++  java
  • android GUI 流程记录


    ViewRootImpl 与 wms

     

    ViewRootImple里的 WindowSeesion是WindowManagerService的proxy, 通过这个句柄来调用WMS的功能
    而W是 wms用来控制app window的句柄, 比如dispatch各种事件,focus,move,resize等, 都是由wms控制w来完成
    android 按键触屏分发大致的流程:
    ·  WMS所在的SystemServer进程接收到按键事件。
    ·  WMS找到UI位于屏幕顶端的进程所对应的IWindow对象,这是一个Bp端对象。
    ·  调用这个IWindow对象的dispatchKey。IWindow对象的Bn端位于ViewRoot中,ViewRoot再根据内部View的位置信息找到真正处理这个事件的View,最后调用dispatchKey函数完成按键的处理。


    activity resume时:

    ViewRootImpl:
    setView()->:
    (1)mView = view; //decorView
    (2)requestLayout();
    (3)mWindowSession.addToDisplay(mWindow, mSeq, mWindowAttributes, //mWindow 即W, 把W句柄给wms
    getHostVisibility(), mDisplay.getDisplayId(),
    mAttachInfo.mContentInsets, mInputChannel);

    requestLayout()->scheduleTraversals()->TraversalRunnable::doTraversal()->performTraversals():
    (1)relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
    int relayoutResult = mWindowSession.relayout(
    mWindow, mSeq, params,
    (int) (mView.getMeasuredWidth() * appScale + 0.5f),
    (int) (mView.getMeasuredHeight() * appScale + 0.5f),
    viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
    mWinFrame, mPendingOverscanInsets, mPendingContentInsets, mPendingVisibleInsets,
    mPendingConfiguration, mSurface);
    |
    Binder
    |
    WindowManagerService:
    relayoutWindow()->:
    ...
    //在wms进程中创建surface并且拷贝到app进程中去
    //createSurfaceLocked() --JNI--> nativeCreate, nativeSetXXX 等在c++层实现 -> SurfaceComposerClient::createSurface
    ①SurfaceControl surfaceControl = winAnimator.createSurfaceLocked();
    -> new SurfaceControl() --JNI--> nativeCreate() -> SurfaceComposerClient::createSurface ->
    ②if (surfaceControl != null) {
    outSurface.copyFrom(surfaceControl); //把surface对象从wms进程拷贝到app进程, java层的surface对象都只是对native对象的封装,包含一个native surface的指针
    if (SHOW_TRANSACTIONS) Slog.i(TAG,
    " OUT SURFACE " + outSurface + ": copied");
    } else {
    // For some reason there isn't a surface. Clear the
    // caller's object so they see the same state.
    outSurface.release();
    }
    ...
    (2)performMeasure()->mView.measure(childWidthMeasureSpec, childHeightMeasureSpec); //测量长宽
    (3)performLayout()->host.layout(0, 0, host.getMeasuredWidth(), host.getMeasuredHeight()); //确定位置
    (4)performDraw()->draw(fullRedrawNeeded) //画图
    ①Surface surface = mSurface;
    ...
    ②drawSoftware(surface, attachInfo, yoff, scalingRequired, dirty))
    canvas = mSurface.lockCanvas(dirty);
    ...
    mView.draw(canvas);
    ...
    surface.unlockCanvasAndPost(canvas);

  • 相关阅读:
    Oracle数据库链Database links
    记录中文字符的烦恼
    oracle游标应用难点 sys_refcursor 和 cursor(转)
    C# Delegate类
    Oracle_merge into 中 using 后的查询表如果有参数的情况
    C# partial
    Excel快捷键
    时间格式的问题
    Ref_cursor
    .Net 引用命名空间
  • 原文地址:https://www.cnblogs.com/hushpa/p/6502369.html
Copyright © 2011-2022 走看看