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

Unified Diff: samplecode/SamplePatch.cpp

Issue 1693013002: Check bounds before casting float to integer in SamplePatch.cpp and SkBlurMaskFilter::CreateEmboss. (Closed) Base URL: https://skia.googlesource.com/skia@unit-scalar-clamp-to-byte
Patch Set: Created 4 years, 10 months 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/effects/SkEmbossMaskFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SamplePatch.cpp
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index 92bb17cd062870dead3d818490e6d8855534ab91..5347b0182a706f52895c8c760a68b0d1c254e2f3 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -109,20 +109,8 @@ static void eval_sheet(const SkPoint edge[], int nu, int nv, int iu, int iv,
pt->set(x, y);
}
-static int ScalarTo255(SkScalar v) {
- int scale = SkScalarToFixed(v) >> 8;
- if (scale < 0) {
- scale = 0;
- } else if (scale > 255) {
- scale = 255;
- }
- return scale;
-}
-
static SkColor make_color(SkScalar s, SkScalar t) {
- int cs = ScalarTo255(s);
- int ct = ScalarTo255(t);
- return SkColorSetARGB(0xFF, cs, 0, 0) + SkColorSetARGB(0, 0, ct, 0);
+ return SkColorSetARGB(0xFF, SkUnitScalarClampToByte(s), SkUnitScalarClampToByte(t), 0);
}
void Patch::draw(SkCanvas* canvas, const SkPaint& paint, int nu, int nv,
« no previous file with comments | « no previous file | src/effects/SkEmbossMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698