mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 08:37:26 +00:00
Fix graph blocks rendering optimization (#1164)
This commit is contained in:
parent
8c82449423
commit
3493eae194
@ -416,8 +416,8 @@ void GraphView::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
int render_offset_x = -horizontalScrollBar()->value() * current_scale;
|
int render_offset_x = -horizontalScrollBar()->value() * current_scale;
|
||||||
int render_offset_y = -verticalScrollBar()->value() * current_scale;
|
int render_offset_y = -verticalScrollBar()->value() * current_scale;
|
||||||
int render_width = viewport()->size().width() / current_scale;
|
int render_width = viewport()->size().width();
|
||||||
int render_height = viewport()->size().height() / current_scale;
|
int render_height = viewport()->size().height();
|
||||||
|
|
||||||
// Do we have scrollbars?
|
// Do we have scrollbars?
|
||||||
bool hscrollbar = horizontalScrollBar()->pageStep() < width * current_scale;
|
bool hscrollbar = horizontalScrollBar()->pageStep() < width * current_scale;
|
||||||
@ -450,12 +450,17 @@ void GraphView::paintEvent(QPaintEvent *event)
|
|||||||
for (auto &blockIt : blocks) {
|
for (auto &blockIt : blocks) {
|
||||||
GraphBlock &block = blockIt.second;
|
GraphBlock &block = blockIt.second;
|
||||||
|
|
||||||
// Check if block is visible
|
qreal blockXRender = block.x * current_scale;
|
||||||
if ((block.x + block.width > -render_offset_x) ||
|
qreal blockYRender = block.y * current_scale;
|
||||||
(block.y + block.height > -render_offset_y) ||
|
qreal blockWidthRender = block.width * current_scale;
|
||||||
(-render_offset_x + render_width > block.x) ||
|
qreal blockHeightRender = block.height * current_scale;
|
||||||
(-render_offset_y + render_height > block.y)) {
|
|
||||||
// Only draw block if it is visible
|
// Check if block is visible by checking if block intersects with view area
|
||||||
|
if (-render_offset_x < blockXRender + blockWidthRender
|
||||||
|
&& -render_offset_x + render_width > blockXRender
|
||||||
|
&& -render_offset_y < blockYRender + blockHeightRender
|
||||||
|
&& -render_offset_y + render_height > blockYRender) {
|
||||||
|
// If it intersects then draw it
|
||||||
drawBlock(p, block);
|
drawBlock(p, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,7 +474,7 @@ void GraphView::paintEvent(QPaintEvent *event)
|
|||||||
QPen pen(edge.color);
|
QPen pen(edge.color);
|
||||||
// if(blockSelected)
|
// if(blockSelected)
|
||||||
// pen.setStyle(Qt::DashLine);
|
// pen.setStyle(Qt::DashLine);
|
||||||
pen.setWidth(pen.width()/ec.width_scale);
|
pen.setWidth(pen.width() / ec.width_scale);
|
||||||
p.setPen(pen);
|
p.setPen(pen);
|
||||||
p.setBrush(edge.color);
|
p.setBrush(edge.color);
|
||||||
p.drawPolyline(edge.polyline);
|
p.drawPolyline(edge.polyline);
|
||||||
|
Loading…
Reference in New Issue
Block a user