void TilePainter::drawStamp(const Tilelayer *stamp, const QRegion &drawRegion) { Q_ASSERT(stamp); if (stamp->bounds().isEmpty()) return; const QRegion region = paintableRegion(drawRegion); if (region.isEmpty()) return; const int w = stamp->width(); const int h = stamp->height(); const QRect regionBounds = region.boundingRect(); foreach (const QRect &rect, region.rects()) { for (int _x = rect.left(); _x <= rect.right(); ++_x) { for (int _y = rect.top(); _y <= rect.bottom(); ++_y) { const int stampX = (_x - regionBounds.left()) % w; const int stampY = (_y - regionBounds.top()) % h; const Cell &cell = stamp->cellAt(stampX, stampY); if (cell.isEmpty()) continue; mTilelayer->setCell(_x - mTilelayer->x(), _y - mTilelayer->y(), cell); } } } mMapEditor->emitRegionChanged(region); }
void TilePainter::erase(const QRegion ®ion) { const QRegion paintable = paintableRegion(region); if (paintable.isEmpty()) return; mTilelayer->erase(paintable.translated(-mTilelayer->position())); mMapEditor->emitRegionChanged(paintable); }
void QWidget::setCursor( const QCursor &cursor ) { createExtra(); delete extra->curs; extra->curs = new QCursor(cursor); setWState( WState_OwnCursor ); if ( isVisible() ) updateCursor( paintableRegion() ); }
void QWidget::unsetCursor() { if ( extra ) { delete extra->curs; extra->curs = 0; } clearWState( WState_OwnCursor ); if ( isVisible() ) updateCursor( paintableRegion() ); }
void TilePainter::setCells(int x, int y, Tilelayer *tilelayer, const QRegion &mask) { QRegion region = paintableRegion(x, y, tilelayer->width(), tilelayer->height()); if (!mask.isEmpty()) region &= mask; if (region.isEmpty()) return; mTilelayer->setCells(x - mTilelayer->x(), y - mTilelayer->y(), tilelayer, region.translated(-mTilelayer->position())); mMapEditor->emitRegionChanged(region); }
void LinkHighlightImpl::paintContents(WebDisplayItemList* webDisplayItemList, WebContentLayerClient::PaintingControlSetting paintingControl) { if (!m_node || !m_node->layoutObject()) return; SkPictureRecorder recorder; gfx::Rect visualRect = paintableRegion(); SkCanvas* canvas = recorder.beginRecording(visualRect.width(), visualRect.height()); SkPaint paint; paint.setStyle(SkPaint::kFill_Style); paint.setFlags(SkPaint::kAntiAlias_Flag); paint.setColor(m_node->layoutObject()->style()->tapHighlightColor().rgb()); canvas->drawPath(m_path.getSkPath(), paint); webDisplayItemList->appendDrawingItem(WebRect(visualRect.x(), visualRect.y(), visualRect.width(), visualRect.height()), recorder.finishRecordingAsPicture()); }
void TilePainter::drawCells(int x, int y, Tilelayer *tilelayer) { const QRegion region = paintableRegion(x, y, tilelayer->width(), tilelayer->height()); if (region.isEmpty()) return; foreach (const QRect &rect, region.rects()) { for (int _x = rect.left(); _x <= rect.right(); ++_x) { for (int _y = rect.top(); _y <= rect.bottom(); ++_y) { const Cell &cell = tilelayer->cellAt(_x - x, _y - y); if (cell.isEmpty()) continue; mTilelayer->setCell(_x - mTilelayer->x(), _y - mTilelayer->y(), cell); } } } mMapEditor->emitRegionChanged(region); }
void QWidget::updateGraphicsContext( QGfx *qgfx_qws, bool clip_children ) const { QPoint offset=mapToGlobal(QPoint(0,0)); QRegion r; // empty if not visible if ( isVisible() && topLevelWidget()->isVisible() ) { int rgnIdx = topLevelWidget()->alloc_region_index; if ( rgnIdx >= 0 ) { r = clip_children ? paintableRegion() : allocatedRegion(); QRegion req; bool changed = FALSE; QWSDisplay::grab(); const int *rgnRev = qwsDisplay()->regionManager()->revision( rgnIdx ); if ( topLevelWidget()->alloc_region_revision != *rgnRev ) { // The TL region has changed, so we better make sure we're // not writing to any regions we don't own anymore. // We'll get a RegionModified event soon that will get our // regions back in sync again. req = qwsDisplay()->regionManager()->region( rgnIdx ); changed = TRUE; } qgfx_qws->setGlobalRegionIndex( rgnIdx ); QWSDisplay::ungrab(); if ( changed ) { r &= req; } } } qgfx_qws->setWidgetDeviceRegion(r); qgfx_qws->setOffset(offset.x(),offset.y()); // Clip the window decoration for TL windows. // It is possible for these windows to draw on the wm decoration if // they change the clip region. Bug or feature? #ifndef QT_NO_QWS_MANAGER if ( extra && extra->topextra && extra->topextra->qwsManager ) qgfx_qws->setClipRegion(rect()); #endif }
void ContentLayerDelegate::paintContents( WebDisplayItemList* webDisplayItemList, WebContentLayerClient::PaintingControlSetting paintingControl) { TRACE_EVENT0("blink,benchmark", "ContentLayerDelegate::paintContents"); PaintController& paintController = m_graphicsLayer->paintController(); paintController.setDisplayItemConstructionIsDisabled( paintingControl == WebContentLayerClient::DisplayListConstructionDisabled); paintController.setSubsequenceCachingIsDisabled( paintingControl == WebContentLayerClient::SubsequenceCachingDisabled); // We also disable caching when Painting or Construction are disabled. In both cases we would like // to compare assuming the full cost of recording, not the cost of re-using cached content. if (paintingControl != WebContentLayerClient::PaintDefaultBehavior && paintingControl != WebContentLayerClient::SubsequenceCachingDisabled) paintController.invalidateAll(); GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled; if (paintingControl == WebContentLayerClient::DisplayListPaintingDisabled || paintingControl == WebContentLayerClient::DisplayListConstructionDisabled) disabledMode = GraphicsContext::FullyDisabled; if (paintingControl != PaintDefaultBehavior) m_graphicsLayer->paint(nullptr, disabledMode); paintArtifactToWebDisplayItemList(webDisplayItemList, paintController.paintArtifact(), paintableRegion()); paintController.setDisplayItemConstructionIsDisabled(false); paintController.setSubsequenceCachingIsDisabled(false); }
void QWidget::scroll( int dx, int dy, const QRect& r ) { if ( testWState( WState_BlockUpdates ) && !children() ) return; bool valid_rect = r.isValid(); QRect sr = valid_rect?r:rect(); int x1, y1, x2, y2, w=sr.width(), h=sr.height(); if ( dx > 0 ) { x1 = sr.x(); x2 = x1+dx; w -= dx; } else { x2 = sr.x(); x1 = x2-dx; w += dx; } if ( dy > 0 ) { y1 = sr.y(); y2 = y1+dy; h -= dy; } else { y2 = sr.y(); y1 = y2-dy; h += dy; } if ( dx == 0 && dy == 0 ) return; QSize s( qt_screen->width(), qt_screen->height() ); QRegion alloc = valid_rect ? paintableRegion() : allocatedRegion(); QRegion dAlloc = alloc; QPoint td1 = qt_screen->mapToDevice( QPoint(0,0), s ); QPoint td2 = qt_screen->mapToDevice( QPoint(dx,dy), s ); dAlloc.translate( td2.x()-td1.x(), td2.y()-td1.y() ); QRegion scrollRegion( alloc & dAlloc ); if ( w > 0 && h > 0 ) { QGfx * mygfx=graphicsContext( FALSE ); mygfx->setClipDeviceRegion( scrollRegion ); mygfx->scroll(x2,y2,w,h,x1,y1); delete mygfx; } paintable_region_dirty = TRUE; QPoint gpos = mapToGlobal( QPoint() ); if ( !valid_rect && children() ) { // scroll children setChildrenAllocatedDirty(); QPoint pd( dx, dy ); QObjectListIt it(*children()); register QObject *object; while ( it ) { // move all children object = it.current(); if ( object->isWidgetType() ) { QWidget *w = (QWidget *)object; QPoint oldp = w->pos(); QRect r( w->pos() + pd, w->size() ); w->crect = r; w->updateRequestedRegion( gpos + w->pos() ); QMoveEvent e( r.topLeft(), oldp ); QApplication::sendEvent( w, &e ); } ++it; } } QSize ds( qt_screen->deviceWidth(), qt_screen->deviceHeight() ); scrollRegion = qt_screen->mapFromDevice( scrollRegion, ds ); scrollRegion.translate( -gpos.x(), -gpos.y() ); QRegion update( sr ); update -= scrollRegion; if ( dx ) { int x = x2 == sr.x() ? sr.x()+w : sr.x(); update |= QRect( x, sr.y(), QABS(dx), sr.height() ); } if ( dy ) { int y = y2 == sr.y() ? sr.y()+h : sr.y(); update |= QRect( sr.x(), y, sr.width(), QABS(dy) ); } repaint( update, !testWFlags(WRepaintNoErase) ); if ( !valid_rect && children() ) paint_children( this, update, FALSE ); }