Esempio n. 1
0
void GuiExtPool::configDisplay(uint32_t type, bool enable, uint32_t w, uint32_t h, uint32_t bufNum)
{
    GUIEXT_LOGD("  configDisplay, type=%d, enable=%d, w=%d, h=%d, bufNum=%d", type, enable, w, h, bufNum);
    if (type == HWC_DISPLAY_PRIMARY)
        GUIEXT_LOGI("  configDisplay, try to modify primary display, type=%d, w=%d, h=%d, bufNum=%d", type, w, h, bufNum);

    sp<DispInfo> disp = mDisplayList.valueFor(type);

    if (!enable || !w || !h || !bufNum) {
        if (disp != 0) {
            if (type != HWC_DISPLAY_PRIMARY) {
                GUIEXT_LOGI("  configDisplay, remove type=%d, w=%d, h=%d, bufNum=%d", type, w, h, bufNum);
                mDisplayList.removeItem(type);
            }

            GUIEXT_LOGI("  configDisplay, remove type=%d, enable=%d, w=%d, h=%d, bufNum=%d", type, enable, w, h, bufNum);
            mDisplayList.removeItem(type);
        }
    } else {
        if (disp == 0) {
            disp = new DispInfo();
            GUIEXT_LOGI("  configDisplay, add new type=%d, w=%d, h=%d, bufNum=%d", type, w, h, bufNum);
        } else {
            GUIEXT_LOGI("  configDisplay, change config of type=%d, w=%d, h=%d, bufNum=%d", type, w, h, bufNum);
        }

        disp->type = type;
        disp->w = w;
        disp->h = h;
        disp->bufNum = bufNum;
        mDisplayList.add(type, disp);
    }

    if (mDisplayList.size() == 0)
        GUIEXT_LOGW("  configDisplay, all display config has been removed, type=%d, enable=%d", type, enable);
}
Esempio n. 2
0
        virtual void binderDied(const wp<IBinder>& who) {
            uint32_t size = mItem.mConsumerList.size();
            GUIEXT_LOGI("consumer died, list size=%d, binder ptr=[%p]", size, who.unsafe_get());

            if (size == 0) {
                GUIEXT_LOGV("consumer died [%p], pool size is zero", who.unsafe_get());
            } else {
                for (uint32_t i = 0 ; i < size ; i++) {
                    GUIEXT_LOGV("   [c] compare index[%d], p=[%p], usage=%d, type=%d, id=%d", i,
                        mItem.mConsumerList[i]->token.get(),
                        mItem.mConsumerList[i]->usage, mItem.mConsumerList[i]->type, mItem.mConsumerList[i]->idx);
                    if (mItem.mConsumerList[i]->token.get() == who.unsafe_get()) {
                        GUIEXT_LOGW("   [c] found index[%d], p=[%p], usage=%d, type=%d, id=%d", i,
                            mItem.mConsumerList[i]->token.get(),
                            mItem.mConsumerList[i]->usage, mItem.mConsumerList[i]->type, mItem.mConsumerList[i]->idx);

                        mItem.release(mItem.mConsumerList[i]->usage, mItem.mConsumerList[i]->type, mItem.mConsumerList[i]->idx);
                        mItem.mConsumerList[i]->token = NULL;
                        mItem.mConsumerList[i]->pid = -1;
                        mItem.mConsumerList[i]->observer = NULL;
                    }
                }

                for (uint32_t i = 0; i < GUI_EXT_USAGE_MAX; i++) {
                    mItem.mIsDisconnected[i] = true;
                }
                bool isDisconnect = true;
                for (uint32_t i = 0 ; i < size ; i++) {
                    if (mItem.mConsumerList[i]->token != NULL) {
                        mItem.mIsDisconnected[mItem.mConsumerList[i]->usage] = false;
                        isDisconnect = false;
                        GUIEXT_LOGV("   [c] still have consumer, idx=%d, token=%p, pid=%d, usage=%d, type=%d, id=%d", i,
                            mItem.mConsumerList[i]->token.get(), mItem.mConsumerList[i]->pid,
                            mItem.mConsumerList[i]->usage, mItem.mConsumerList[i]->type, mItem.mConsumerList[i]->idx);
                    }
                }

                if (isDisconnect) {
                    mItem.mConsumerDeathListener->binderDied(mItem.mId);
                }

                GUIEXT_LOGV("consumer died done");
            }
        }
Esempio n. 3
0
        virtual void binderDied(const wp<IBinder>& who) {
            uint32_t size = mPool.mPoolList.size();
            GUIEXT_LOGI("producer died, pool size=%d, binder ptr=[%p]", size, who.unsafe_get());

            if (size == 0) {
                GUIEXT_LOGV("producer died [%p], pool size is zero", who.unsafe_get());
            } else {
                for (uint32_t i = size-1 ;; i--) {
                    GUIEXT_LOGV("   [p] compare index[%d], p=[%p]", i, mPool.mPoolList[i]->mProducerToken.get());
                    if (mPool.mPoolList[i]->mProducerToken.get() == who.unsafe_get()) {
                        GUIEXT_LOGW("   [p] found index[%d], p=[%p], id=%d", i, mPool.mPoolList[i]->mProducerToken.get(), mPool.mPoolList[i]->mId);
                        mPool.mPoolList[i]->mProducerToken = NULL;
                        mPool.mPoolList[i]->mProducerPid = -1;
                        mPool.removePoolItem(mPool.mPoolList[i]->mId);
                    }

                    if (i == 0)
                        break;
                }

                GUIEXT_LOGV("producer died done");
            }
        }
