VBrush brush(color);
drawable->setBrush(brush);
-
+ float scale = getScale(mParentMatrix);
drawable->setStrokeInfo(mCap, mJoin, mMiterLimit,
- mWidth * getScale(mParentMatrix));
+ mWidth * scale);
if (mDashArraySize) {
+ for (int i = 0 ; i < mDashArraySize ; i++)
+ mDashArray[i] *= scale;
drawable->setDashInfo(mDashArray, mDashArraySize);
}
}
void LOTGStrokeItem::updateRenderNode(LOTPathDataItem *pathNode,
VDrawable *drawable, bool sameParent)
{
+ float scale = getScale(mParentMatrix);
drawable->setBrush(VBrush(mGradient.get()));
drawable->setStrokeInfo(mCap, mJoin, mMiterLimit,
- mWidth * getScale(mParentMatrix));
+ mWidth * scale);
if (mDashArraySize) {
+ for (int i = 0 ; i < mDashArraySize ; i++)
+ mDashArray[i] *= scale;
drawable->setDashInfo(mDashArray, mDashArraySize);
}
}
break;
}
- mCNode.mStroke.dashArray = mStroke.dashArray;
- mCNode.mStroke.dashArraySize = mStroke.dashArraySize;
+ mCNode.mStroke.dashArray = mStroke.mDash.data();
+ mCNode.mStroke.dashArraySize = mStroke.mDash.size();
} else {
mCNode.mStroke.enable = 0;
{
if (mFlag & (DirtyState::Path)) {
if (mStroke.enable) {
- if (mStroke.dashArraySize) {
- VDasher dasher(mStroke.dashArray, mStroke.dashArraySize);
+ if (mStroke.mDash.size()) {
+ VDasher dasher(mStroke.mDash.data(), mStroke.mDash.size());
mPath = dasher.dashed(mPath);
}
mRleTask = VRaster::instance().generateStrokeInfo(
- std::move(mPath), std::move(mRle), mStroke.cap, mStroke.join, mStroke.width,
- mStroke.meterLimit);
+ std::move(mPath), std::move(mRle), mStroke.cap, mStroke.join,
+ mStroke.width, mStroke.meterLimit);
} else {
- mRleTask = VRaster::instance().generateFillInfo(std::move(mPath), std::move(mRle), mFillRule);
+ mRleTask = VRaster::instance().generateFillInfo(
+ std::move(mPath), std::move(mRle), mFillRule);
}
mFlag &= ~DirtyFlag(DirtyState::Path);
}
float strokeWidth)
{
if ((mStroke.cap == cap) && (mStroke.join == join) &&
- vCompare(mStroke.meterLimit, meterLimit) && vCompare(mStroke.width, strokeWidth))
+ vCompare(mStroke.meterLimit, meterLimit) &&
+ vCompare(mStroke.width, strokeWidth))
return;
mStroke.enable = true;
mFlag |= DirtyState::Path;
}
-void VDrawable::setDashInfo(float *array, int size)
+void VDrawable::setDashInfo(float *array, uint size)
{
bool hasChanged = false;
- if (mStroke.dashArraySize == size) {
- for (int i = 0; i < size; i++) {
- if (!vCompare(mStroke.dashArray[i], array[i])) {
+ if (mStroke.mDash.size() == size) {
+ for (uint i = 0; i < size; i++) {
+ if (!vCompare(mStroke.mDash[i], array[i])) {
hasChanged = true;
break;
}
if (!hasChanged) return;
- mStroke.dashArray = array;
- mStroke.dashArraySize = size;
+ mStroke.mDash.clear();
+
+ for (uint i = 0; i < size; i++) {
+ mStroke.mDash.push_back(array[i]);
+ }
mFlag |= DirtyState::Path;
}
void setBrush(const VBrush &brush) { mBrush = brush; }
void setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
float strokeWidth);
- void setDashInfo(float *array, int size);
+ void setDashInfo(float *array, uint size);
void preprocess();
VRle rle();
public:
+ struct StrokeInfo {
+ bool enable{false};
+ float width{0.0};
+ CapStyle cap{CapStyle::Flat};
+ JoinStyle join{JoinStyle::Bevel};
+ float meterLimit{10};
+ std::vector<float> mDash;
+ };
DirtyFlag mFlag{DirtyState::All};
VDrawable::Type mType{Type::Fill};
VBrush mBrush;
FillRule mFillRule{FillRule::Winding};
std::future<VRle> mRleTask;
VRle mRle;
- struct {
- bool enable{false};
- float width{0.0};
- CapStyle cap{CapStyle::Flat};
- JoinStyle join{JoinStyle::Bevel};
- float meterLimit{10};
- float * dashArray{nullptr};
- int dashArraySize{0};
- } mStroke;
+ StrokeInfo mStroke;
};
#endif // VDRAWABLE_H