Skip to content

Commit

Permalink
Tweak logic regarding page item margins following forced re-render
Browse files Browse the repository at this point in the history
of layout items when exporting (i.e. disabling of cached item render)

The old issue of semi-transparent pixels around the edge of the page
had reared again. This is caused by the antialiasing while rendering
the page symbol. In order to avoid this, we cater to the most common
use case of having pages with a solid, borderless fill and slightly
extend the fill symbol polygon outside the page by 2 pixels
(determined by trial-and-error). The less common use case of having
a page symbol containing a border suffers by this border being
clipped by a couple of pixels, but we must address the much more
common use case over this.
  • Loading branch information
nyalldawson committed Dec 17, 2017
1 parent d3aee95 commit 2b0ed50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/layout/qgslayoutitempage.cpp
Expand Up @@ -216,10 +216,11 @@ void QgsLayoutItemPage::draw( QgsRenderContext &context, const QStyleOptionGraph
//Now subtract 1 pixel to prevent semi-transparent borders at edge of solid page caused by
//anti-aliased painting. This may cause a pixel to be cropped from certain edge lines/symbols,
//but that can be counteracted by adding a dummy transparent line symbol layer with a wider line width
maxBleedPixels--;
maxBleedPixels = std::floor( maxBleedPixels - 2 );

// round up
QPolygonF pagePolygon = QPolygonF( QRectF( maxBleedPixels, maxBleedPixels,
( rect().width() * scale - 2 * maxBleedPixels ), ( rect().height() * scale - 2 * maxBleedPixels ) ) );
std::ceil( rect().width() * scale ) - 2 * maxBleedPixels, std::ceil( rect().height() * scale ) - 2 * maxBleedPixels ) );
QList<QPolygonF> rings; //empty list

symbol->renderPolygon( pagePolygon, &rings, nullptr, context );
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b0ed50

Please sign in to comment.