static void findDisplayFormats(FormatVector &dFormats, unsigned minColorChannelBits) {
    for(unsigned i=0; i < LEN(displayFormats); ++i) {
        if(FormatColorBits(displayFormats[i]) >= minColorChannelBits) {
            dFormats.push_back(displayFormats[i]);
        }
    }
}
static void findBackBufferFormats(FormatVector &bbFormats, unsigned minColorChannelBits, unsigned minAlphaBits) {
    for(unsigned i=0; i < LEN(backBufferFormats); ++i) {
        if(FormatColorBits(backBufferFormats[i]) >= minColorChannelBits) {
            if(FormatAlphaBits(backBufferFormats[i]) >= minAlphaBits) {
                bbFormats.push_back(backBufferFormats[i]);
            }
        }
    }
}
static void findDepthStencilFormats(FormatVector &dsFormats, unsigned minDepthBits, unsigned minStencilBits) {
    for(unsigned i=0; i < LEN(depthStencilFormats); ++i) {
        if(FormatDepthBits(depthStencilFormats[i]) >= minDepthBits) {
            if(FormatStencilBits(depthStencilFormats[i]) >= minStencilBits) {
                dsFormats.push_back(depthStencilFormats[i]);
            }
        }
    }

}
gint QTMSFactoryImpl::GetSupportedFormats(const QTMSStreamType strmtype, FormatVector& fmtlist)
{
    TRACE_PRN_FN_ENT;
    gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
    TMS::FormatVector tmsfmtlist;
    if (iFactory) {
        ret = iFactory->GetSupportedFormats((TMSStreamType) strmtype, tmsfmtlist);
    }

    std::vector<TMSFormat*>::iterator itCodecs = tmsfmtlist.begin();
    TMSFormatType fmttype;
    for (; itCodecs < tmsfmtlist.end(); itCodecs++) {
        (*itCodecs)->GetType(fmttype);
        QTMSFormat* qtmsfmt(NULL);
        switch (fmttype) {
        case QTMS_FORMAT_PCM:
            ret = QTMSPCMFormatImpl::Create(qtmsfmt, *itCodecs);
            break;
        case QTMS_FORMAT_AMR:
            ret = QTMSAMRFormatImpl::Create(qtmsfmt, *itCodecs);
            break;
        case QTMS_FORMAT_G711:
            ret = QTMSG711FormatImpl::Create(qtmsfmt, *itCodecs);
            break;
        case QTMS_FORMAT_G729:
            ret = QTMSG729FormatImpl::Create(qtmsfmt, *itCodecs);
            break;
        case QTMS_FORMAT_ILBC:
            ret = QTMSILBCFormatImpl::Create(qtmsfmt, *itCodecs);
            break;
        default:
            break;
        }

        if (qtmsfmt) {
            fmtlist.push_back(qtmsfmt);
        }
    }
    TRACE_PRN_FN_EXT;
    return ret;
}
示例#5
0
void MythUIText::DrawSelf(MythPainter *p, int xoffset, int yoffset,
                          int alphaMod, QRect clipRect)
{
    if (m_Canvas.isNull())
        return;

    FormatVector formats;
    QRect drawrect = m_drawRect.toQRect();
    drawrect.translate(xoffset, yoffset);
    QRect canvas = m_Canvas.toQRect();

    int alpha = CalcAlpha(alphaMod);

    if (m_Ascent)
    {
        drawrect.setY(drawrect.y() - m_Ascent);
        canvas.moveTop(canvas.y() + m_Ascent);
        canvas.setHeight(canvas.height() + m_Ascent);
    }
    if (m_Descent)
    {
        drawrect.setHeight(drawrect.height() + m_Descent);
        canvas.setHeight(canvas.height() + m_Descent);
    }

    if (m_leftBearing)
    {
        drawrect.setX(drawrect.x() + m_leftBearing);
        canvas.moveLeft(canvas.x() - m_leftBearing);
        canvas.setWidth(canvas.width() - m_leftBearing);
    }
    if (m_rightBearing)
    {
        drawrect.setWidth(drawrect.width() - m_rightBearing);
        canvas.setWidth(canvas.width() - m_rightBearing);
    }

    if (GetFontProperties()->hasOutline())
    {
        QTextLayout::FormatRange range;

        QColor outlineColor;
        int outlineSize, outlineAlpha;

        GetFontProperties()->GetOutline(outlineColor, outlineSize,
                                        outlineAlpha);
        outlineColor.setAlpha(outlineAlpha);

        MythPoint  outline(outlineSize, outlineSize);
        outline.NormPoint(); // scale it to screen resolution

        QPen pen;
        pen.setBrush(outlineColor);
        pen.setWidth(outline.x());

        range.start = 0;
        range.length = m_CutMessage.size();
        range.format.setTextOutline(pen);
        formats.push_back(range);

        drawrect.setX(drawrect.x() - outline.x());
        drawrect.setWidth(drawrect.width() + outline.x());
        drawrect.setY(drawrect.y() - outline.y());
        drawrect.setHeight(drawrect.height() + outline.y());

        /* Canvas pos is where the view port (drawrect) pulls from, so
         * it needs moved to the right for the left edge to be picked up*/
        canvas.moveLeft(canvas.x() + outline.x());
        canvas.setWidth(canvas.width() + outline.x());
        canvas.moveTop(canvas.y() + outline.y());
        canvas.setHeight(canvas.height() + outline.y());
    }

    if (GetFontProperties()->hasShadow())
    {
        QPoint shadowOffset;
        QColor shadowColor;
        int    shadowAlpha;

        GetFontProperties()->GetShadow(shadowOffset, shadowColor, shadowAlpha);

        MythPoint  shadow(shadowOffset);
        shadow.NormPoint(); // scale it to screen resolution

        drawrect.setWidth(drawrect.width() + shadow.x());
        drawrect.setHeight(drawrect.height() + shadow.y());

        canvas.setWidth(canvas.width() + shadow.x());
        canvas.setHeight(canvas.height() + shadow.y());
    }

    p->DrawTextLayout(canvas, m_Layouts, formats,
                      *GetFontProperties(), alpha, drawrect);
}
bool d3ddfw::findAdapterMode(IDirect3D9* d3d, 
		d3ddfw::DisplayFormat& format, bool fullscreen, 
		unsigned minFullscreenWidth, unsigned minFullscreenHeight,
		unsigned minColorChannelBits, unsigned minAlphaBits,
		unsigned minDepthBits, unsigned minStencilBits)
{
    FormatVector allowedDisplayFormats;
    FormatVector allowedBackBufferFormats;
    FormatVector allowedDepthStencilFormats;

    findDisplayFormats(allowedDisplayFormats, minColorChannelBits);
    findBackBufferFormats(allowedBackBufferFormats, minColorChannelBits, minAlphaBits);
    findDepthStencilFormats(allowedDepthStencilFormats, minDepthBits, minStencilBits);

    std::sort(allowedDisplayFormats.begin(), allowedDisplayFormats.end(),
            CompareDisplayFormats());

    std::sort(allowedBackBufferFormats.begin(), allowedBackBufferFormats.end(),
            CompareBBFormats(minAlphaBits > 0));

    std::sort(allowedDepthStencilFormats.begin(), allowedDepthStencilFormats.end(),
            CompareDSFormats(minStencilBits > 0));


    if(!fullscreen) {
        // Don't worry about mode enumeration


        FormatVector::const_iterator dIter;
        FormatVector::const_iterator bbIter;
        FormatVector::const_iterator dsIter;

        for(dIter = allowedDisplayFormats.begin(); dIter != allowedDisplayFormats.end(); ++dIter) {
            for(bbIter = allowedBackBufferFormats.begin(); bbIter != allowedBackBufferFormats.end(); ++bbIter) {
                if(SUCCEEDED(d3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, *dIter, *bbIter, fullscreen))) {
                    for(dsIter = allowedDepthStencilFormats.begin(); dsIter != allowedDepthStencilFormats.end(); ++dsIter) {
                        if(SUCCEEDED(d3d->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, *dIter, *bbIter, *dsIter))) {

                            format.adapterOrdinal = D3DADAPTER_DEFAULT;
                            format.displayFormat = *dIter;
                            format.backBufferFormat = *bbIter;
                            format.depthStencilFormat = *dsIter;
                            format.fullscreen = false;
                            return true;
                        }
                    }
                }
            }
        }

        return false;
    }

    // Cheat a bit.  Just assume they want the resolution the same as they're running now
    d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &format.mode);

    FormatVector::const_iterator dIter;
    FormatVector::const_iterator bbIter;
    FormatVector::const_iterator dsIter;

    for(dIter = allowedDisplayFormats.begin(); dIter != allowedDisplayFormats.end(); ++dIter) {
        for(bbIter = allowedBackBufferFormats.begin(); bbIter != allowedBackBufferFormats.end(); ++bbIter) {
            if(SUCCEEDED(d3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, *dIter, *bbIter, fullscreen))) {
                for(dsIter = allowedDepthStencilFormats.begin(); dsIter != allowedDepthStencilFormats.end(); ++dsIter) {
                    if(SUCCEEDED(d3d->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, *dIter, *bbIter, *dsIter))) {

                        format.adapterOrdinal = D3DADAPTER_DEFAULT;
                        format.displayFormat = *dIter;
                        format.backBufferFormat = *bbIter;
                        format.depthStencilFormat = *dsIter;
                        format.fullscreen = fullscreen;
                        return true;
                    }
                }
            }
        }
    }

    return false;
}