Skip to content

Commit

Permalink
replace uint ushort and uchar typedefs with uint32 uint16 and uint8
Browse files Browse the repository at this point in the history
-- added format script to run clang format on latest commit.
  • Loading branch information
smohantty committed Dec 9, 2021
1 parent 16beec8 commit d7cf0a5
Show file tree
Hide file tree
Showing 22 changed files with 177 additions and 168 deletions.
1 change: 1 addition & 0 deletions format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git diff -U0 --no-color HEAD^ | clang-format-diff -i -p1
6 changes: 3 additions & 3 deletions src/lottie/lottiefiltermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class FilterData {
public:
void addValue(LOTVariant& value)
{
uint index = static_cast<uint>(value.property());
uint32_t index = static_cast<uint32_t>(value.property());
if (mBitset.test(index)) {
std::replace_if(mFilters.begin(), mFilters.end(),
[&value](const LOTVariant& e) {
Expand All @@ -253,7 +253,7 @@ class FilterData {

void removeValue(LOTVariant& value)
{
uint index = static_cast<uint>(value.property());
uint32_t index = static_cast<uint32_t>(value.property());
if (mBitset.test(index)) {
mBitset.reset(index);
mFilters.erase(std::remove_if(mFilters.begin(), mFilters.end(),
Expand All @@ -266,7 +266,7 @@ class FilterData {
}
bool hasFilter(rlottie::Property prop) const
{
return mBitset.test(static_cast<uint>(prop));
return mBitset.test(static_cast<uint32_t>(prop));
}
model::Color color(rlottie::Property prop, int frame) const
{
Expand Down
28 changes: 14 additions & 14 deletions src/lottie/lottieitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ bool renderer::Composition::update(int frameNo, const VSize &size,

bool renderer::Composition::render(const rlottie::Surface &surface)
{
mSurface.reset(reinterpret_cast<uchar *>(surface.buffer()),
uint(surface.width()), uint(surface.height()),
uint(surface.bytesPerLine()),
mSurface.reset(reinterpret_cast<uint8_t *>(surface.buffer()),
uint32_t(surface.width()), uint32_t(surface.height()),
uint32_t(surface.bytesPerLine()),
VBitmap::Format::ARGB32_Premultiplied);

/* schedule all preprocess task for this frame at once.
Expand Down Expand Up @@ -200,7 +200,7 @@ VRle renderer::Mask::rle()
{
if (!vCompare(mCombinedAlpha, 1.0f)) {
VRle obj = mRasterizer.rle();
obj *= uchar(mCombinedAlpha * 255);
obj *= uint8_t(mCombinedAlpha * 255);
return obj;
} else {
return mRasterizer.rle();
Expand Down Expand Up @@ -343,7 +343,7 @@ renderer::Layer::Layer(model::Layer *layerData) : mLayerData(layerData)
mLayerMask = std::make_unique<renderer::LayerMask>(mLayerData);
}

bool renderer::Layer::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool renderer::Layer::resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value)
{
if (!keyPath.matches(name(), depth)) {
Expand All @@ -359,25 +359,25 @@ bool renderer::Layer::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
return true;
}

bool renderer::ShapeLayer::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool renderer::ShapeLayer::resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value)
{
if (renderer::Layer::resolveKeyPath(keyPath, depth, value)) {
if (keyPath.propagate(name(), depth)) {
uint newDepth = keyPath.nextDepth(name(), depth);
uint32_t newDepth = keyPath.nextDepth(name(), depth);
mRoot->resolveKeyPath(keyPath, newDepth, value);
}
return true;
}
return false;
}

bool renderer::CompLayer::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool renderer::CompLayer::resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value)
{
if (renderer::Layer::resolveKeyPath(keyPath, depth, value)) {
if (keyPath.propagate(name(), depth)) {
uint newDepth = keyPath.nextDepth(name(), depth);
uint32_t newDepth = keyPath.nextDepth(name(), depth);
for (const auto &layer : mLayers) {
layer->resolveKeyPath(keyPath, newDepth, value);
}
Expand Down Expand Up @@ -507,7 +507,7 @@ void renderer::CompLayer::render(VPainter *painter, const VRle &inheritMask,
renderHelper(&srcPainter, inheritMask, matteRle, cache);
srcPainter.end();
painter->drawBitmap(VPoint(), srcBitmap,
uchar(combinedAlpha() * 255.0f));
uint8_t(combinedAlpha() * 255.0f));
cache.release_surface(srcBitmap);
} else {
renderHelper(painter, inheritMask, matteRle, cache);
Expand Down Expand Up @@ -863,7 +863,7 @@ renderer::DrawableList renderer::ShapeLayer::renderList()
return {mDrawableList.data(), mDrawableList.size()};
}

bool renderer::Group::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool renderer::Group::resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value)
{
if (!keyPath.skip(name())) {
Expand All @@ -880,15 +880,15 @@ bool renderer::Group::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
}

if (keyPath.propagate(name(), depth)) {
uint newDepth = keyPath.nextDepth(name(), depth);
uint32_t newDepth = keyPath.nextDepth(name(), depth);
for (auto &child : mContents) {
child->resolveKeyPath(keyPath, newDepth, value);
}
}
return true;
}

bool renderer::Fill::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool renderer::Fill::resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value)
{
if (!keyPath.matches(mModel.name(), depth)) {
Expand All @@ -903,7 +903,7 @@ bool renderer::Fill::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
return false;
}

bool renderer::Stroke::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool renderer::Stroke::resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value)
{
if (!keyPath.matches(mModel.name(), depth)) {
Expand Down
20 changes: 10 additions & 10 deletions src/lottie/lottieitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace renderer {

using DrawableList = VSpan<VDrawable *>;

enum class DirtyFlagBit : uchar {
enum class DirtyFlagBit : uint8_t {
None = 0x00,
Matrix = 0x01,
Alpha = 0x02,
Expand Down Expand Up @@ -239,8 +239,8 @@ class Layer {
std::vector<LOTMask> & cmasks() { return mCApiData->mMasks; }
std::vector<LOTNode *> & cnodes() { return mCApiData->mCNodeList; }
const char * name() const { return mLayerData->name(); }
virtual bool resolveKeyPath(LOTKeyPath &keyPath, uint depth,
LOTVariant &value);
virtual bool resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value);

protected:
virtual void preprocessStage(const VRect &clip) = 0;
Expand Down Expand Up @@ -275,7 +275,7 @@ class CompLayer final : public Layer {
void render(VPainter *painter, const VRle &mask, const VRle &matteRle,
SurfaceCache &cache) final;
void buildLayerNode() final;
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value) override;

protected:
Expand Down Expand Up @@ -317,7 +317,7 @@ class ShapeLayer final : public Layer {
explicit ShapeLayer(model::Layer *layerData, VArenaAlloc *allocator);
DrawableList renderList() final;
void buildLayerNode() final;
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value) override;

protected:
Expand Down Expand Up @@ -355,13 +355,13 @@ class ImageLayer final : public Layer {

class Object {
public:
enum class Type : uchar { Unknown, Group, Shape, Paint, Trim };
enum class Type : uint8_t { Unknown, Group, Shape, Paint, Trim };
virtual ~Object() = default;
Object & operator=(Object &&) noexcept = delete;
virtual void update(int frameNo, const VMatrix &parentMatrix,
float parentAlpha, const DirtyFlag &flag) = 0;
virtual void renderList(std::vector<VDrawable *> &) {}
virtual bool resolveKeyPath(LOTKeyPath &, uint, LOTVariant &)
virtual bool resolveKeyPath(LOTKeyPath &, uint32_t, LOTVariant &)
{
return false;
}
Expand All @@ -387,7 +387,7 @@ class Group : public Object {
static const char *TAG = "__";
return mModel.hasModel() ? mModel.name() : TAG;
}
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value) override;

protected:
Expand Down Expand Up @@ -532,7 +532,7 @@ class Fill final : public Paint {

protected:
bool updateContent(int frameNo, const VMatrix &matrix, float alpha) final;
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value) final;

private:
Expand All @@ -557,7 +557,7 @@ class Stroke : public Paint {

protected:
bool updateContent(int frameNo, const VMatrix &matrix, float alpha) final;
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth,
bool resolveKeyPath(LOTKeyPath &keyPath, uint32_t depth,
LOTVariant &value) final;

private:
Expand Down
8 changes: 4 additions & 4 deletions src/lottie/lottieitem_capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void renderer::Layer::buildLayerNode()
mCApiData = std::make_unique<renderer::CApiData>();
clayer().keypath = name();
}
if (complexContent()) clayer().mAlpha = uchar(combinedAlpha() * 255.f);
if (complexContent()) clayer().mAlpha = uint8_t(combinedAlpha() * 255.f);
clayer().mVisible = visible();
// update matte
if (hasMatte()) {
Expand Down Expand Up @@ -124,7 +124,7 @@ void renderer::Layer::buildLayerNode()
cNode.mPath.ptCount = 2 * pts.size();
cNode.mPath.elmPtr = elmPtr;
cNode.mPath.elmCount = elm.size();
cNode.mAlpha = uchar(mask.mCombinedAlpha * 255.0f);
cNode.mAlpha = uint8_t(mask.mCombinedAlpha * 255.0f);
switch (mask.maskMode()) {
case model::Mask::Mode::Add:
cNode.mMode = MaskAdd;
Expand Down Expand Up @@ -196,7 +196,7 @@ void renderer::ImageLayer::buildLayerNode()

// Alpha calculation already combined.
lotDrawable->mCNode->mImageInfo.mAlpha =
uchar(lotDrawable->mBrush.mTexture->mAlpha);
uint8_t(lotDrawable->mBrush.mTexture->mAlpha);

cnodes().push_back(lotDrawable->mCNode.get());
}
Expand All @@ -216,7 +216,7 @@ static void updateGStops(LOTNode *n, const VGradient *grad)
LOTGradientStop *ptr = n->mGradient.stopPtr;
for (const auto &i : grad->mStops) {
ptr->pos = i.first;
ptr->a = uchar(i.second.alpha() * grad->alpha());
ptr->a = uint8_t(i.second.alpha() * grad->alpha());
ptr->r = i.second.red();
ptr->g = i.second.green();
ptr->b = i.second.blue();
Expand Down
6 changes: 3 additions & 3 deletions src/lottie/lottiekeypath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LOTKeyPath::LOTKeyPath(const std::string &keyPath)
}
}

bool LOTKeyPath::matches(const std::string &key, uint depth)
bool LOTKeyPath::matches(const std::string &key, uint32_t depth)
{
if (skip(key)) {
// This is an object we programatically create.
Expand All @@ -28,7 +28,7 @@ bool LOTKeyPath::matches(const std::string &key, uint depth)
return false;
}

uint LOTKeyPath::nextDepth(const std::string key, uint depth)
uint32_t LOTKeyPath::nextDepth(const std::string key, uint32_t depth)
{
if (skip(key)) {
// If it's a container then we added programatically and it isn't a part
Expand All @@ -51,7 +51,7 @@ uint LOTKeyPath::nextDepth(const std::string key, uint depth)
return depth;
}

bool LOTKeyPath::fullyResolvesTo(const std::string key, uint depth)
bool LOTKeyPath::fullyResolvesTo(const std::string key, uint32_t depth)
{
if (depth > mKeys.size()) {
return false;
Expand Down
12 changes: 6 additions & 6 deletions src/lottie/lottiekeypath.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
class LOTKeyPath {
public:
LOTKeyPath(const std::string &keyPath);
bool matches(const std::string &key, uint depth);
uint nextDepth(const std::string key, uint depth);
bool fullyResolvesTo(const std::string key, uint depth);
bool matches(const std::string &key, uint32_t depth);
uint32_t nextDepth(const std::string key, uint32_t depth);
bool fullyResolvesTo(const std::string key, uint32_t depth);

bool propagate(const std::string key, uint depth)
bool propagate(const std::string key, uint32_t depth)
{
return skip(key) ? true : (depth < size()) || (mKeys[depth] == "**");
}
bool skip(const std::string &key) const { return key == "__"; }

private:
bool isGlobstar(uint depth) const { return mKeys[depth] == "**"; }
bool isGlob(uint depth) const { return mKeys[depth] == "*"; }
bool isGlobstar(uint32_t depth) const { return mKeys[depth] == "**"; }
bool isGlob(uint32_t depth) const { return mKeys[depth] == "*"; }
bool endsWithGlobstar() const { return mKeys.back() == "**"; }
size_t size() const { return mKeys.size() - 1; }

Expand Down
10 changes: 5 additions & 5 deletions src/lottie/lottiemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ inline T lerp(const T &start, const T &end, float t)

namespace model {

enum class MatteType : uchar { None = 0, Alpha = 1, AlphaInv, Luma, LumaInv };
enum class MatteType : uint8_t { None = 0, Alpha = 1, AlphaInv, Luma, LumaInv };

enum class BlendMode : uchar {
enum class BlendMode : uint8_t {
Normal = 0,
Multiply = 1,
Screen = 2,
Expand All @@ -72,8 +72,8 @@ class Color {
Color(float red, float green, float blue) : r(red), g(green), b(blue) {}
VColor toColor(float a = 1)
{
return VColor(uchar(255 * r), uchar(255 * g), uchar(255 * b),
uchar(255 * a));
return VColor(uint8_t(255 * r), uint8_t(255 * g), uint8_t(255 * b),
uint8_t(255 * a));
}
friend inline Color operator+(const Color &c1, const Color &c2);
friend inline Color operator-(const Color &c1, const Color &c2);
Expand Down Expand Up @@ -667,7 +667,7 @@ class Group : public Object {

class Layer : public Group {
public:
enum class Type : uchar {
enum class Type : uint8_t {
Precomp = 0,
Solid = 1,
Image = 2,
Expand Down
Loading

0 comments on commit d7cf0a5

Please sign in to comment.