2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "vdrawable.h"
23 void VDrawable::preprocess(const VRect &clip)
25 if (mFlag & (DirtyState::Path)) {
27 if (!mRleFuture) mRleFuture = std::make_shared<VSharedState<VRle>>();
32 if (mStroke.mDash.size()) {
33 VDasher dasher(mStroke.mDash.data(), mStroke.mDash.size());
34 mPath = dasher.dashed(mPath);
36 VRaster::generateStrokeInfo(mRleFuture,
37 std::move(mPath), std::move(mRle), mStroke.cap, mStroke.join,
38 mStroke.width, mStroke.meterLimit, clip);
40 VRaster::generateFillInfo(mRleFuture,
41 std::move(mPath), std::move(mRle), mFillRule, clip);
44 mFlag &= ~DirtyFlag(DirtyState::Path);
50 if (mRleFuture && mRleFuture->valid()) {
51 mRle = mRleFuture->get();
56 void VDrawable::setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
59 if ((mStroke.cap == cap) && (mStroke.join == join) &&
60 vCompare(mStroke.meterLimit, meterLimit) &&
61 vCompare(mStroke.width, strokeWidth))
64 mStroke.enable = true;
67 mStroke.meterLimit = meterLimit;
68 mStroke.width = strokeWidth;
69 mFlag |= DirtyState::Path;
72 void VDrawable::setDashInfo(float *array, uint size)
74 bool hasChanged = false;
76 if (mStroke.mDash.size() == size) {
77 for (uint i = 0; i < size; i++) {
78 if (!vCompare(mStroke.mDash[i], array[i])) {
87 if (!hasChanged) return;
89 mStroke.mDash.clear();
91 for (uint i = 0; i < size; i++) {
92 mStroke.mDash.push_back(array[i]);
94 mFlag |= DirtyState::Path;
97 void VDrawable::setPath(const VPath &path)
100 mFlag |= DirtyState::Path;