//---------------------------------------------------------------------------//
// extern function
//---------------------------------------------------------------------------//
extern "C" int stretchFimgApi(struct fimg2d_blit *cmd)
{
    pthread_mutex_lock(&s_g2d_lock);

    FimgApi * fimgApi = createFimgApi();

    if (fimgApi == NULL) {
        PRINT("%s::createFimgApi() fail\n", __func__);
        pthread_mutex_unlock(&s_g2d_lock);
        return -1;
    }

    if (fimgApi->Stretch(cmd) == false) {
        if (fimgApi != NULL)
            destroyFimgApi(fimgApi);

        pthread_mutex_unlock(&s_g2d_lock);
        return -1;
    }

    if (fimgApi != NULL)
        destroyFimgApi(fimgApi);

    pthread_mutex_unlock(&s_g2d_lock);
    return 0;
}
Пример #2
0
extern "C" int SyncFimgApi(void)
{
    FimgApi * fimgApi = createFimgApi();
    if (fimgApi == NULL) {
        PRINT("%s::createFimgApi() fail\n", __func__);
        return -1;
    }

    if (fimgApi->Sync() == false) {
        if (fimgApi != NULL)
            destroyFimgApi(fimgApi);

        return -1;
    }

    if (fimgApi != NULL)
        destroyFimgApi(fimgApi);

    return 0;
}
extern "C" int SyncFimgApi(void)
{
    pthread_mutex_lock(&s_g2d_lock);
    FimgApi * fimgApi = createFimgApi();
    if (fimgApi == NULL) {
        PRINT("%s::createFimgApi() fail\n", __func__);
        pthread_mutex_unlock(&s_g2d_lock);
        return -1;
    }

    if (fimgApi->Sync() == false) {
        if (fimgApi != NULL)
            destroyFimgApi(fimgApi);

        pthread_mutex_unlock(&s_g2d_lock);
        return -1;
    }

    if (fimgApi != NULL)
        destroyFimgApi(fimgApi);

    pthread_mutex_unlock(&s_g2d_lock);
    return 0;
}
extern "C" int stretchFimgApi_fast(struct fimg2d_blit *cmd, unsigned long tmpbuf_addr, int tmpbuf_size)
{
    if (tmpbuf_addr == 0 || tmpbuf_size <= 0)
        return stretchFimgApi(cmd);

    /* scaling & rotation only */
    if (cmd->param.rotate == ORIGIN || cmd->param.scaling.mode == NO_SCALING)
        return stretchFimgApi(cmd);

    /* src & dst only */
    if (cmd->src == NULL || cmd->msk != NULL)
        return stretchFimgApi(cmd);

    /* a(x)rgb8888 src only */
    if (cmd->src->fmt >= CF_RGB_565)
        return stretchFimgApi(cmd);

    FimgApi * fimgApi = createFimgApi();

    if (fimgApi == NULL) {
        PRINT("%s::createFimgApi() fail\n", __func__);
        return -1;
    }

    bool is_scaledown, sr_w, sr_h;
    struct fimg2d_image tmpbuf;
    struct fimg2d_blit cmd1st, cmd2nd;
    struct fimg2d_param *p;

    /* check is_scaledown */
    p = &cmd->param;
    sr_w = p->scaling.src_w - p->scaling.dst_w;
    sr_h = p->scaling.src_h - p->scaling.dst_h;
    is_scaledown = (sr_w + sr_h > 0) ? true : false;

    if (is_scaledown) {
        /* set temp buffer */
        tmpbuf.width = cmd->dst->rect.y2 - cmd->dst->rect.y1;
        tmpbuf.height = cmd->dst->rect.x2 - cmd->dst->rect.x1;
        tmpbuf.stride = tmpbuf.width * 4;
        tmpbuf.order = cmd->src->order;
        tmpbuf.fmt = cmd->src->fmt;
        tmpbuf.addr.type = cmd->src->addr.type;
        tmpbuf.addr.start = tmpbuf_addr;
        tmpbuf.plane2.type = ADDR_NONE;
        tmpbuf.rect.x1 = 0;
        tmpbuf.rect.y1 = 0;
        tmpbuf.rect.x2 = tmpbuf.width;
        tmpbuf.rect.y2 = tmpbuf.height;
        tmpbuf.need_cacheopr = false;

        /* 1st step : copy with scaling down */
        p = &cmd1st.param;
        memcpy(p, &cmd->param, sizeof(cmd->param));
        p->rotate = ORIGIN;
        p->g_alpha = 0xff;
        p->dither = false;
        cmd1st.op = BLIT_OP_SRC;
        cmd1st.src = cmd->src;
        cmd1st.dst = &tmpbuf;
        cmd1st.msk = NULL;
        cmd1st.tmp = NULL;
        cmd1st.sync = BLIT_SYNC;
        cmd1st.seq_no = cmd->seq_no;

        /* 2nd step : op with rotation */
        p = &cmd2nd.param;
        memcpy(p, &cmd->param, sizeof(cmd->param));
        p->scaling.mode = NO_SCALING;
        cmd2nd.op = cmd->op;
        cmd2nd.src = &tmpbuf;
        cmd2nd.dst = cmd->dst;
        cmd2nd.msk = NULL;
        cmd2nd.tmp = NULL;
        cmd2nd.sync = BLIT_SYNC;
        cmd2nd.seq_no = cmd->seq_no;
    } else {
        /* set temp buffer */
        tmpbuf.width = cmd->src->rect.y2 - cmd->src->rect.y1;
        tmpbuf.height = cmd->src->rect.x2 - cmd->src->rect.x1;
        tmpbuf.stride = tmpbuf.width * 4;
        tmpbuf.order = cmd->src->order;
        tmpbuf.fmt = cmd->src->fmt;
        tmpbuf.addr.type = cmd->src->addr.type;
        tmpbuf.addr.start = tmpbuf_addr;
        tmpbuf.plane2.type = ADDR_NONE;
        tmpbuf.rect.x1 = 0;
        tmpbuf.rect.y1 = 0;
        tmpbuf.rect.x2 = tmpbuf.width;
        tmpbuf.rect.y2 = tmpbuf.height;
        tmpbuf.need_cacheopr = false;

        /* 1st step : copy with rotation */
        p = &cmd1st.param;
        memcpy(p, &cmd->param, sizeof(cmd->param));
        p->scaling.mode = NO_SCALING;
        p->g_alpha = 0xff;
        p->dither = false;
        cmd1st.op = BLIT_OP_SRC;
        cmd1st.src = cmd->src;
        cmd1st.dst = &tmpbuf;
        cmd1st.msk = NULL;
        cmd1st.tmp = NULL;
        cmd1st.sync = BLIT_SYNC;
        cmd1st.seq_no = cmd->seq_no;

        /* 2nd step : op with scaling up */
        p = &cmd2nd.param;
        memcpy(p, &cmd->param, sizeof(cmd->param));
        p->rotate = ORIGIN;
        cmd2nd.op = cmd->op;
        cmd2nd.src = &tmpbuf;
        cmd2nd.dst = cmd->dst;
        cmd2nd.msk = NULL;
        cmd2nd.tmp = NULL;
        cmd2nd.sync = BLIT_SYNC;
        cmd2nd.seq_no = cmd->seq_no;
    }

    /* 1st step blit */
    if (fimgApi->Stretch(&cmd1st) == false) {
        if (fimgApi != NULL)
            destroyFimgApi(fimgApi);
        return -1;
    }

    /* 2nd step blit */
    if (fimgApi->Stretch(&cmd2nd) == false) {
        if (fimgApi != NULL)
            destroyFimgApi(fimgApi);
        return -1;
    }

    if (fimgApi != NULL)
        destroyFimgApi(fimgApi);

    return 0;
}