Remove undefined behavior from innershapes gm
It is undefined for the inner rrect to not be contained in the inner. Change-Id: I632060771fb7918050e1836d17b4702ea765a08f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384116 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
parent
82fe4d2243
commit
1bb1f220bd
@ -140,10 +140,29 @@ private:
|
||||
const SkRRect& outer = fShapes[i];
|
||||
const SkRRect& inner = fShapes[(i * 7 + 11) % fSimpleShapeCount];
|
||||
float s = 0.95f * std::min(outer.rect().width() / inner.rect().width(),
|
||||
outer.rect().height() / inner.rect().height());
|
||||
outer.rect().height() / inner.rect().height());
|
||||
SkMatrix innerXform;
|
||||
float dx = (rand.nextF() - 0.5f) * (outer.rect().width() - s * inner.rect().width());
|
||||
float dy = (rand.nextF() - 0.5f) * (outer.rect().height() - s * inner.rect().height());
|
||||
// Fixup inner rects so they don't reach outside the outer rect.
|
||||
switch (i) {
|
||||
case 0:
|
||||
s *= .85f;
|
||||
break;
|
||||
case 8:
|
||||
s *= .4f;
|
||||
dx = dy = 0;
|
||||
break;
|
||||
case 5:
|
||||
s *= .75f;
|
||||
dx = dy = 0;
|
||||
break;
|
||||
case 6:
|
||||
s *= .65f;
|
||||
dx = -5;
|
||||
dy = 10;
|
||||
break;
|
||||
}
|
||||
innerXform.setTranslate(outer.rect().centerX() + dx, outer.rect().centerY() + dy);
|
||||
if (s < 1) {
|
||||
innerXform.preScale(s, s);
|
||||
|
Loading…
Reference in New Issue
Block a user