Bug 793201 - Fix compiler warnings in Azure with MSVC r=bas

This commit is contained in:
Andrew Quartey 2012-09-28 13:21:40 -04:00
parent 5b9be123ec
commit 1417d2b2c4
9 changed files with 86 additions and 63 deletions

View File

@ -47,7 +47,7 @@ BoxBlurHorizontal(unsigned char* aInput,
memcpy(aOutput, aInput, aWidth*aRows);
return;
}
uint32_t reciprocal = (uint64_t(1) << 32) / boxSize;
uint32_t reciprocal = uint32_t((uint64_t(1) << 32) / boxSize);
for (int32_t y = 0; y < aRows; y++) {
// Check whether the skip rect intersects this row. If the skip
@ -125,7 +125,7 @@ BoxBlurVertical(unsigned char* aInput,
memcpy(aOutput, aInput, aWidth*aRows);
return;
}
uint32_t reciprocal = (uint64_t(1) << 32) / boxSize;
uint32_t reciprocal = uint32_t((uint64_t(1) << 32) / boxSize);
for (int32_t x = 0; x < aWidth; x++) {
bool inSkipRectX = x >= aSkipRect.x &&
@ -349,7 +349,8 @@ AlphaBoxBlur::AlphaBoxBlur(const Rect& aRect,
mHasDirtyRect = false;
}
mRect = IntRect(rect.x, rect.y, rect.width, rect.height);
mRect = IntRect(int32_t(rect.x), int32_t(rect.y),
int32_t(rect.width), int32_t(rect.height));
if (mRect.IsEmpty()) {
return;
}
@ -361,7 +362,8 @@ AlphaBoxBlur::AlphaBoxBlur(const Rect& aRect,
Rect skipRect = *aSkipRect;
skipRect.RoundIn();
skipRect.Deflate(Size(aBlurRadius + aSpreadRadius));
mSkipRect = IntRect(skipRect.x, skipRect.y, skipRect.width, skipRect.height);
mSkipRect = IntRect(int32_t(skipRect.x), int32_t(skipRect.y),
int32_t(skipRect.width), int32_t(skipRect.height));
mSkipRect = mSkipRect.Intersect(mRect);
if (mSkipRect.IsEqualInterior(mRect))
@ -389,7 +391,8 @@ AlphaBoxBlur::AlphaBoxBlur(uint8_t* aData,
const Rect& aRect,
int32_t aStride,
float aSigma)
: mRect(aRect.x, aRect.y, aRect.width, aRect.height),
: mRect(int32_t(aRect.x), int32_t(aRect.y),
int32_t(aRect.width), int32_t(aRect.height)),
mSpreadRadius(),
mBlurRadius(CalculateBlurRadius(Point(aSigma, aSigma))),
mData(aData),
@ -502,7 +505,7 @@ AlphaBoxBlur::Blur()
* http://www.w3.org/TR/SVG11/filters.html#feGaussianBlurElement
* https://bugzilla.mozilla.org/show_bug.cgi?id=590039#c19
*/
static const Float GAUSSIAN_SCALE_FACTOR = (3 * sqrt(2 * M_PI) / 4) * 1.5;
static const Float GAUSSIAN_SCALE_FACTOR = Float((3 * sqrt(2 * M_PI) / 4) * 1.5);
IntSize
AlphaBoxBlur::CalculateBlurRadius(const Point& aStd)

View File

@ -11,6 +11,10 @@
namespace mozilla {
namespace gfx {
#ifdef _MSC_VER
#pragma warning( disable : 4251 )
#endif
/**
* Implementation of a triple box blur approximation of a Gaussian blur.
*

View File

@ -403,9 +403,9 @@ DrawTargetCairo::DrawSurfaceWithShadow(SourceSurface *aSurface,
return;
}
Float width = aSurface->GetSize().width;
Float height = aSurface->GetSize().height;
Float width = Float(aSurface->GetSize().width);
Float height = Float(aSurface->GetSize().height);
SourceSurfaceCairo* source = static_cast<SourceSurfaceCairo*>(aSurface);
cairo_surface_t* sourcesurf = source->GetSurface();
cairo_surface_t* blursurf;

View File

@ -954,7 +954,7 @@ DrawTargetD2D::Mask(const Pattern &aSource,
1.0f, maskBrush),
layer);
Rect rect(0, 0, mSize.width, mSize.height);
Rect rect(0, 0, (Float)mSize.width, (Float)mSize.height);
Matrix mat = mTransform;
mat.Invert();
@ -1678,7 +1678,7 @@ DrawTargetD2D::GetClippedGeometry(IntRect *aClipBounds)
// Do nothing but add it to the current clip bounds.
if (!iter->mPath && iter->mIsPixelAligned) {
mCurrentClipBounds.IntersectRect(mCurrentClipBounds,
IntRect(iter->mBounds.left, iter->mBounds.top,
IntRect(int32_t(iter->mBounds.left), int32_t(iter->mBounds.top),
int32_t(iter->mBounds.right - iter->mBounds.left),
int32_t(iter->mBounds.bottom - iter->mBounds.top)));
continue;
@ -1687,7 +1687,7 @@ DrawTargetD2D::GetClippedGeometry(IntRect *aClipBounds)
if (!pathGeom) {
if (pathRectIsAxisAligned) {
mCurrentClipBounds.IntersectRect(mCurrentClipBounds,
IntRect(pathRect.left, pathRect.top,
IntRect(int32_t(pathRect.left), int32_t(pathRect.top),
int32_t(pathRect.right - pathRect.left),
int32_t(pathRect.bottom - pathRect.top)));
}
@ -2027,9 +2027,10 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont,
RefPtr<ID2D1Geometry> geom = GetClippedGeometry(clipBounds);
RefPtr<ID2D1RectangleGeometry> rectGeom;
factory()->CreateRectangleGeometry(D2D1::RectF(rectBounds.x, rectBounds.y,
rectBounds.width + rectBounds.x,
rectBounds.height + rectBounds.y),
factory()->CreateRectangleGeometry(D2D1::RectF(Float(rectBounds.x),
Float(rectBounds.y),
Float(rectBounds.width + rectBounds.x),
Float(rectBounds.height + rectBounds.y)),
byRef(rectGeom));
D2D1_GEOMETRY_RELATION relation;
@ -2432,7 +2433,7 @@ DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix
return nullptr;
}
Rect rect(0, 0, mSize.width, mSize.height);
Rect rect(0, 0, Float(mSize.width), Float(mSize.height));
// Calculate the rectangle of the source mapped to our surface.
rect = invTransform.TransformBounds(rect);
@ -2440,7 +2441,7 @@ DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix
IntSize size = aSurface->GetSize();
Rect uploadRect(0, 0, size.width, size.height);
Rect uploadRect(0, 0, Float(size.width), Float(size.height));
// Limit the uploadRect as much as possible without supporting discontiguous uploads
//
@ -2503,15 +2504,17 @@ DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix
ImageHalfScaler scaler(aSurface->GetData(), stride, size);
// Calculate the maximum width/height of the image post transform.
Point topRight = transform * Point(size.width, 0);
Point topRight = transform * Point(Float(size.width), 0);
Point topLeft = transform * Point(0, 0);
Point bottomRight = transform * Point(size.width, size.height);
Point bottomLeft = transform * Point(0, size.height);
Point bottomRight = transform * Point(Float(size.width), Float(size.height));
Point bottomLeft = transform * Point(0, Float(size.height));
IntSize scaleSize;
scaleSize.width = max(Distance(topRight, topLeft), Distance(bottomRight, bottomLeft));
scaleSize.height = max(Distance(topRight, bottomRight), Distance(topLeft, bottomLeft));
scaleSize.width = int32_t(max(Distance(topRight, topLeft),
Distance(bottomRight, bottomLeft)));
scaleSize.height = int32_t(max(Distance(topRight, bottomRight),
Distance(topLeft, bottomLeft)));
if (unsigned(scaleSize.width) > mRT->GetMaximumBitmapSize()) {
// Ok, in this case we'd really want a downscale of a part of the bitmap,
@ -2532,7 +2535,8 @@ DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix
D2D1::BitmapProperties(D2DPixelFormat(aSurface->GetFormat())),
byRef(bitmap));
aMatrix.Scale(size.width / newSize.width, size.height / newSize.height);
aMatrix.Scale(Float(size.width / newSize.width),
Float(size.height / newSize.height));
return bitmap;
}
}

View File

@ -32,7 +32,8 @@ namespace gfx {
SkColor ColorToSkColor(const Color &color, Float aAlpha)
{
//XXX: do a better job converting to int
return SkColorSetARGB(color.a*aAlpha*255.0, color.r*255.0, color.g*255.0, color.b*255.0);
return SkColorSetARGB(U8CPU(color.a*aAlpha*255.0), U8CPU(color.r*255.0),
U8CPU(color.g*255.0), U8CPU(color.b*255.0));
}
class GradientStopsSkia : public GradientStops
@ -131,7 +132,8 @@ IntRectToSkRect(const IntRect& aRect)
SkIRect
RectToSkIRect(const Rect& aRect)
{
return SkIRect::MakeXYWH(aRect.x, aRect.y, aRect.width, aRect.height);
return SkIRect::MakeXYWH(int32_t(aRect.x), int32_t(aRect.y),
int32_t(aRect.width), int32_t(aRect.height));
}
SkIRect
@ -309,12 +311,12 @@ struct AutoPaintSetup {
mPaint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
SkPaint temp;
temp.setXfermodeMode(GfxOpToSkiaOp(aOptions.mCompositionOp));
temp.setAlpha(aOptions.mAlpha*255);
temp.setAlpha(U8CPU(aOptions.mAlpha*255));
//TODO: Get a rect here
mCanvas->saveLayer(nullptr, &temp);
mNeedsRestore = true;
} else {
mPaint.setAlpha(aOptions.mAlpha*255.0);
mPaint.setAlpha(U8CPU(aOptions.mAlpha*255.0));
mAlpha = aOptions.mAlpha;
}
mPaint.setFilterBitmap(true);
@ -425,7 +427,8 @@ DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface *aSurface,
paint.setXfermodeMode(GfxOpToSkiaOp(aOperator));
SkSafeUnref(paint.setLooper(dl));
SkRect rect = RectToSkRect(Rect(aDest.x, aDest.y, bitmap.width(), bitmap.height()));
SkRect rect = RectToSkRect(Rect(Float(aDest.x), Float(aDest.y),
Float(bitmap.width()), Float(bitmap.height())));
mCanvas->drawRect(rect, paint);
mCanvas->restore();
}
@ -570,7 +573,7 @@ DrawTargetSkia::Mask(const Pattern &aSource,
// Take our destination bounds and convert them into user space to use
// as the path to draw.
SkPath path;
path.addRect(SkRect::MakeWH(mSize.width, mSize.height));
path.addRect(SkRect::MakeWH(SkScalar(mSize.width), SkScalar(mSize.height)));
Matrix temp = mTransform;
temp.Invert();

View File

@ -196,7 +196,7 @@ PathBuilderCairo::CurrentPoint() const
CairoTempMatrix tempMatrix(*mPathContext, mTransform);
double x, y;
cairo_get_current_point(*mPathContext, &x, &y);
return Point(x, y);
return Point((Float)x, (Float)y);
}
TemporaryRef<Path>
@ -271,7 +271,7 @@ PathCairo::GetBounds(const Matrix &aTransform) const
double x1, y1, x2, y2;
cairo_path_extents(*mPathContext, &x1, &y1, &x2, &y2);
Rect bounds(x1, y1, x2 - x1, y2 - y1);
Rect bounds(Float(x1), Float(y1), Float(x2 - x1), Float(y2 - y1));
return aTransform.TransformBounds(bounds);
}
@ -286,7 +286,7 @@ PathCairo::GetStrokedBounds(const StrokeOptions &aStrokeOptions,
SetCairoStrokeOptions(*mPathContext, aStrokeOptions);
cairo_stroke_extents(*mPathContext, &x1, &y1, &x2, &y2);
Rect bounds(x1, y1, x2 - x1, y2 - y1);
Rect bounds((Float)x1, (Float)y1, (Float)(x2 - x1), (Float)(y2 - y1));
return aTransform.TransformBounds(bounds);
}

View File

@ -16,67 +16,67 @@ template <typename T>
void ArcToBezier(T* aSink, const Point &aOrigin, float aRadius, float aStartAngle,
float aEndAngle, bool aAntiClockwise)
{
Point startPoint(aOrigin.x + cos(aStartAngle) * aRadius,
aOrigin.y + sin(aStartAngle) * aRadius);
aSink->LineTo(startPoint);
Point startPoint(aOrigin.x + cos(aStartAngle) * aRadius,
aOrigin.y + sin(aStartAngle) * aRadius);
// Clockwise we always sweep from the smaller to the larger angle, ccw
aSink->LineTo(startPoint);
// Clockwise we always sweep from the smaller to the larger angle, ccw
// it's vice versa.
if (!aAntiClockwise && (aEndAngle < aStartAngle)) {
Float correction = ceil((aStartAngle - aEndAngle) / (2.0f * M_PI));
aEndAngle += correction * 2.0f * M_PI;
Float correction = Float(ceil((aStartAngle - aEndAngle) / (2.0f * M_PI)));
aEndAngle += float(correction * 2.0f * M_PI);
} else if (aAntiClockwise && (aStartAngle < aEndAngle)) {
Float correction = ceil((aEndAngle - aStartAngle) / (2.0f * M_PI));
aStartAngle += correction * 2.0f * M_PI;
Float correction = (Float)ceil((aEndAngle - aStartAngle) / (2.0f * M_PI));
aStartAngle += float(correction * 2.0f * M_PI);
}
// Sweeping more than 2 * pi is a full circle.
if (!aAntiClockwise && (aEndAngle - aStartAngle > 2 * M_PI)) {
aEndAngle = aStartAngle + 2.0f * M_PI;
aEndAngle = float(aStartAngle + 2.0f * M_PI);
} else if (aAntiClockwise && (aStartAngle - aEndAngle > 2.0f * M_PI)) {
aEndAngle = aStartAngle - 2.0f * M_PI;
aEndAngle = float(aStartAngle - 2.0f * M_PI);
}
// Calculate the total arc we're going to sweep.
Float arcSweepLeft = fabs(aEndAngle - aStartAngle);
Float sweepDirection = aAntiClockwise ? -1.0f : 1.0f;
Float currentStartAngle = aStartAngle;
while (arcSweepLeft > 0) {
// We guarantee here the current point is the start point of the next
// curve segment.
Float currentEndAngle;
if (arcSweepLeft > M_PI / 2.0f) {
currentEndAngle = currentStartAngle + M_PI / 2.0f * sweepDirection;
currentEndAngle = Float(currentStartAngle + M_PI / 2.0f * sweepDirection);
} else {
currentEndAngle = currentStartAngle + arcSweepLeft * sweepDirection;
}
Point currentStartPoint(aOrigin.x + cos(currentStartAngle) * aRadius,
aOrigin.y + sin(currentStartAngle) * aRadius);
Point currentEndPoint(aOrigin.x + cos(currentEndAngle) * aRadius,
aOrigin.y + sin(currentEndAngle) * aRadius);
// Calculate kappa constant for partial curve. The sign of angle in the
// tangent will actually ensure this is negative for a counter clockwise
// tangent will actually ensure this is negative for a counter clockwise
// sweep, so changing signs later isn't needed.
Float kappa = (4.0f / 3.0f) * tan((currentEndAngle - currentStartAngle) / 4.0f) * aRadius;
Point tangentStart(-sin(currentStartAngle), cos(currentStartAngle));
Point cp1 = currentStartPoint;
cp1 += tangentStart * kappa;
Point revTangentEnd(sin(currentEndAngle), -cos(currentEndAngle));
Point cp2 = currentEndPoint;
cp2 += revTangentEnd * kappa;
aSink->BezierTo(cp1, cp2, currentEndPoint);
arcSweepLeft -= M_PI / 2.0f;
arcSweepLeft -= Float(M_PI / 2.0f);
currentStartAngle = currentEndAngle;
}
}

View File

@ -137,8 +137,10 @@ PathSkia::ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
}
SkRegion pointRect;
pointRect.setRect(SkFloatToScalar(transformed.x - 1), SkFloatToScalar(transformed.y - 1),
SkFloatToScalar(transformed.x + 1), SkFloatToScalar(transformed.y + 1));
pointRect.setRect(int32_t(SkFloatToScalar(transformed.x - 1)),
int32_t(SkFloatToScalar(transformed.y - 1)),
int32_t(SkFloatToScalar(transformed.x + 1)),
int32_t(SkFloatToScalar(transformed.y + 1)));
SkRegion pathRegion;

View File

@ -30,16 +30,23 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect,
const gfxRect* aDirtyRect,
const gfxRect* aSkipRect)
{
mozilla::gfx::Rect rect(aRect.x, aRect.y, aRect.width, aRect.height);
mozilla::gfx::Rect rect(Float(aRect.x), Float(aRect.y),
Float(aRect.width), Float(aRect.height));
IntSize spreadRadius(aSpreadRadius.width, aSpreadRadius.height);
IntSize blurRadius(aBlurRadius.width, aBlurRadius.height);
nsAutoPtr<mozilla::gfx::Rect> dirtyRect;
if (aDirtyRect) {
dirtyRect = new mozilla::gfx::Rect(aDirtyRect->x, aDirtyRect->y, aDirtyRect->width, aDirtyRect->height);
dirtyRect = new mozilla::gfx::Rect(Float(aDirtyRect->x),
Float(aDirtyRect->y),
Float(aDirtyRect->width),
Float(aDirtyRect->height));
}
nsAutoPtr<mozilla::gfx::Rect> skipRect;
if (aSkipRect) {
skipRect = new mozilla::gfx::Rect(aSkipRect->x, aSkipRect->y, aSkipRect->width, aSkipRect->height);
skipRect = new mozilla::gfx::Rect(Float(aSkipRect->x),
Float(aSkipRect->y),
Float(aSkipRect->width),
Float(aSkipRect->height));
}
mBlur = new AlphaBoxBlur(rect, spreadRadius, blurRadius, dirtyRect, skipRect);
@ -99,7 +106,7 @@ gfxAlphaBoxBlur::Paint(gfxContext* aDestinationCtx, const gfxPoint& offset)
gfxIntSize gfxAlphaBoxBlur::CalculateBlurRadius(const gfxPoint& aStd)
{
mozilla::gfx::Point std(aStd.x, aStd.y);
mozilla::gfx::Point std(Float(aStd.x), Float(aStd.y));
IntSize size = AlphaBoxBlur::CalculateBlurRadius(std);
return gfxIntSize(size.width, size.height);
}