lottie/render: Implement drawRle() with position information.

Change-Id: Ia5bbcf911baaaa4b684045a6ac28c4dcfc14f841
This commit is contained in:
subhransu mohanty
2018-08-06 10:19:57 +09:00
parent 296534e3c0
commit 92c363da42
3 changed files with 24 additions and 14 deletions

View File

@@ -496,8 +496,7 @@ static void blendColorARGB(int count, const VRle::Span *spans, void *userData)
if (op.mode == VPainter::CompModeSrc) {
// inline for performance
while (count--) {
uint *target =
((uint *)data->mRasterBuffer->scanLine(spans->y)) + spans->x;
uint *target = data->buffer(spans->x, spans->y);
if (spans->coverage == 255) {
memfill32(target, color, spans->len);
} else {
@@ -512,8 +511,7 @@ static void blendColorARGB(int count, const VRle::Span *spans, void *userData)
}
while (count--) {
uint *target =
((uint *)data->mRasterBuffer->scanLine(spans->y)) + spans->x;
uint *target = data->buffer(spans->x, spans->y);
op.funcSolid(target, spans->len, color, spans->coverage);
++spans;
}
@@ -531,9 +529,8 @@ static void blendGradientARGB(int count, const VRle::Span *spans,
if (!op.srcFetch) return;
while (count--) {
uint *target =
((uint *)data->mRasterBuffer->scanLine(spans->y)) + spans->x;
int length = spans->len;
uint *target = data->buffer(spans->x, spans->y);
int length = spans->len;
while (length) {
int l = std::min(length, BLEND_GRADIENT_BUFFER_SIZE);
op.srcFetch(buffer, &op, data, spans->y, spans->x, l);

View File

@@ -111,12 +111,22 @@ struct VSpanData {
};
enum class Type { None, Solid, LinearGradient, RadialGradient };
void updateSpanFunc();
void init(VRasterBuffer *image);
void setup(const VBrush & brush,
VPainter::CompositionMode mode = VPainter::CompModeSrcOver,
int alpha = 255);
void setupMatrix(const VMatrix &matrix);
void updateSpanFunc();
void init(VRasterBuffer *image);
void setup(const VBrush & brush,
VPainter::CompositionMode mode = VPainter::CompModeSrcOver,
int alpha = 255);
void setupMatrix(const VMatrix &matrix);
void setPos(const VPoint &pos) { mPos = pos; }
VRect clipRect() const
{
return mSystemClip.translated(-mPos.x(), -mPos.y());
}
uint *buffer(int x, int y) const
{
return (uint *)(mRasterBuffer->scanLine(y + mPos.y())) + x + mPos.x();
}
VRasterBuffer * mRasterBuffer;
ProcessRleSpan mBlendFunc;
@@ -124,6 +134,7 @@ struct VSpanData {
VRect mSystemClip;
VSpanData::Type mType;
std::shared_ptr<VSpanData::Pinnable> mCachedGradient;
VPoint mPos;
union {
uint32_t mSolid;
VGradientData mGradient;

View File

@@ -19,8 +19,10 @@ void VPainterImpl::drawRle(const VPoint &pos, const VRle &rle)
if (!mSpanData.mUnclippedBlendFunc) return;
mSpanData.setPos(pos);
// do draw after applying clip.
rle.intersect(mSpanData.mSystemClip, mSpanData.mUnclippedBlendFunc,
rle.intersect(mSpanData.clipRect(), mSpanData.mUnclippedBlendFunc,
&mSpanData);
}