Exemplo n.º 1
0
void GraphicsItemRenderer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
	Q_UNUSED(option);
	Q_UNUSED(widget);
    DPTR_D(GraphicsItemRenderer);
    d.painter = painter;
    {
        //lock is required only when drawing the frame
        QMutexLocker locker(&d.img_mutex);
        Q_UNUSED(locker);
        //begin paint. how about QPainter::beginNativePainting()?
        //fill background color when necessary, e.g. renderer is resized, image is null
        //if we access d.data which will be modified in AVThread, the following must be protected
        if (d.out_rect != boundingRect() || d.data.isEmpty()) {
            d.update_background = false;
            drawBackground();
        }
        //DO NOT return if no data. we should draw other things
        //NOTE: if data is not copyed in convertData, you should always call drawFrame()
        if (!d.data.isEmpty()) {
            drawFrame();
        }
    }
    //drawXXX only implement the painting, no other logic
    if (d.draw_osd)
        drawOSD();
    if (d.draw_subtitle)
        drawSubtitle();
    if (d.draw_custom)
        drawCustom();
    //end paint. how about QPainter::endNativePainting()?
    d.painter = 0; //painter may be not available outside this function
}
Exemplo n.º 2
0
//--------------------------------------------------------------------------------------------
void Scene::draw(){
    //background
    ofSetColor(bgCol, 255*alphaPrc);
    ofFill();
    ofRect(0, 0, gameWidth, gameHeight);
    
    drawBackgroundCustom();
    
    //some visual effects rely on drawing the grid
    //this will do nothing if those effects are not active
    field.drawGrid(alphaPrc);
    
    //draw the field particles
    for (int i=fieldParticles.size()-1; i>=0; i--){
        fieldParticles[i]->draw(alphaPrc);
    }
    
    //draw the towers
    for (int i=towers.size()-1; i>=0; i--){
        towers[i]->draw(alphaPrc, showCupDebug);
    }
    
    //draw anything special for this scene
    drawCustom();
}
Exemplo n.º 3
0
void Direct2DRenderer::paintEvent(QPaintEvent *)
{
    DPTR_D(Direct2DRenderer);
    QMutexLocker locker(&d.img_mutex);
    Q_UNUSED(locker);
    if (!d.render_target) {
        qWarning("No render target!!!");
        return;
    }
    HRESULT hr = S_OK;
    //begin paint
    //http://www.daimakuai.net/?page_id=1574
    d.render_target->BeginDraw();
    //The first bitmap size is 0x0, we should only draw the background
    //we access d.data which will be modified in AVThread, so must be protected
    if ((d.update_background && d.out_rect != rect())|| d.data.isEmpty()) {
        d.update_background = false;
        drawBackground();
    }
    //d.data is always empty because we did not assign a vaule in convertData?
    if (!d.data.isEmpty()) {
        //return; //why the background is white if return? the below code draw an empty bitmap?
    }
    drawFrame();
    //drawXXX only implement the painting, no other logic
    if (d.draw_osd)
        drawOSD();
    if (d.draw_subtitle)
        drawSubtitle();
    if (d.draw_custom)
        drawCustom();
    hr = d.render_target->EndDraw(NULL, NULL);
    if (hr == D2DERR_RECREATE_TARGET) {
        qDebug("D2DERR_RECREATE_TARGET");
        hr = S_OK;
        d.destroyDeviceResource();
        d.createDeviceResource(); //?
    }
    //end paint
}
void GameObject::draw(){
    drawCustom();
}