void TiledBackingStore::updateTileBuffers() { if (m_contentsFrozen) return; m_client->tiledBackingStorePaintBegin(); Vector<IntRect> paintedArea; Vector<RefPtr<Tile> > dirtyTiles; TileMap::iterator end = m_tiles.end(); for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { if (!it->second->isDirty()) continue; dirtyTiles.append(it->second); // FIXME: should not request system repaint for the full tile. paintedArea.append(mapToContents(it->second->rect())); } if (dirtyTiles.isEmpty()) { m_client->tiledBackingStorePaintEnd(paintedArea); return; } // FIXME: In single threaded case, tile back buffers could be updated asynchronously // one by one and then swapped to front in one go. This would minimize the time spent // blocking on tile updates. unsigned size = dirtyTiles.size(); for (unsigned n = 0; n < size; ++n) dirtyTiles[n]->updateBackBuffer(); for (unsigned n = 0; n < size; ++n) dirtyTiles[n]->swapBackBufferToFront(); m_client->tiledBackingStorePaintEnd(paintedArea); }
void TiledDrawingAreaProxy::tileBufferUpdateComplete() { // Bail out if all tile back buffers have not been updated. Vector<TiledDrawingAreaTile*> tilesToFlip; TileMap::iterator end = m_tiles.end(); for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { RefPtr<TiledDrawingAreaTile>& current = it->second; if (current->isReadyToPaint() && (current->isDirty() || current->hasBackBufferUpdatePending())) return; if (current->hasReadyBackBuffer()) tilesToFlip.append(current.get()); } // Everything done, move back buffers to front. Vector<IntRect> paintedArea; unsigned size = tilesToFlip.size(); for (unsigned n = 0; n < size; ++n) { TiledDrawingAreaTile* tile = tilesToFlip[n]; tile->swapBackBufferToFront(); // FIXME: should not request system repaint for the full tile. paintedArea.append(mapToContents(tile->rect())); } if (size) updateWebView(paintedArea); m_tileCreationTimer.startOneShot(0); }
void UVWidget::paintGL() { glPushAttrib( GL_ALL_ATTRIB_BITS ); glMatrixMode( GL_PROJECTION ); glPushMatrix(); glLoadIdentity(); setupViewport( width(), height() ); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); qglClearColor( Options::bgColor() ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glDisable( GL_DEPTH_TEST ); glDepthMask( GL_FALSE ); // draw texture glPushMatrix(); glLoadIdentity(); glEnable( GL_TEXTURE_2D ); if ( aTextureBlend->isChecked() ) glEnable( GL_BLEND ); else glDisable( GL_BLEND ); if( !texfile.isEmpty() ) bindTexture( texfile ); else bindTexture( texsource ); glTranslatef( -0.5f, -0.5f, 0.0f ); glTranslatef( -1.0f, -1.0f, 0.0f ); for( int i = 0; i < 3; i++ ) { for( int j = 0; j < 3; j++ ) { if( i == 1 && j == 1 ) { glColor4f( 0.75f, 0.75f, 0.75f, 1.0f ); } else { glColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); } glDrawArrays( GL_QUADS, 0, 4 ); glTranslatef( 1.0f, 0.0f, 0.0f ); } glTranslatef( -3.0f, 1.0f, 0.0f ); } glTranslatef( 1.0f, -2.0f, 0.0f ); glDisable( GL_TEXTURE_2D ); glPopMatrix(); // draw grid glPushMatrix(); glLoadIdentity(); glEnable( GL_BLEND ); glLineWidth( 0.8f ); glBegin( GL_LINES ); int glGridMinX = qRound( qMin( glViewRect[0], glViewRect[1] ) / glGridD ); int glGridMaxX = qRound( qMax( glViewRect[0], glViewRect[1] ) / glGridD ); int glGridMinY = qRound( qMin( glViewRect[2], glViewRect[3] ) / glGridD ); int glGridMaxY = qRound( qMax( glViewRect[2], glViewRect[3] ) / glGridD ); for( int i = glGridMinX; i < glGridMaxX; i++ ) { GLdouble glGridPos = glGridD * i; if( ( i % ( GRIDSEGS * GRIDSEGS ) ) == 0 ) { glLineWidth( 1.4f ); glColor4f( 1.0f, 1.0f, 1.0f, 0.4f ); } else if( zoom > ( GRIDSEGS * GRIDSEGS / 2.0 ) ) { continue; } else if( ( i % GRIDSEGS ) == 0 ) { glLineWidth( 1.2f ); glColor4f( 1.0f, 1.0f, 1.0f, 0.2f ); } else if( zoom > ( GRIDSEGS / 2.0 ) ) { continue; } else { glLineWidth( 0.8f ); glColor4f( 1.0f, 1.0f, 1.0f, 0.1f ); } glVertex2d( glGridPos, glViewRect[2] ); glVertex2d( glGridPos, glViewRect[3] ); } for( int i = glGridMinY; i < glGridMaxY; i++ ) { GLdouble glGridPos = glGridD * i; if( ( i % ( GRIDSEGS * GRIDSEGS ) ) == 0 ) { glLineWidth( 1.4f ); glColor4f( 1.0f, 1.0f, 1.0f, 0.4f ); } else if( zoom > ( GRIDSEGS * GRIDSEGS / 2.0 ) ) { continue; } else if( ( i % GRIDSEGS ) == 0 ) { glLineWidth( 1.2f ); glColor4f( 1.0f, 1.0f, 1.0f, 0.2f ); } else if( zoom > ( GRIDSEGS / 2.0 ) ) { continue; } else { glLineWidth( 0.8f ); glColor4f( 1.0f, 1.0f, 1.0f, 0.1f ); } glVertex2d( glViewRect[0], glGridPos ); glVertex2d( glViewRect[1], glGridPos ); } glEnd(); glPopMatrix(); drawTexCoords(); glDisable( GL_DEPTH_TEST ); glDepthMask( GL_FALSE ); if( ! selectRect.isNull() ) { glLoadIdentity(); glHighlightColor(); glBegin( GL_LINE_LOOP ); glVertex( mapToContents( selectRect.topLeft() ) ); glVertex( mapToContents( selectRect.topRight() ) ); glVertex( mapToContents( selectRect.bottomRight() ) ); glVertex( mapToContents( selectRect.bottomLeft() ) ); glEnd(); } if ( ! selectPoly.isEmpty() ) { glLoadIdentity(); glHighlightColor(); glBegin( GL_LINE_LOOP ); foreach ( QPoint p, selectPoly ) { glVertex( mapToContents( p ) ); }