-- added format script to run clang format on latest commit.
Change-Id: I23f7fad4b75ef6c40e984766480876bf1bcb88a2
Signed-off-by: jykeon <jykeon@samsung.com>
--- /dev/null
+git diff -U0 --no-color HEAD^ | clang-format-diff -i -p1
\ No newline at end of file
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) {
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(),
}
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
{
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.
{
if (!vCompare(mCombinedAlpha, 1.0f)) {
VRle obj = mRasterizer.rle();
- obj *= uchar(mCombinedAlpha * 255);
+ obj *= uint8_t(mCombinedAlpha * 255);
return obj;
} else {
return mRasterizer.rle();
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)) {
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);
}
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);
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())) {
}
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)) {
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)) {
using DrawableList = VSpan<VDrawable *>;
-enum class DirtyFlagBit : uchar {
+enum class DirtyFlagBit : uint8_t {
None = 0x00,
Matrix = 0x01,
Alpha = 0x02,
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;
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:
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:
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;
}
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:
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:
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:
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()) {
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;
// 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());
}
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();
}
}
-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.
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
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;
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; }
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,
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);
class Layer : public Group {
public:
- enum class Type : uchar {
+ enum class Type : uint8_t {
Precomp = 0,
Solid = 1,
Image = 2,
void VBitmap::Impl::reset(size_t width, size_t height, VBitmap::Format format)
{
mRoData = nullptr;
- mWidth = uint(width);
- mHeight = uint(height);
+ mWidth = uint32_t(width);
+ mHeight = uint32_t(height);
mFormat = format;
mDepth = depth(format);
mStride = ((mWidth * mDepth + 31) >> 5)
<< 2; // bytes per scanline (must be multiple of 4)
- mOwnData = std::make_unique<uchar[]>(mStride * mHeight);
+ mOwnData = std::make_unique<uint8_t[]>(mStride * mHeight);
}
-void VBitmap::Impl::reset(uchar *data, size_t width, size_t height, size_t bytesPerLine,
- VBitmap::Format format)
+void VBitmap::Impl::reset(uint8_t *data, size_t width, size_t height,
+ size_t bytesPerLine, VBitmap::Format format)
{
mRoData = data;
- mWidth = uint(width);
- mHeight = uint(height);
- mStride = uint(bytesPerLine);
+ mWidth = uint32_t(width);
+ mHeight = uint32_t(height);
+ mStride = uint32_t(bytesPerLine);
mFormat = format;
mDepth = depth(format);
mOwnData = nullptr;
}
-uchar VBitmap::Impl::depth(VBitmap::Format format)
+uint8_t VBitmap::Impl::depth(VBitmap::Format format)
{
- uchar depth = 1;
+ uint8_t depth = 1;
switch (format) {
case VBitmap::Format::Alpha8:
depth = 8;
return depth;
}
-void VBitmap::Impl::fill(uint /*pixel*/)
+void VBitmap::Impl::fill(uint32_t /*pixel*/)
{
//@TODO
}
{
if (mFormat != VBitmap::Format::ARGB32_Premultiplied) return;
auto dataPtr = data();
- for (uint col = 0; col < mHeight; col++) {
- uint *pixel = (uint *)(dataPtr + mStride * col);
- for (uint row = 0; row < mWidth; row++) {
+ for (uint32_t col = 0; col < mHeight; col++) {
+ uint32_t *pixel = (uint32_t *)(dataPtr + mStride * col);
+ for (uint32_t row = 0; row < mWidth; row++) {
int alpha = vAlpha(*pixel);
if (alpha == 0) {
pixel++;
mImpl = rc_ptr<Impl>(width, height, format);
}
-VBitmap::VBitmap(uchar *data, size_t width, size_t height, size_t bytesPerLine,
- VBitmap::Format format)
+VBitmap::VBitmap(uint8_t *data, size_t width, size_t height,
+ size_t bytesPerLine, VBitmap::Format format)
{
if (!data || width <= 0 || height <= 0 || bytesPerLine <= 0 ||
format == Format::Invalid)
mImpl = rc_ptr<Impl>(data, width, height, bytesPerLine, format);
}
-void VBitmap::reset(uchar *data, size_t w, size_t h, size_t bytesPerLine,
+void VBitmap::reset(uint8_t *data, size_t w, size_t h, size_t bytesPerLine,
VBitmap::Format format)
{
if (mImpl) {
return mImpl ? mImpl->mDepth : 0;
}
-uchar *VBitmap::data()
+uint8_t *VBitmap::data()
{
return mImpl ? mImpl->data() : nullptr;
}
-uchar *VBitmap::data() const
+uint8_t *VBitmap::data() const
{
return mImpl ? mImpl->data() : nullptr;
}
return mImpl ? mImpl->format() : VBitmap::Format::Invalid;
}
-void VBitmap::fill(uint pixel)
+void VBitmap::fill(uint32_t pixel)
{
if (mImpl) mImpl->fill(pixel);
}
class VBitmap {
public:
- enum class Format: uchar {
+ enum class Format : uint8_t {
Invalid,
Alpha8,
ARGB32,
VBitmap() = default;
VBitmap(size_t w, size_t h, VBitmap::Format format);
- VBitmap(uchar *data, size_t w, size_t h, size_t bytesPerLine, VBitmap::Format format);
- void reset(uchar *data, size_t w, size_t h, size_t stride, VBitmap::Format format);
+ VBitmap(uint8_t *data, size_t w, size_t h, size_t bytesPerLine,
+ VBitmap::Format format);
+ void reset(uint8_t *data, size_t w, size_t h, size_t stride,
+ VBitmap::Format format);
void reset(size_t w, size_t h, VBitmap::Format format=Format::ARGB32_Premultiplied);
size_t stride() const;
size_t width() const;
size_t depth() const;
VBitmap::Format format() const;
bool valid() const;
- uchar * data();
- uchar * data() const;
+ uint8_t * data();
+ uint8_t * data() const;
VRect rect() const;
VSize size() const;
- void fill(uint pixel);
+ void fill(uint32_t pixel);
void updateLuma();
private:
struct Impl {
- std::unique_ptr<uchar[]> mOwnData{nullptr};
- uchar * mRoData{nullptr};
- uint mWidth{0};
- uint mHeight{0};
- uint mStride{0};
- uchar mDepth{0};
+ std::unique_ptr<uint8_t[]> mOwnData{nullptr};
+ uint8_t * mRoData{nullptr};
+ uint32_t mWidth{0};
+ uint32_t mHeight{0};
+ uint32_t mStride{0};
+ uint8_t mDepth{0};
VBitmap::Format mFormat{VBitmap::Format::Invalid};
explicit Impl(size_t width, size_t height, VBitmap::Format format)
{
reset(width, height, format);
}
- explicit Impl(uchar *data, size_t w, size_t h, size_t bytesPerLine, VBitmap::Format format)
+ explicit Impl(uint8_t *data, size_t w, size_t h, size_t bytesPerLine,
+ VBitmap::Format format)
{
reset(data, w, h, bytesPerLine, format);
}
size_t stride() const { return mStride; }
size_t width() const { return mWidth; }
size_t height() const { return mHeight; }
- uchar * data() { return mRoData ? mRoData : mOwnData.get(); }
+ uint8_t * data() { return mRoData ? mRoData : mOwnData.get(); }
VBitmap::Format format() const { return mFormat; }
- void reset(uchar *, size_t, size_t, size_t, VBitmap::Format);
+ void reset(uint8_t *, size_t, size_t, size_t, VBitmap::Format);
void reset(size_t, size_t, VBitmap::Format);
- static uchar depth(VBitmap::Format format);
- void fill(uint);
+ static uint8_t depth(VBitmap::Format format);
+ void fill(uint32_t);
void updateLuma();
};
{
}
-VBrush::VBrush(uchar r, uchar g, uchar b, uchar a)
+VBrush::VBrush(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
: mType(VBrush::Type::Solid), mColor(r, g, b, a)
{
VBrush():mType(Type::NoBrush),mColor(){};
explicit VBrush(const VColor &color);
explicit VBrush(const VGradient *gradient);
- explicit VBrush(uchar r, uchar g, uchar b, uchar a);
+ explicit VBrush(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
explicit VBrush(const VTexture *texture);
inline VBrush::Type type() const { return mType; }
public:
bool hasChanged = false;
if (obj->mDash.size() == dashInfo.size()) {
- for (uint i = 0; i < dashInfo.size(); ++i) {
+ for (uint32_t i = 0; i < dashInfo.size(); ++i) {
if (!vCompare(obj->mDash[i], dashInfo[i])) {
hasChanged = true;
break;
VCacheKey hash_val = 0;
VCacheData info;
const VGradientStops &stops = gradient.mStops;
- for (uint i = 0; i < stops.size() && i <= 2; i++)
+ for (uint32_t i = 0; i < stops.size() && i <= 2; i++)
hash_val +=
VCacheKey(stops[i].second.premulARGB() * gradient.alpha());
}
protected:
- uint maxCacheSize() const { return 60; }
+ uint32_t maxCacheSize() const { return 60; }
VCacheData addCacheElement(VCacheKey hash_val, const VGradient &gradient)
{
if (mCache.size() == maxCacheSize()) {
- uint count = maxCacheSize() / 10;
+ uint32_t count = maxCacheSize() / 10;
while (count--) {
mCache.erase(mCache.begin());
}
{
VSpanData *data = (VSpanData *)(userData);
Operator op = getOperator(data);
- const uint color = data->mSolid;
+ const uint32_t color = data->mSolid;
for (size_t i = 0 ; i < size; ++i) {
const auto &span = array[i];
}
// Signature of Process Object
-// void Pocess(uint* scratchBuffer, size_t x, size_t y, uchar cov)
+// void Pocess(uint* scratchBuffer, size_t x, size_t y, uint8_t cov)
template <class Process>
static inline void process_in_chunk(const VRle::Span *array, size_t size,
Process process)
{
- std::array<uint, 2048> buf;
+ std::array<uint32_t, 2048> buf;
for (size_t i = 0; i < size; i++) {
const auto &span = array[i];
size_t len = span.len;
process_in_chunk(
array, size,
- [&](uint *scratch, size_t x, size_t y, size_t len, uchar cov) {
+ [&](uint32_t *scratch, size_t x, size_t y, size_t len, uint8_t cov) {
op.srcFetch(scratch, &op, data, (int)y, (int)x, (int)len);
op.func(data->buffer((int)x, (int)y), (int)len, scratch, cov);
});
return v < lo ? lo : hi < v ? hi : v;
}
-static constexpr inline uchar alpha_mul(uchar a, uchar b)
+static constexpr inline uint8_t alpha_mul(uint8_t a, uint8_t b)
{
return ((a * b) >> 8);
}
process_in_chunk(
array, size,
- [&](uint *scratch, size_t x, size_t y, size_t len, uchar cov) {
+ [&](uint32_t *scratch, size_t x, size_t y, size_t len, uint8_t cov) {
const auto coverage = (cov * src.alpha()) >> 8;
const float xfactor = y * data->m21 + data->dx + data->m11;
const float yfactor = y * data->m22 + data->dy + data->m12;
void resetBuffer(int val = 0);
- inline uchar *scanLine(int y)
+ inline uint8_t *scanLine(int y)
{
assert(y >= 0);
assert(size_t(y) < mHeight);
size_t mHeight{0};
size_t mBytesPerLine{0};
size_t mBytesPerPixel{0};
- mutable uchar * mBuffer{nullptr};
+ mutable uint8_t *mBuffer{nullptr};
};
struct VGradientData {
struct VTextureData : public VRasterBuffer {
uint32_t pixel(int x, int y) const { return *pixelRef(x, y); };
- uchar alpha() const { return mAlpha; }
- void setAlpha(uchar alpha) { mAlpha = alpha; }
+ uint8_t alpha() const { return mAlpha; }
+ void setAlpha(uint8_t alpha) { mAlpha = alpha; }
void setClip(const VRect &clip);
// clip rect
int left;
int top;
int bottom;
bool hasAlpha;
- uchar mAlpha;
+ uint8_t mAlpha;
};
struct VColorTable {
mDrawableSize = VSize(region.width(), region.height());
}
- uint *buffer(int x, int y) const
+ uint32_t *buffer(int x, int y) const
{
return mRasterBuffer->pixelRef(x + mOffset.x(), y + mOffset.y());
}
return c >> 24;
}
-static inline uint32_t interpolate_pixel(uint x, uint a, uint y, uint b)
+static inline uint32_t interpolate_pixel(uint32_t x, uint32_t a, uint32_t y,
+ uint32_t b)
{
- uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
+ uint32_t t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
t >>= 8;
t &= 0xff00ff;
x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
dest = d * sa * ca + d * cia
= d * (sa * ca + cia)
*/
-static void color_DestinationIn(uint *dest, int length, uint color,
- uint alpha)
+static void color_DestinationIn(uint32_t *dest, int length, uint32_t color,
+ uint32_t alpha)
{
- uint a = vAlpha(color);
+ uint32_t a = vAlpha(color);
if (alpha != 255) {
a = BYTE_MUL(a, alpha) + 255 - alpha;
}
dest = d * sia * ca + d * cia
= d * (sia * ca + cia)
*/
-static void color_DestinationOut(uint *dest, int length, uint color,
- uint alpha)
+static void color_DestinationOut(uint32_t *dest, int length, uint32_t color,
+ uint32_t alpha)
{
- uint a = vAlpha(~color);
+ uint32_t a = vAlpha(~color);
if (alpha != 255) a = BYTE_MUL(a, alpha) + 255 - alpha;
for (int i = 0; i < length; ++i) {
dest[i] = BYTE_MUL(dest[i], a);
uint32_t alpha)
{
if (alpha == 255) {
- memcpy(dest, src, size_t(length) * sizeof(uint));
+ memcpy(dest, src, size_t(length) * sizeof(uint32_t));
} else {
- uint ialpha = 255 - alpha;
+ uint32_t ialpha = 255 - alpha;
for (int i = 0; i < length; ++i) {
dest[i] =
interpolate_pixel(src[i], alpha, dest[i], ialpha);
static void src_SourceOver(uint32_t *dest, int length, const uint32_t *src,
uint32_t alpha)
{
- uint s, sia;
+ uint32_t s, sia;
if (alpha == 255) {
for (int i = 0; i < length; ++i) {
}
}
-static void src_DestinationIn(uint *dest, int length, const uint *src,
- uint alpha)
+static void src_DestinationIn(uint32_t *dest, int length, const uint32_t *src,
+ uint32_t alpha)
{
if (alpha == 255) {
for (int i = 0; i < length; ++i) {
dest[i] = BYTE_MUL(dest[i], vAlpha(src[i]));
}
} else {
- uint cia = 255 - alpha;
+ uint32_t cia = 255 - alpha;
for (int i = 0; i < length; ++i) {
- uint a = BYTE_MUL(vAlpha(src[i]), alpha) + cia;
+ uint32_t a = BYTE_MUL(vAlpha(src[i]), alpha) + cia;
dest[i] = BYTE_MUL(dest[i], a);
}
}
}
-static void src_DestinationOut(uint *dest, int length, const uint *src,
- uint alpha)
+static void src_DestinationOut(uint32_t *dest, int length, const uint32_t *src,
+ uint32_t alpha)
{
if (alpha == 255) {
for (int i = 0; i < length; ++i) {
dest[i] = BYTE_MUL(dest[i], vAlpha(~src[i]));
}
} else {
- uint cia = 255 - alpha;
+ uint32_t cia = 255 - alpha;
for (int i = 0; i < length; ++i) {
- uint sia = BYTE_MUL(vAlpha(~src[i]), alpha) + cia;
+ uint32_t sia = BYTE_MUL(vAlpha(~src[i]), alpha) + cia;
dest[i] = BYTE_MUL(dest[i], sia);
}
}
#include <type_traits>
#include <utility>
-using uint = uint32_t;
-using ushort = uint16_t;
-using uchar = uint8_t;
#if !defined(V_NAMESPACE)
explicit constexpr inline vFlagHelper(int ai) noexcept : i(ai) {}
constexpr inline operator int() const noexcept { return i; }
- explicit constexpr inline vFlagHelper(uint ai) noexcept : i(int(ai)) {}
+ explicit constexpr inline vFlagHelper(uint32_t ai) noexcept : i(int(ai)) {}
explicit constexpr inline vFlagHelper(short ai) noexcept : i(int(ai)) {}
- explicit constexpr inline vFlagHelper(ushort ai) noexcept : i(int(uint(ai))) {}
- constexpr inline operator uint() const noexcept { return uint(i); }
+ explicit constexpr inline vFlagHelper(uint16_t ai) noexcept
+ : i(int(uint32_t(ai)))
+ {
+ }
+ constexpr inline operator uint32_t() const noexcept { return uint32_t(i); }
};
template <typename Enum>
i &= mask;
return *this;
}
- inline vFlag &operator&=(uint mask) noexcept
+ inline vFlag &operator&=(uint32_t mask) noexcept
{
i &= mask;
return *this;
{
return vFlag(vFlagHelper(i & mask));
}
- constexpr inline vFlag operator&(uint mask) const noexcept
+ constexpr inline vFlag operator&(uint32_t mask) const noexcept
{
return vFlag(vFlagHelper(i & mask));
}
class VColor {
public:
VColor() = default;
- explicit VColor(uchar red, uchar green, uchar blue, uchar alpha = 255) noexcept
- :a(alpha), r(red), g(green), b(blue){}
- 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; }
+ explicit VColor(uint8_t red, uint8_t green, uint8_t blue,
+ uint8_t alpha = 255) noexcept
+ : a(alpha), r(red), g(green), b(blue)
+ {
+ }
+ inline uint8_t red() const noexcept { return r; }
+ inline uint8_t green() const noexcept { return g; }
+ inline uint8_t blue() const noexcept { return b; }
+ inline uint8_t alpha() const noexcept { return a; }
+ inline void setRed(uint8_t red) noexcept { r = red; }
+ inline void setGreen(uint8_t green) noexcept { g = green; }
+ inline void setBlue(uint8_t blue) noexcept { b = blue; }
+ inline void setAlpha(uint8_t alpha) noexcept { a = alpha; }
inline bool isOpaque() const { return a == 255; }
inline bool isTransparent() const { return a == 0; }
inline bool operator==(const VColor &o) const
{
return ((a == o.a) && (r == o.r) && (g == o.g) && (b == o.b));
}
- uint premulARGB() const
+ uint32_t premulARGB() const
{
int pr = (r * a) / 255;
int pg = (g * a) / 255;
int pb = (b * a) / 255;
- return uint((a << 24) | (pr << 16) | (pg << 8) | (pb));
+ return uint32_t((a << 24) | (pr << 16) | (pg << 8) | (pb));
}
- uint premulARGB(float opacity) const
+ uint32_t premulARGB(float opacity) const
{
int alpha = int(a * opacity);
int pr = (r * alpha) / 255;
int pg = (g * alpha) / 255;
int pb = (b * alpha) / 255;
- return uint((alpha << 24) | (pr << 16) | (pg << 8) | (pb));
+ return uint32_t((alpha << 24) | (pr << 16) | (pg << 8) | (pb));
}
public:
- uchar a{0};
- uchar r{0};
- uchar g{0};
- uchar b{0};
+ uint8_t a{0};
+ uint8_t r{0};
+ uint8_t g{0};
+ uint8_t b{0};
};
enum class FillRule: unsigned char { EvenOdd, Winding };
int i = 0;
while (i < n) {
spans[i].x = short(x1);
- spans[i].len = ushort(x2 - x1);
+ spans[i].len = uint16_t(x2 - x1);
spans[i].y = short(y + i);
spans[i].coverage = 255;
++i;
public:
enum class Direction { CCW, CW };
- enum class Element : uchar { MoveTo, LineTo, CubicTo, Close };
+ enum class Element : uint8_t { MoveTo, LineTo, CubicTo, Close };
bool empty() const;
bool null() const;
void moveTo(const VPointF &p);
outRef.convert(mPath);
outRef.convert(mCap, mJoin, mStrokeWidth, mMiterLimit);
- uint points, contors;
+ uint32_t points, contors;
SW_FT_Stroker_Set(stroker, outRef.ftWidth, outRef.ftCap,
outRef.ftJoin, outRef.ftMiterLimit);
static size_t _opIntersect(const VRect &, rle_view &, Result &);
static size_t _opIntersect(rle_view &, rle_view &, Result &);
-static inline uchar divBy255(int x)
+static inline uint8_t divBy255(int x)
{
return (x + (x >> 8) + 0x80) >> 8;
}
}
}
-void VRle::Data::operator*=(uchar alpha)
+void VRle::Data::operator*=(uint8_t alpha)
{
for (auto &i : mSpans) {
i.coverage = divBy255(i.coverage * alpha);
out->x = minx;
} else {
out->x = span.x;
- out->len = std::min(span.len, ushort(maxx - span.x + 1));
+ out->len = std::min(span.len, uint16_t(maxx - span.x + 1));
}
if (out->len != 0) {
out->y = span.y;
return result.max_size() - available;
}
-static void blitXor(VRle::Span *spans, int count, uchar *buffer, int offsetX)
+static void blitXor(VRle::Span *spans, int count, uint8_t *buffer, int offsetX)
{
while (count--) {
int x = spans->x + offsetX;
int l = spans->len;
- uchar *ptr = buffer + x;
+ uint8_t *ptr = buffer + x;
while (l--) {
int da = *ptr;
*ptr = divBy255((255 - spans->coverage) * (da) +
}
}
-static void blitDestinationOut(VRle::Span *spans, int count, uchar *buffer,
+static void blitDestinationOut(VRle::Span *spans, int count, uint8_t *buffer,
int offsetX)
{
while (count--) {
int x = spans->x + offsetX;
int l = spans->len;
- uchar *ptr = buffer + x;
+ uint8_t *ptr = buffer + x;
while (l--) {
*ptr = divBy255((255 - spans->coverage) * (*ptr));
ptr++;
}
}
-static void blitSrcOver(VRle::Span *spans, int count, uchar *buffer,
+static void blitSrcOver(VRle::Span *spans, int count, uint8_t *buffer,
int offsetX)
{
while (count--) {
int x = spans->x + offsetX;
int l = spans->len;
- uchar *ptr = buffer + x;
+ uint8_t *ptr = buffer + x;
while (l--) {
*ptr = spans->coverage + divBy255((255 - spans->coverage) * (*ptr));
ptr++;
}
}
-void blitSrc(VRle::Span *spans, int count, uchar *buffer, int offsetX)
+void blitSrc(VRle::Span *spans, int count, uint8_t *buffer, int offsetX)
{
while (count--) {
int x = spans->x + offsetX;
int l = spans->len;
- uchar *ptr = buffer + x;
+ uint8_t *ptr = buffer + x;
while (l--) {
*ptr = std::max(spans->coverage, *ptr);
ptr++;
}
}
-size_t bufferToRle(uchar *buffer, int size, int offsetX, int y, VRle::Span *out)
+size_t bufferToRle(uint8_t *buffer, int size, int offsetX, int y,
+ VRle::Span *out)
{
size_t count = 0;
- uchar value = buffer[0];
+ uint8_t value = buffer[0];
int curIndex = 0;
// size = offsetX < 0 ? size + offsetX : size;
for (int i = 0; i < size; i++) {
- uchar curValue = buffer[0];
+ uint8_t curValue = buffer[0];
if (value != curValue) {
if (value) {
out->y = y;
break;
}
}
- using blitter = void (*)(VRle::Span *, int, uchar *, int);
+ using blitter = void (*)(VRle::Span *, int, uint8_t *, int);
blitter _blitter;
std::array<VRle::Span, 256> _result;
- std::array<uchar, 1024> _buffer;
+ std::array<uint8_t, 1024> _buffer;
VRle::Span * _aStart{nullptr};
VRle::Span * _bStart{nullptr};
struct Span {
short x{0};
short y{0};
- ushort len{0};
- uchar coverage{0};
+ uint16_t len{0};
+ uint8_t coverage{0};
};
using VRleSpanCb = void (*)(size_t count, const VRle::Span *spans,
void *userData);
void reset() { d.write().reset(); }
void translate(const VPoint &p) { d.write().translate(p); }
- void operator*=(uchar alpha) { d.write() *= alpha; }
+ void operator*=(uint8_t alpha) { d.write() *= alpha; }
void intersect(const VRect &r, VRleSpanCb cb, void *userData) const;
void intersect(const VRle &rle, VRleSpanCb cb, void *userData) const;
void setBbox(const VRect &bbox) const;
void reset();
void translate(const VPoint &p);
- void operator*=(uchar alpha);
+ void operator*=(uint8_t alpha);
void opGeneric(const VRle::Data &, const VRle::Data &, Op code);
void opSubstract(const VRle::Data &, const VRle::Data &);
void opIntersect(VRle::View a, VRle::View b);