| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 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. |
| 13 | * |
| 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 |
| 17 | */ |
| 18 |
| 19 | #ifndef VDRAWABLE_H |
| 20 | #define VDRAWABLE_H |
| 21 | #include <future> |
| 22 | #include "vbrush.h" |
| 23 | #include "vpath.h" |
| 24 | #include "vrle.h" |
| 25 | #include "vraster.h" |
| 26 |
| 27 | class VDrawable { |
| 28 | public: |
| 29 | enum class DirtyState { |
| 30 | None = 0x00000000, |
| 31 | Path = 0x00000001, |
| 32 | Stroke = 0x00000010, |
| 33 | Brush = 0x00000100, |
| 34 | All = (None | Path | Stroke | Brush) |
| 35 | }; |
| 36 | enum class Type : unsigned char{ |
| 37 | Fill, |
| 38 | Stroke, |
| 39 | }; |
| 40 | typedef vFlag<DirtyState> DirtyFlag; |
| 41 | void setPath(const VPath &path); |
| 42 | void setFillRule(FillRule rule) { mFillRule = rule; } |
| 43 | void setBrush(const VBrush &brush) { mBrush = brush; } |
| 44 | void setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit, |
| 45 | float strokeWidth); |
| 46 | void setDashInfo(float *array, uint size); |
| 47 | void preprocess(const VRect &clip); |
| 48 | VRle rle(); |
| 49 |
| 50 | public: |
| 51 | struct StrokeInfo { |
| 52 | std::vector<float> mDash; |
| 53 | float width{0.0}; |
| 54 | float meterLimit{10}; |
| 55 | bool enable{false}; |
| 56 | CapStyle cap{CapStyle::Flat}; |
| 57 | JoinStyle join{JoinStyle::Bevel}; |
| 58 | }; |
| 59 | VRasterizer mRasterizer; |
| 60 | VBrush mBrush; |
| 61 | VPath mPath; |
| 62 | StrokeInfo mStroke; |
| 63 | DirtyFlag mFlag{DirtyState::All}; |
| 64 | FillRule mFillRule{FillRule::Winding}; |
| 65 | VDrawable::Type mType{Type::Fill}; |
| 66 | }; |
| 67 |
| 68 | #endif // VDRAWABLE_H |
| 69 |