common: RenderRegion x, y protect against negative value in unsigned int

This change protects against negative value in unsigned int of
RenderRegion.x/y. This fixes a problem of invisible paint if ClipPath
bounds was negative.

@issue: #704
This commit is contained in:
Michal Maciola 2021-08-10 17:22:37 +02:00 committed by Hermet Park
parent abebdbe545
commit e6ebb5379b
3 changed files with 5 additions and 2 deletions

View file

@ -77,6 +77,9 @@ static bool _clipPathFastTrack(Paint* cmpTarget, const RenderTransform* pTransfo
y2 = y2 * pTransform->m.e22 + pTransform->m.e23; y2 = y2 * pTransform->m.e22 + pTransform->m.e23;
} }
if (x1 < 0.0f) x1 = 0.0f;
if (y1 < 0.0f) y1 = 0.0f;
viewport.x = static_cast<uint32_t>(x1); viewport.x = static_cast<uint32_t>(x1);
viewport.y = static_cast<uint32_t>(y1); viewport.y = static_cast<uint32_t>(y1);
viewport.w = static_cast<uint32_t>(roundf(x2 - x1 + 0.5f)); viewport.w = static_cast<uint32_t>(roundf(x2 - x1 + 0.5f));

View file

@ -95,7 +95,7 @@ struct Picture::Impl
if (auto p = loader->paint()) { if (auto p = loader->paint()) {
paint = p.release(); paint = p.release();
loader->close(); loader->close();
if (w != loader->w && h != loader->h) { if (w != loader->w || h != loader->h) {
loader->resize(paint, w, h); loader->resize(paint, w, h);
resizing = false; resizing = false;
} }

View file

@ -523,7 +523,7 @@ unique_ptr<Scene> svgSceneBuild(SvgNode* node, float vx, float vy, float vw, flo
auto docNode = _sceneBuildHelper(node, vx, vy, vw, vh); auto docNode = _sceneBuildHelper(node, vx, vy, vw, vh);
auto viewBoxClip = Shape::gen(); auto viewBoxClip = Shape::gen();
viewBoxClip->appendRect(vx, vy ,vw, vh, 0, 0); viewBoxClip->appendRect(vx, vy, vw, vh, 0, 0);
viewBoxClip->fill(0, 0, 0, 255); viewBoxClip->fill(0, 0, 0, 255);
auto compositeLayer = Scene::gen(); auto compositeLayer = Scene::gen();