Updated skia
This commit is contained in:
parent
720081c3bb
commit
f6961fbf8d
19 changed files with 105 additions and 89 deletions
|
|
@ -113,13 +113,17 @@ void DrawBrushStroke::initialize_draw_data(DrawingProgram& drawP) {
|
|||
return false;
|
||||
};
|
||||
|
||||
brushPath = std::make_shared<SkPath>();
|
||||
brushPathLOD[0] = std::make_shared<SkPath>();
|
||||
brushPathLOD[1] = std::make_shared<SkPath>();
|
||||
auto brushPathBuilder = std::make_shared<SkPathBuilder>();
|
||||
auto brushPathLOD0Builder = std::make_shared<SkPathBuilder>();
|
||||
auto brushPathLOD1Builder = std::make_shared<SkPathBuilder>();
|
||||
|
||||
create_triangles(triangleFunc, points, 0, brushPath);
|
||||
create_triangles(triangleFunc, points, 4, brushPathLOD[0]);
|
||||
create_triangles(triangleFunc, points, 30, brushPathLOD[1]);
|
||||
create_triangles(triangleFunc, points, 0, brushPathBuilder);
|
||||
create_triangles(triangleFunc, points, 4, brushPathLOD0Builder);
|
||||
create_triangles(triangleFunc, points, 30, brushPathLOD1Builder);
|
||||
|
||||
brushPath = std::make_shared<SkPath>(brushPathBuilder->detach());
|
||||
brushPathLOD[0] = std::make_shared<SkPath>(brushPathLOD0Builder->detach());
|
||||
brushPathLOD[1] = std::make_shared<SkPath>(brushPathLOD1Builder->detach());
|
||||
}
|
||||
create_collider();
|
||||
}
|
||||
|
|
@ -223,7 +227,7 @@ std::vector<DrawBrushStrokePoint> DrawBrushStroke::every_nth_point_include_front
|
|||
return toRet;
|
||||
}
|
||||
|
||||
void DrawBrushStroke::create_triangles(const std::function<bool(Vector2f, Vector2f, Vector2f)>& passTriangleFunc, const std::vector<DrawBrushStrokePoint>& smoothedPoints, size_t skipVertexCount, std::shared_ptr<SkPath> bPath) {
|
||||
void DrawBrushStroke::create_triangles(const std::function<bool(Vector2f, Vector2f, Vector2f)>& passTriangleFunc, const std::vector<DrawBrushStrokePoint>& smoothedPoints, size_t skipVertexCount, std::shared_ptr<SkPathBuilder> bPathBuilder) {
|
||||
const int ARC_SMOOTHNESS = 10;
|
||||
const int CIRCLE_SMOOTHNESS = 20;
|
||||
const std::vector<DrawBrushStrokePoint>& pointsN = d->points;
|
||||
|
|
@ -239,8 +243,8 @@ void DrawBrushStroke::create_triangles(const std::function<bool(Vector2f, Vector
|
|||
}
|
||||
|
||||
if(pointsN.size() < 2) {
|
||||
if(bPath && !topPoints.empty())
|
||||
bPath->addPoly({topPoints.data(), topPoints.size()}, false);
|
||||
if(bPathBuilder && !topPoints.empty())
|
||||
bPathBuilder->addPolygon({topPoints.data(), topPoints.size()}, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -387,9 +391,9 @@ void DrawBrushStroke::create_triangles(const std::function<bool(Vector2f, Vector
|
|||
}
|
||||
}
|
||||
|
||||
if(bPath && !topPoints.empty()) {
|
||||
if(bPathBuilder && !topPoints.empty()) {
|
||||
topPoints.insert(topPoints.begin(), bottomPoints.rbegin(), bottomPoints.rend());
|
||||
bPath->addPoly({topPoints.data(), topPoints.size()}, false);
|
||||
bPathBuilder->addPolygon({topPoints.data(), topPoints.size()}, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#ifndef IS_SERVER
|
||||
#include <include/core/SkPath.h>
|
||||
#include <include/core/SkPathBuilder.h>
|
||||
#endif
|
||||
|
||||
#define DRAW_MINIMUM_LIMIT 0.3
|
||||
|
|
@ -57,7 +58,7 @@ class DrawBrushStroke : public DrawComponent {
|
|||
|
||||
void add_precheck_aabb_level(size_t level, const std::vector<SCollision::BVHContainer<float>>& levelArray);
|
||||
std::vector<SCollision::AABB<float>> precheckAABBLevels;
|
||||
void create_triangles(const std::function<bool(Vector2f, Vector2f, Vector2f)>& passTriangleFunc, const std::vector<DrawBrushStrokePoint>& smoothedPoints, size_t skipVertexCount, std::shared_ptr<SkPath> bPath);
|
||||
void create_triangles(const std::function<bool(Vector2f, Vector2f, Vector2f)>& passTriangleFunc, const std::vector<DrawBrushStrokePoint>& smoothedPoints, size_t skipVertexCount, std::shared_ptr<SkPathBuilder> bPath);
|
||||
std::vector<size_t> get_wedge_indices(const std::vector<DrawBrushStrokePoint>& points);
|
||||
std::vector<DrawBrushStrokePoint> smooth_points(size_t beginIndex, size_t endIndex, unsigned numOfDivisions);
|
||||
std::vector<DrawBrushStrokePoint> smooth_points_avg(size_t beginIndex, size_t endIndex, unsigned numOfDivisions);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "DrawEllipse.hpp"
|
||||
#include "Helpers/ConvertVec.hpp"
|
||||
#include "Helpers/SCollision.hpp"
|
||||
#include <include/core/SkPathBuilder.h>
|
||||
|
||||
#ifndef IS_SERVER
|
||||
#include "../DrawCollision.hpp"
|
||||
|
|
@ -70,9 +71,10 @@ void DrawEllipse::draw(SkCanvas* canvas, const DrawData& drawData) {
|
|||
}
|
||||
|
||||
void DrawEllipse::create_draw_data() {
|
||||
ellipsePath = SkPath();
|
||||
SkPathBuilder ellipsePathBuilder;
|
||||
SkRect newRect = SkRect::MakeLTRB(d.p1.x(), d.p1.y(), d.p2.x(), d.p2.y());
|
||||
ellipsePath.addOval(newRect);
|
||||
ellipsePathBuilder.addOval(newRect);
|
||||
ellipsePath = ellipsePathBuilder.detach();
|
||||
}
|
||||
|
||||
void DrawEllipse::initialize_draw_data(DrawingProgram& drawP) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "Helpers/MathExtras.hpp"
|
||||
#include "Helpers/SCollision.hpp"
|
||||
#include <include/core/SkPaint.h>
|
||||
#include <include/core/SkPathBuilder.h>
|
||||
#include "../SharedTypes.hpp"
|
||||
|
||||
#ifndef IS_SERVER
|
||||
|
|
@ -87,14 +88,16 @@ bool DrawRectangle::collides_within_coords(const SCollision::ColliderCollection<
|
|||
}
|
||||
|
||||
void DrawRectangle::create_draw_data() {
|
||||
rectPath = SkPath();
|
||||
SkPathBuilder rectPathBuilder;
|
||||
if(d.p1.x() == d.p2.x() || d.p1.y() == d.p2.y()) {
|
||||
rectPath.moveTo(convert_vec2<SkPoint>(d.p1));
|
||||
rectPath.lineTo(convert_vec2<SkPoint>(d.p2));
|
||||
rectPathBuilder.moveTo(convert_vec2<SkPoint>(d.p1));
|
||||
rectPathBuilder.lineTo(convert_vec2<SkPoint>(d.p2));
|
||||
rectPath = rectPathBuilder.detach();
|
||||
}
|
||||
else {
|
||||
SkRect newRect = SkRect::MakeLTRB(d.p1.x(), d.p1.y(), d.p2.x(), d.p2.y());
|
||||
rectPath.addRoundRect(newRect, d.cornerRadius, d.cornerRadius);
|
||||
SkRRect newRect = SkRRect::MakeRectXY(SkRect::MakeLTRB(d.p1.x(), d.p1.y(), d.p2.x(), d.p2.y()), d.cornerRadius, d.cornerRadius);
|
||||
rectPathBuilder.addRRect(newRect);
|
||||
rectPath = rectPathBuilder.detach();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue