Fix build warnings in SkAlphaThresholdFilter
BUG=None
R=bsalomon@google.com
Author: zork@chromium.org
Review URL: https://codereview.chromium.org/101763010
git-svn-id: http://skia.googlecode.com/svn/trunk@12937 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/imagealphathreshold.cpp b/gm/imagealphathreshold.cpp
index 2839744..7597090 100644
--- a/gm/imagealphathreshold.cpp
+++ b/gm/imagealphathreshold.cpp
@@ -43,7 +43,7 @@
SkMatrix matrix;
matrix.reset();
matrix.setTranslate(WIDTH * .1f, HEIGHT * .1f);
- matrix.postScale(.8, .8);
+ matrix.postScale(.8f, .8f);
canvas->concat(matrix);
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index a53731f..f15a13d 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -308,18 +308,18 @@
SkASSERT(src.config() == SkBitmap::kARGB_8888_Config);
if (src.config() != SkBitmap::kARGB_8888_Config) {
- return false;
+ return false;
}
SkMatrix localInverse;
if (!matrix.invert(&localInverse)) {
- return NULL;
+ return false;
}
SkAutoLockPixels alp(src);
SkASSERT(src.getPixels());
if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) {
- return false;
+ return false;
}
dst->setConfig(src.config(), src.width(), src.height());
@@ -328,8 +328,8 @@
return false;
}
- U8CPU innerThreshold = fInnerThreshold * 0xFF;
- U8CPU outerThreshold = fOuterThreshold * 0xFF;
+ U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF);
+ U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF);
SkColor* sptr = src.getAddr32(0, 0);
SkColor* dptr = dst->getAddr32(0, 0);
int width = src.width(), height = src.height();
@@ -338,25 +338,25 @@
const SkColor& source = sptr[y * width + x];
SkColor output_color(source);
SkPoint position;
- localInverse.mapXY(x, y, &position);
- if (fRegion.contains(position.x(), position.y())) {
+ localInverse.mapXY((SkScalar)x, (SkScalar)y, &position);
+ if (fRegion.contains((int32_t)position.x(), (int32_t)position.y())) {
if (SkColorGetA(source) < innerThreshold) {
U8CPU alpha = SkColorGetA(source);
if (alpha == 0)
alpha = 1;
float scale = (float)innerThreshold / alpha;
output_color = SkColorSetARGB(innerThreshold,
- SkColorGetR(source) * scale,
- SkColorGetG(source) * scale,
- SkColorGetB(source) * scale);
+ (U8CPU)(SkColorGetR(source) * scale),
+ (U8CPU)(SkColorGetG(source) * scale),
+ (U8CPU)(SkColorGetB(source) * scale));
}
} else {
if (SkColorGetA(source) > outerThreshold) {
float scale = (float)outerThreshold / SkColorGetA(source);
output_color = SkColorSetARGB(outerThreshold,
- SkColorGetR(source) * scale,
- SkColorGetG(source) * scale,
- SkColorGetB(source) * scale);
+ (U8CPU)(SkColorGetR(source) * scale),
+ (U8CPU)(SkColorGetG(source) * scale),
+ (U8CPU)(SkColorGetB(source) * scale));
}
}
dptr[y * dst->width() + x] = output_color;
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index a1dbea8..7e55cc7 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -260,7 +260,7 @@
void forceLinking() {
SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0);
- SkAlphaThresholdFilter::Create(SkRegion(), .5, .5);
+ SkAlphaThresholdFilter::Create(SkRegion(), .5f, .5f);
SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1);
GrConfigConversionEffect::Create(NULL,
false,