Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: gm/mixedxfermodes.cpp

Issue 666043003: Preventing division by 0 in non-separable blend mode shaders. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: moving the test to an existing test file Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkXfermode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/mixedxfermodes.cpp
diff --git a/gm/mixedxfermodes.cpp b/gm/mixedxfermodes.cpp
index a5023e1b0b07218ad6b2acc171568ecae7d35de4..a22ead13aa27b3f9484979a0e212bd04fecfc7d6 100644
--- a/gm/mixedxfermodes.cpp
+++ b/gm/mixedxfermodes.cpp
@@ -22,6 +22,15 @@ public:
}
protected:
+ enum ShapeType {
+ kShapeTypeCircle,
+ kShapeTypeRoundRect,
+ kShapeTypeRect,
+ kShapeTypeConvexPath,
+ kShapeTypeConcavePath,
+ kNumShapeTypes
+ };
+
virtual SkString onShortName() SK_OVERRIDE {
return SkString("mixed_xfermodes");
}
@@ -32,21 +41,20 @@ protected:
void drawShape(SkCanvas* canvas,
const SkPaint& paint,
- SkRandom* random) {
+ ShapeType type) {
static const SkRect kRect = SkRect::MakeXYWH(SkIntToScalar(-50), SkIntToScalar(-50),
SkIntToScalar(75), SkIntToScalar(105));
- int shape = random->nextULessThan(5);
- switch (shape) {
- case 0:
+ switch (type) {
egdaniel 2014/11/14 16:08:21 You need to have a default case or else there will
rosca 2014/11/17 16:09:31 Done.
+ case kShapeTypeCircle:
canvas->drawCircle(0, 0, 50, paint);
break;
- case 1:
+ case kShapeTypeRoundRect:
canvas->drawRoundRect(kRect, SkIntToScalar(10), SkIntToScalar(20), paint);
break;
- case 2:
+ case kShapeTypeRect:
canvas->drawRect(kRect, paint);
break;
- case 3:
+ case kShapeTypeConvexPath:
if (fConvexPath.isEmpty()) {
SkPoint points[4];
kRect.toQuad(points);
@@ -57,7 +65,7 @@ protected:
}
canvas->drawPath(fConvexPath, paint);
break;
- case 4:
+ case kShapeTypeConcavePath:
if (fConcavePath.isEmpty()) {
SkPoint points[5] = {{0, SkIntToScalar(-50)} };
SkMatrix rot;
@@ -108,6 +116,13 @@ protected:
SkColor color = random.nextU();
SkXfermode::Mode mode =
static_cast<SkXfermode::Mode>(random.nextULessThan(SkXfermode::kLastMode + 1));
+ ShapeType shapeType = static_cast<ShapeType>(random.nextULessThan(kNumShapeTypes));
+
+ if (i == kNumShapes - 1) {
egdaniel 2014/11/14 16:08:21 Since what you want to test ends up drawing nothin
rosca 2014/11/17 16:09:31 Done.
+ color = SkColorSetARGBMacro(225, 100, 100, 100);
+ mode = SkXfermode::kSaturation_Mode;
+ shapeType = kShapeTypeConvexPath;
+ }
SkPaint p;
p.setAntiAlias(true);
@@ -117,7 +132,7 @@ protected:
canvas->translate(dx, dy);
canvas->scale(s, s);
canvas->rotate(r);
- this->drawShape(canvas, p, &random);
+ this->drawShape(canvas, p, shapeType);
canvas->restore();
}
}
« no previous file with comments | « no previous file | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698