Esempio n. 4
0
void GuiExtClientProducer::serviceDiedLocked()
{
    GUIEXT_LOGI("[%s]", __func__);
}
Esempio n. 5
0
status_t GuiExtPool::alloc(const sp<IBinder>& token, uint32_t gralloc_usage, uint32_t w, uint32_t h, uint32_t * poolId)
{
    Mutex::Autolock _l(mLock);
    ATRACE_CALL();
    GUIEXT_LOGD("  alloc, gralloc_usage=%x, w=%d, h=%d", gralloc_usage, w, h);

    const nsecs_t time_start = systemTime();

    uint32_t size = mPoolList.size();
    if (size >= MAX_ALLOC_SIZE) {
        GUIEXT_LOGW("  alloc pools size is reaching %d, can't alloc", size);
        *poolId = 0;
        return NOT_ENOUGH_DATA;
    }

    if (size == 0) {
        DisplayInfo dinfo;
        sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(
                ISurfaceComposer::eDisplayIdMain);
        SurfaceComposerClient::getDisplayInfo(display, &dinfo);

        mDefaultDisplayWidth = dinfo.w;
        mDefaultDisplayHeight = dinfo.h;

        sp<DispInfo> disp = new DispInfo;
        disp->type = 0;
        disp->w = mDefaultDisplayWidth;
        disp->h = mDefaultDisplayHeight;
        disp->bufNum = MAX_HWC_DEQUEUED_NUM;
        mDisplayList.add((uint32_t)HWC_DISPLAY_PRIMARY, disp);

        GUIEXT_LOGI("pool list size=0, try to get default display(w x h) = (%d x %d)", disp->w, disp->h);
    }

    *poolId = getPoolId();
    bool isHwcNeeded = gralloc_usage & GRALLOC_USAGE_HW_COMPOSER;

    class ProducerDeathObserver : public IBinder::DeathRecipient {
        GuiExtPool & mPool;
        virtual void binderDied(const wp<IBinder>& who) {
            uint32_t size = mPool.mPoolList.size();
            GUIEXT_LOGI("producer died, pool size=%d, binder ptr=[%p]", size, who.unsafe_get());

            if (size == 0) {
                GUIEXT_LOGV("producer died [%p], pool size is zero", who.unsafe_get());
            } else {
                for (uint32_t i = size-1 ;; i--) {
                    GUIEXT_LOGV("   [p] compare index[%d], p=[%p]", i, mPool.mPoolList[i]->mProducerToken.get());
                    if (mPool.mPoolList[i]->mProducerToken.get() == who.unsafe_get()) {
                        GUIEXT_LOGW("   [p] found index[%d], p=[%p], id=%d", i, mPool.mPoolList[i]->mProducerToken.get(), mPool.mPoolList[i]->mId);
                        mPool.mPoolList[i]->mProducerToken = NULL;
                        mPool.mPoolList[i]->mProducerPid = -1;
                        mPool.removePoolItem(mPool.mPoolList[i]->mId);
                    }

                    if (i == 0)
                        break;
                }

                GUIEXT_LOGV("producer died done");
            }
        }
    public:
        ProducerDeathObserver(GuiExtPool & pool) : mPool(pool) { }
    };

    sp<IBinder::DeathRecipient> observer = new ProducerDeathObserver(*const_cast<GuiExtPool*>(this));
    token->linkToDeath(observer);

    sp<GuiExtPoolItem> item = new GuiExtPoolItem(token, isHwcNeeded, *poolId, w, h, mDisplayList, observer);
    status_t err;
    err = item->prepareBuffer(gralloc_usage);
    if (err != NO_ERROR) {
        GUIEXT_LOGE("  alloc fail, isHWcNeeded=%d, w=%d, h=%d, usage=%x, poolId=%d", isHwcNeeded, w, h, gralloc_usage, *poolId);
        *poolId = 0;
        return err;
    }

    mPoolList.add(*poolId, item);

    const nsecs_t time_end = systemTime();
    GUIEXT_LOGI("  alloc cost time=%" PRId64 " ms, gralloc_usage=%x, w=%d, h=%d, poolId=%d", ns2ms(time_end - time_start),
        gralloc_usage, w, h, *poolId);

    return err;
}
Esempio n. 6
0
GuiExtPool::GuiExtPool()
    : mPoolId(0)
    , mPoolList(NULL)
{
    GUIEXT_LOGI("GuiExtPool ctor");
}