Commit 73e5e9b5 by Jiacheng Lu Committed by Commit Bot

Clang warn implicit float to int conversion

1. add '-Wfloat-conversion' in compiler flag for clang 2. fix existed implicit float conversion Bug: angleproject:3728 Change-Id: I0dc07eeb74c5d6dc480c6f0aa88bc75ab98e4292 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1713741 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent a2129356
...@@ -122,6 +122,7 @@ config("extra_warnings") { ...@@ -122,6 +122,7 @@ config("extra_warnings") {
# Enable after anglebug.com/3128 is fixed. # Enable after anglebug.com/3128 is fixed.
# "-Wextra-semi-stmt", # "-Wextra-semi-stmt",
"-Wfloat-conversion",
"-Wnon-virtual-dtor", "-Wnon-virtual-dtor",
"-Wunneeded-internal-declaration", "-Wunneeded-internal-declaration",
] ]
......
...@@ -335,7 +335,7 @@ class Matrix ...@@ -335,7 +335,7 @@ class Matrix
Matrix<T> result(std::vector<T>(mElements.size()), rows(), columns()); Matrix<T> result(std::vector<T>(mElements.size()), rows(), columns());
for (unsigned int i = 0; i < rows(); i++) for (unsigned int i = 0; i < rows(); i++)
for (unsigned int j = 0; j < columns(); j++) for (unsigned int j = 0; j < columns(); j++)
result(i, j) = det ? adjugateMatrix(i, j) / det : T(); result(i, j) = (det != static_cast<T>(0)) ? adjugateMatrix(i, j) / det : T();
return result; return result;
} }
......
...@@ -2953,7 +2953,7 @@ TConstantUnion *TIntermConstantUnion::foldUnaryComponentWise(TOperator op, ...@@ -2953,7 +2953,7 @@ TConstantUnion *TIntermConstantUnion::foldUnaryComponentWise(TOperator op,
ASSERT(getType().getBasicType() == EbtFloat); ASSERT(getType().getBasicType() == EbtFloat);
float x = operandArray[i].getFConst(); float x = operandArray[i].getFConst();
float length = VectorLength(operandArray, objectSize); float length = VectorLength(operandArray, objectSize);
if (length) if (length != 0.0f)
resultArray[i].setFConst(x / length); resultArray[i].setFConst(x / length);
else else
UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(),
......
...@@ -298,12 +298,12 @@ void WindowSurfaceCGL::setSwapInterval(EGLint interval) ...@@ -298,12 +298,12 @@ void WindowSurfaceCGL::setSwapInterval(EGLint interval)
EGLint WindowSurfaceCGL::getWidth() const EGLint WindowSurfaceCGL::getWidth() const
{ {
return CGRectGetWidth([mLayer frame]); return (EGLint)CGRectGetWidth([mLayer frame]);
} }
EGLint WindowSurfaceCGL::getHeight() const EGLint WindowSurfaceCGL::getHeight() const
{ {
return CGRectGetHeight([mLayer frame]); return (EGLint)CGRectGetHeight([mLayer frame]);
} }
EGLint WindowSurfaceCGL::isPostSubBufferSupported() const EGLint WindowSurfaceCGL::isPostSubBufferSupported() const
......
...@@ -129,8 +129,8 @@ static float YCoordToFromCG(float y) ...@@ -129,8 +129,8 @@ static float YCoordToFromCG(float y)
NSSize windowSize = [[mWindow->getNSWindow() contentView] frame].size; NSSize windowSize = [[mWindow->getNSWindow() contentView] frame].size;
Event event; Event event;
event.Type = Event::EVENT_RESIZED; event.Type = Event::EVENT_RESIZED;
event.Size.Width = windowSize.width; event.Size.Width = (int)windowSize.width;
event.Size.Height = windowSize.height; event.Size.Height = (int)windowSize.height;
mWindow->pushEvent(event); mWindow->pushEvent(event);
} }
...@@ -139,8 +139,8 @@ static float YCoordToFromCG(float y) ...@@ -139,8 +139,8 @@ static float YCoordToFromCG(float y)
NSRect screenspace = [mWindow->getNSWindow() frame]; NSRect screenspace = [mWindow->getNSWindow() frame];
Event event; Event event;
event.Type = Event::EVENT_MOVED; event.Type = Event::EVENT_MOVED;
event.Move.X = screenspace.origin.x; event.Move.X = (int)screenspace.origin.x;
event.Move.Y = YCoordToFromCG(screenspace.origin.y + screenspace.size.height); event.Move.Y = (int)YCoordToFromCG(screenspace.origin.y + screenspace.size.height);
mWindow->pushEvent(event); mWindow->pushEvent(event);
} }
...@@ -474,8 +474,8 @@ static MouseButton TranslateMouseButton(int button) ...@@ -474,8 +474,8 @@ static MouseButton TranslateMouseButton(int button)
Event event; Event event;
event.Type = eventType; event.Type = eventType;
event.MouseButton.Button = button; event.MouseButton.Button = button;
event.MouseButton.X = [nsEvent locationInWindow].x; event.MouseButton.X = (int)[nsEvent locationInWindow].x;
event.MouseButton.Y = [self translateMouseY:[nsEvent locationInWindow].y]; event.MouseButton.Y = (int)[self translateMouseY:[nsEvent locationInWindow].y];
mWindow->pushEvent(event); mWindow->pushEvent(event);
} }
...@@ -498,8 +498,8 @@ static MouseButton TranslateMouseButton(int button) ...@@ -498,8 +498,8 @@ static MouseButton TranslateMouseButton(int button)
{ {
Event event; Event event;
event.Type = Event::EVENT_MOUSE_MOVED; event.Type = Event::EVENT_MOUSE_MOVED;
event.MouseMove.X = [nsEvent locationInWindow].x; event.MouseMove.X = (int)[nsEvent locationInWindow].x;
event.MouseMove.Y = [self translateMouseY:[nsEvent locationInWindow].y]; event.MouseMove.Y = (int)[self translateMouseY:[nsEvent locationInWindow].y];
mWindow->pushEvent(event); mWindow->pushEvent(event);
} }
...@@ -560,7 +560,7 @@ static MouseButton TranslateMouseButton(int button) ...@@ -560,7 +560,7 @@ static MouseButton TranslateMouseButton(int button)
Event event; Event event;
event.Type = Event::EVENT_MOUSE_WHEEL_MOVED; event.Type = Event::EVENT_MOUSE_WHEEL_MOVED;
event.MouseWheel.Delta = [nsEvent deltaY]; event.MouseWheel.Delta = (int)[nsEvent deltaY];
mWindow->pushEvent(event); mWindow->pushEvent(event);
} }
...@@ -718,7 +718,7 @@ void OSXWindow::messageLoop() ...@@ -718,7 +718,7 @@ void OSXWindow::messageLoop()
void OSXWindow::setMousePosition(int x, int y) void OSXWindow::setMousePosition(int x, int y)
{ {
y = [mWindow frame].size.height - y - 1; y = (int)([mWindow frame].size.height) - y - 1;
NSPoint screenspace; NSPoint screenspace;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
...@@ -733,7 +733,7 @@ bool OSXWindow::setPosition(int x, int y) ...@@ -733,7 +733,7 @@ bool OSXWindow::setPosition(int x, int y)
{ {
// Given CG and NS's coordinate system, the "Y" position of a window is the Y coordinate // Given CG and NS's coordinate system, the "Y" position of a window is the Y coordinate
// of the bottom of the window. // of the bottom of the window.
int newBottom = [mWindow frame].size.height + y; int newBottom = (int)([mWindow frame].size.height) + y;
NSRect emptyRect = NSMakeRect(x, YCoordToFromCG(newBottom), 0, 0); NSRect emptyRect = NSMakeRect(x, YCoordToFromCG(newBottom), 0, 0);
[mWindow setFrameOrigin:[mWindow frameRectForContentRect:emptyRect].origin]; [mWindow setFrameOrigin:[mWindow frameRectForContentRect:emptyRect].origin];
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment