fix clang code model warning.

This commit is contained in:
subhransu mohanty 2019-07-11 13:46:44 +09:00 committed by Subhransu
parent 87a6eeed0c
commit 97a711f2ad
11 changed files with 66 additions and 69 deletions

View File

@ -14,7 +14,7 @@ install:
- pip install meson==0.50.0 ninja
- call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %ARCH%
build_script:
- meson -Dwarning_level=0 -Dwerror=false --backend=ninja --prefix=%cd% build
- meson -Dwerror=false --backend=ninja --prefix=%cd% build
- where link
- ninja -C build
test_script:

View File

@ -131,7 +131,7 @@ bool LOTCompItem::update(int frameNo)
float sx = float(viewPort.width()) / viewBox.width();
float sy = float(viewPort.height()) / viewBox.height();
float scale = fmin(sx, sy);
float scale = std::min(sx, sy);
float tx = (viewPort.width() - viewBox.width() * scale) * 0.5f;
float ty = (viewPort.height() - viewBox.height() * scale) * 0.5f;
@ -1340,7 +1340,7 @@ void LOTFillItem::updateRenderNode()
{
VColor color = mColor;
color.setAlpha(color.a * parentAlpha());
color.setAlpha(uchar(color.a * parentAlpha()));
VBrush brush(color);
mDrawable.setBrush(brush);
mDrawable.setFillRule(mModel.fillRule());
@ -1397,7 +1397,7 @@ void LOTStrokeItem::updateRenderNode()
{
VColor color = mColor;
color.setAlpha(color.a * parentAlpha());
color.setAlpha(uchar(color.a * parentAlpha()));
VBrush brush(color);
mDrawable.setBrush(brush);
float scale =

View File

@ -250,8 +250,8 @@ public:
}
bool changed(int prevFrame, int curFrame) const {
int first = mKeyFrames.front().mStartFrame;
int last = mKeyFrames.back().mEndFrame;
auto first = mKeyFrames.front().mStartFrame;
auto last = mKeyFrames.back().mEndFrame;
return !((first > prevFrame && first > curFrame) ||
(last < prevFrame && last < curFrame));
@ -572,7 +572,7 @@ public:
size_t frameAtPos(double pos) const {
if (pos < 0) pos = 0;
if (pos > 1) pos = 1;
return pos * frameDuration();
return size_t(pos * frameDuration());
}
long frameAtTime(double timeInSec) const {
return frameAtPos(timeInSec / duration());
@ -979,7 +979,7 @@ public:
double duration() const {return mRoot->duration();}
size_t totalFrame() const {return mRoot->totalFrame();}
size_t frameDuration() const {return mRoot->frameDuration();}
size_t frameRate() const {return mRoot->frameRate();}
double frameRate() const {return mRoot->frameRate();}
size_t startFrame() const {return mRoot->startFrame();}
size_t endFrame() const {return mRoot->endFrame();}
size_t frameAtPos(double pos) const {return mRoot->frameAtPos(pos);}

View File

@ -17,7 +17,7 @@
*/
#include "vbitmap.h"
#include <string.h>
#include <string>
#include "vdrawhelper.h"
#include "vglobal.h"
@ -35,8 +35,12 @@ struct VBitmap::Impl {
bool mRoData;
Impl() = delete;
Impl(Impl&&) = delete;
Impl(const Impl&) = delete;
Impl& operator=(Impl&&) = delete;
Impl& operator=(Impl&) = delete;
Impl(uint width, uint height, VBitmap::Format format)
explicit Impl(uint width, uint height, VBitmap::Format format)
: mOwnData(true), mRoData(false)
{
reset(width, height, format);
@ -55,24 +59,19 @@ struct VBitmap::Impl {
mFormat = format;
mStride = stride;
mBytes = mStride * mHeight;
mData = reinterpret_cast<uchar *>(::operator new(mBytes));
mData = new uchar[mBytes];
}
Impl(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format)
: mOwnData(false), mRoData(false)
explicit Impl(uchar *data, uint w, uint h, uint bytesPerLine, VBitmap::Format format)
: mData(data), mWidth(w), mHeight(h), mStride(bytesPerLine),
mDepth(depth(format)), mFormat(format), mOwnData(false), mRoData(false)
{
mWidth = w;
mHeight = h;
mFormat = format;
mStride = bytesPerLine;
mBytes = mStride * mHeight;
mData = data;
mDepth = depth(format);
}
~Impl()
{
if (mOwnData && mData) ::operator delete(mData);
if (mOwnData && mData) delete[] mData;
}
uint stride() const { return mStride; }
@ -125,7 +124,7 @@ struct VBitmap::Impl {
green = (green * 255) / alpha;
blue = (blue * 255) / alpha;
}
int luminosity = (0.299f * red + 0.587f * green + 0.114f * blue);
int luminosity = int(0.299f * red + 0.587f * green + 0.114f * blue);
*pixel = luminosity << 24;
pixel++;
}
@ -195,7 +194,7 @@ uchar *VBitmap::data() const
bool VBitmap::valid() const
{
return mImpl ? true : false;
return (mImpl != nullptr);
}
VBitmap::Format VBitmap::format() const

View File

@ -21,9 +21,7 @@
V_BEGIN_NAMESPACE
VGradient::VGradient(VGradient::Type type)
: mType(type),
mSpread(VGradient::Spread::Pad),
mMode(VGradient::Mode::Absolute)
: mType(type)
{
if (mType == Type::Linear)
linear.x1 = linear.y1 = linear.x2 = linear.y2 = 0.0f;
@ -41,7 +39,7 @@ VBrush::VBrush(const VColor &color) : mType(VBrush::Type::Solid), mColor(color)
{
}
VBrush::VBrush(int r, int g, int b, int a)
VBrush::VBrush(uchar r, uchar g, uchar b, uchar a)
: mType(VBrush::Type::Solid), mColor(r, g, b, a)
{

View File

@ -27,14 +27,14 @@
V_BEGIN_NAMESPACE
typedef std::pair<float, VColor> VGradientStop;
typedef std::vector<VGradientStop> VGradientStops;
using VGradientStop = std::pair<float, VColor>;
using VGradientStops = std::vector<VGradientStop>;
class VGradient {
public:
enum class Mode { Absolute, Relative };
enum class Spread { Pad, Repeat, Reflect };
enum class Type { Linear, Radial };
VGradient(VGradient::Type type);
explicit VGradient(VGradient::Type type);
void setStops(const VGradientStops &stops);
void setAlpha(float alpha) {mAlpha = alpha;}
float alpha() const {return mAlpha;}
@ -42,16 +42,16 @@ public:
public:
static constexpr int colorTableSize = 1024;
VGradient::Type mType;
VGradient::Spread mSpread;
VGradient::Mode mMode;
VGradient::Type mType{Type::Linear};
VGradient::Spread mSpread{Spread::Pad};
VGradient::Mode mMode{Mode::Absolute};
VGradientStops mStops;
float mAlpha{1.0};
struct Linear{
float x1, y1, x2, y2;
float x1{0}, y1{0}, x2{0}, y2{0};
};
struct Radial{
float cx, cy, fx, fy, cradius, fradius;
float cx{0}, cy{0}, fx{0}, fy{0}, cradius{0}, fradius{0};
};
union {
Linear linear;
@ -64,10 +64,10 @@ class VBrush {
public:
enum class Type { NoBrush, Solid, LinearGradient, RadialGradient, Texture };
VBrush() = default;
VBrush(const VColor &color);
VBrush(const VGradient *gradient);
VBrush(int r, int g, int b, int a);
VBrush(const VBitmap &texture);
explicit VBrush(const VColor &color);
explicit VBrush(const VGradient *gradient);
explicit VBrush(uchar r, uchar g, uchar b, uchar a);
explicit VBrush(const VBitmap &texture);
inline VBrush::Type type() const { return mType; }
void setMatrix(const VMatrix &m);
public:

View File

@ -19,7 +19,7 @@
#ifndef VCOWPTR_H
#define VCOWPTR_H
#include <assert.h>
#include <cassert>
#include "vglobal.h"
template <typename T>
@ -30,9 +30,8 @@ class vcow_ptr {
model() = default;
template <class... Args>
explicit model(Args&&... args) : mValue(std::forward<Args>(args)...)
{
}
explicit model(Args&&... args) : mValue(std::forward<Args>(args)...){}
explicit model(const T& other) : mValue(other){}
T mValue;
};
@ -54,7 +53,7 @@ public:
}
template <class... Args>
vcow_ptr(Args&&... args) : mModel(new model(std::forward<Args>(args)...))
explicit vcow_ptr(Args&&... args) : mModel(new model(std::forward<Args>(args)...))
{
}
@ -71,7 +70,8 @@ public:
auto operator=(const vcow_ptr& x) noexcept -> vcow_ptr&
{
return *this = vcow_ptr(x);
*this = vcow_ptr(x);
return *this;
}
auto operator=(vcow_ptr&& x) noexcept -> vcow_ptr&
@ -85,7 +85,7 @@ public:
auto operator-> () const noexcept -> const element_type* { return &read(); }
int refCount() const noexcept
std::size_t refCount() const noexcept
{
assert(mModel);

View File

@ -91,7 +91,7 @@ public:
if (count == -1) // isStatic
return true;
atomic.fetch_sub(1);
return --count;
return (--count == 0);
}
bool isShared() const
{
@ -263,14 +263,14 @@ public:
VColor() = default;
explicit VColor(uchar red, uchar green, uchar blue, uchar alpha = 255) noexcept
:a(alpha), r(red), g(green), b(blue){}
inline int red() const noexcept { return r; }
inline int green() const noexcept { return g; }
inline int blue() const noexcept { return b; }
inline int alpha() const noexcept { return a; }
inline void setRed(int red) noexcept { r = red; }
inline void setGreen(int green) noexcept { g = green; }
inline void setBlue(int blue) noexcept { b = blue; }
inline void setAlpha(int alpha) noexcept { a = alpha; }
inline uchar red() const noexcept { return r; }
inline uchar green() const noexcept { return g; }
inline uchar blue() const noexcept { return b; }
inline uchar alpha() const noexcept { return a; }
inline void setRed(uchar red) noexcept { r = red; }
inline void setGreen(uchar green) noexcept { g = green; }
inline void setBlue(uchar blue) noexcept { b = blue; }
inline void setAlpha(uchar alpha) noexcept { a = alpha; }
inline bool isOpaque() const { return a == 255; }
inline bool operator==(const VColor &o) const
{

View File

@ -69,7 +69,7 @@ public:
const std::vector<VPointF> & points() const;
void clone(const VPath &srcPath);
bool unique() const { return d.unique();}
int refCount() const { return d.refCount();}
size_t refCount() const { return d.refCount();}
private:
struct VPathData {

View File

@ -31,9 +31,9 @@ V_BEGIN_NAMESPACE
enum class Operation { Add, Xor };
struct VRleHelper {
size_t alloc;
size_t size;
VRle::Span *spans;
size_t alloc{0};
size_t size{0};
VRle::Span *spans{nullptr};
};
static void rleIntersectWithRle(VRleHelper *, int, int, VRleHelper *,
VRleHelper *);
@ -150,7 +150,7 @@ void VRle::VRleData::invert()
}
}
void VRle::VRleData::operator*=(int alpha)
void VRle::VRleData::operator*=(uchar alpha)
{
alpha &= 0xff;
for (auto &i : mSpans) {

View File

@ -30,13 +30,13 @@ V_BEGIN_NAMESPACE
class VRle {
public:
struct Span {
short x;
short y;
ushort len;
uchar coverage;
short x{0};
short y{0};
ushort len{0};
uchar coverage{0};
};
typedef void (*VRleSpanCb)(size_t count, const VRle::Span *spans,
void *userData);
using VRleSpanCb = void (*)(size_t count, const VRle::Span *spans,
void *userData);
bool empty() const;
VRect boundingRect() const;
void setBoundingRect(const VRect &bbox);
@ -46,7 +46,7 @@ public:
void translate(const VPoint &p);
void invert();
void operator*=(int alpha);
void operator*=(uchar alpha);
void intersect(const VRect &r, VRleSpanCb cb, void *userData) const;
void intersect(const VRle &rle, VRleSpanCb cb, void *userData) const;
@ -59,7 +59,7 @@ public:
static VRle toRle(const VRect &rect);
bool unique() const {return d.unique();}
int refCount() const { return d.refCount();}
size_t refCount() const { return d.refCount();}
void clone(const VRle &o);
private:
@ -75,7 +75,7 @@ private:
void setBbox(const VRect &bbox) const;
void reset();
void translate(const VPoint &p);
void operator*=(int alpha);
void operator*=(uchar alpha);
void invert();
void opIntersect(const VRect &, VRle::VRleSpanCb, void *) const;
void opGeneric(const VRle::VRleData &, const VRle::VRleData &, OpCode code);
@ -119,7 +119,7 @@ inline void VRle::invert()
d.write().invert();
}
inline void VRle::operator*=(int alpha)
inline void VRle::operator*=(uchar alpha)
{
d.write() *= alpha;
}