开发者选项 Disable HW overlays

android 4.2.2

取得flags位,并mTransactionFlags把相应的位清零。

uint32_t SurfaceFlinger::getTransactionFlags(uint32_t flags)
{
    return android_atomic_and(~flags, &mTransactionFlags) & flags;
}




1.Disable HW overlays

1../packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java

setting得到SurfaceFlinger服务,通过binder发命令。


private void writeDisableOverlaysOption() {

        try {
            IBinder flinger = ServiceManager.getService("SurfaceFlinger");
            if (flinger != null) {
                Parcel data = Parcel.obtain();
                data.writeInterfaceToken("android.ui.ISurfaceComposer");
                final int disableOverlays = mDisableOverlays.isChecked() ? 1 : 0;
                data.writeInt(disableOverlays);
                flinger.transact(1008, data, null, 0);
                data.recycle();

                updateFlingerOptions();
            }
        } catch (RemoteException ex) {
        }
    }


2.SurfaceFlinger.cpp

SurfaceFlinger处理命令,置位相应的标志,重新画图。

           case 1008:  // toggle use of hw composer
                n = data.readInt32();
                mDebugDisableHWC = n ? 1 : 0;
                invalidateHwcGeometry();  //mHwWorkListDirty = true;
                repaintEverything();            
                return NO_ERROR;

3.SurfaceFlinger.cpp

重新画图。

void SurfaceFlinger::repaintEverything() {
    android_atomic_or(1, &mRepaintEverything);
    signalTransaction();
}

4. 4-6给队列发消息

void SurfaceFlinger::signalTransaction() {
    mEventQueue.invalidate();

5.


#define INVALIDATE_ON_VSYNC 1

void MessageQueue::invalidate() {
#if INVALIDATE_ON_VSYNC
    mEvents->requestNextVsync();
#else
    mHandler->dispatchInvalidate();
#endif
}   
    

6.

frameworks/native/services/surfaceflinger/MessageQueue.cpp

void MessageQueue::Handler::dispatchInvalidate() {
    if ((android_atomic_or(eventMaskInvalidate, &mEventMask) & eventMaskInvalidate) == 0) {
        mQueue.mLooper->sendMessage(this, Message(MessageQueue::INVALIDATE));
    }
}

7.处理重画的消息

void SurfaceFlinger::onMessageReceived(int32_t what) {
    ATRACE_CALL();
    switch (what) {
    case MessageQueue::INVALIDATE:
        TF_PRINT(TF_EVENT_START, "SF", "Invalidate", "Composition invalidate start");
        handleMessageTransaction();
        handleMessageInvalidate();
        signalRefresh();
        TF_PRINT(TF_EVENT_STOP, "SF", "Invalidate", "Composition invalidate end");
        break;
    case MessageQueue::REFRESH:
        TF_PRINT(TF_EVENT_START, "SF", "CompositionRefresh", "Composition refresh start");
        handleMessageRefresh();
        TF_PRINT(TF_EVENT_STOP, "SF", "CompositionRefresh", "Composition refresh end");
        break;
    }
}

8.图形属性大小、旋转方向没有发生变化,所以不会调用

void SurfaceFlinger::handleMessageTransaction() {
    uint32_t transactionFlags = peekTransactionFlags(eTransactionMask);// transactionFlags=mTransactionFlags
    if (transactionFlags) { // transactionFlags = false 所以不会走下边。
        handleTransaction(transactionFlags);
    }
}

9.重新计算可视区,mVisibleRegionsDirty推测是false.

void SurfaceFlinger::handleMessageInvalidate() {
    ATRACE_CALL();
    handlePageFlip();
}


void SurfaceFlinger::handlePageFlip()
{
    Region dirtyRegion;

    bool visibleRegions = false;
    const LayerVector& currentLayers(mDrawingState.layersSortedByZ);
    const size_t count = currentLayers.size();
    for (size_t i=0 ; i<count ; i++) {
        const sp<LayerBase>& layer(currentLayers[i]);
        const Region dirty(layer->latchBuffer(visibleRegions));
        const Layer::State& s(layer->drawingState());
        invalidateLayerStack(s

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值