mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-20 23:11:39 +00:00
gl_engine: remove the outdated tesseletion mechanics
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
After introducing Triangle Fan-like Triangulation there is no necessary to have heavy and complex tessellator All unused entities are removed
This commit is contained in:
parent
3426531dd2
commit
2c048f72e8
7 changed files with 33 additions and 1591 deletions
|
@ -186,35 +186,10 @@ struct Array
|
||||||
return count == reserved;
|
return count == reserved;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class COMPARE> void sort()
|
|
||||||
{
|
|
||||||
qsort<COMPARE>(data, 0, (int32_t)(count - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
~Array()
|
~Array()
|
||||||
{
|
{
|
||||||
tvg::free(data);
|
tvg::free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
template<class COMPARE>
|
|
||||||
void qsort(T* arr, int32_t low, int32_t high)
|
|
||||||
{
|
|
||||||
if (low < high) {
|
|
||||||
auto i = low;
|
|
||||||
auto j = high;
|
|
||||||
auto tmp = arr[low];
|
|
||||||
while (i < j) {
|
|
||||||
while (i < j && !COMPARE{}(arr[j], tmp)) --j;
|
|
||||||
if (i < j) arr[i++] = arr[j];
|
|
||||||
while (i < j && COMPARE{}(arr[i], tmp)) ++i;
|
|
||||||
if (i < j) arr[j--] = arr[i];
|
|
||||||
}
|
|
||||||
arr[i] = tmp;
|
|
||||||
qsort<COMPARE>(arr, low, i - 1);
|
|
||||||
qsort<COMPARE>(arr, i + 1, high);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ source_file = [
|
||||||
'tvgGl.h',
|
'tvgGl.h',
|
||||||
'tvgGlCommon.h',
|
'tvgGlCommon.h',
|
||||||
'tvgGlGpuBuffer.h',
|
'tvgGlGpuBuffer.h',
|
||||||
'tvgGlList.h',
|
|
||||||
'tvgGlProgram.h',
|
'tvgGlProgram.h',
|
||||||
'tvgGlRenderer.h',
|
'tvgGlRenderer.h',
|
||||||
'tvgGlRenderPass.h',
|
'tvgGlRenderPass.h',
|
||||||
|
|
|
@ -23,31 +23,29 @@
|
||||||
#ifndef _TVG_GL_COMMON_H_
|
#ifndef _TVG_GL_COMMON_H_
|
||||||
#define _TVG_GL_COMMON_H_
|
#define _TVG_GL_COMMON_H_
|
||||||
|
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#include "tvgGl.h"
|
#include "tvgGl.h"
|
||||||
#include "tvgRender.h"
|
#include "tvgRender.h"
|
||||||
#include "tvgMath.h"
|
#include "tvgMath.h"
|
||||||
|
|
||||||
#define MIN_GL_STROKE_WIDTH 1.0f
|
#define MIN_GL_STROKE_WIDTH 1.0f
|
||||||
|
|
||||||
#define MVP_MATRIX(w, h) \
|
#define MVP_MATRIX(w, h) \
|
||||||
float mvp[4*4] = { \
|
float mvp[4*4] = { \
|
||||||
2.f / w, 0.0, 0.0f, 0.0f, \
|
2.f / w, 0.0, 0.0f, 0.0f, \
|
||||||
0.0, -2.f / h, 0.0f, 0.0f, \
|
0.0, -2.f / h, 0.0f, 0.0f, \
|
||||||
0.0f, 0.0f, -1.f, 0.0f, \
|
0.0f, 0.0f, -1.0f, 0.0f, \
|
||||||
-1.f, 1.f, 0.0f, 1.0f \
|
-1.f, 1.f, 0.0f, 1.0f \
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MULTIPLY_MATRIX(A, B, transform) \
|
#define MULTIPLY_MATRIX(A, B, transform) \
|
||||||
for(auto i = 0; i < 4; ++i) \
|
for(auto i = 0; i < 4; ++i) { \
|
||||||
{ \
|
for(auto j = 0; j < 4; ++j) { \
|
||||||
for(auto j = 0; j < 4; ++j) \
|
float sum = 0.0; \
|
||||||
{ \
|
for (auto k = 0; k < 4; ++k) \
|
||||||
float sum = 0.0; \
|
|
||||||
for (auto k = 0; k < 4; ++k) \
|
|
||||||
sum += A[k*4+i] * B[j*4+k]; \
|
sum += A[k*4+i] * B[j*4+k]; \
|
||||||
transform[j*4+i] = sum; \
|
transform[j*4+i] = sum; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,24 +59,24 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// All GPU use 4x4 matrix with column major order
|
// All GPU use 4x4 matrix with column major order
|
||||||
#define GET_MATRIX44(mat3, mat4) \
|
#define GET_MATRIX44(mat3, mat4) \
|
||||||
do { \
|
do { \
|
||||||
mat4[0] = mat3.e11; \
|
mat4[0] = mat3.e11; \
|
||||||
mat4[1] = mat3.e21; \
|
mat4[1] = mat3.e21; \
|
||||||
mat4[2] = 0; \
|
mat4[2] = 0; \
|
||||||
mat4[3] = mat3.e31; \
|
mat4[3] = mat3.e31; \
|
||||||
mat4[4] = mat3.e12; \
|
mat4[4] = mat3.e12; \
|
||||||
mat4[5] = mat3.e22; \
|
mat4[5] = mat3.e22; \
|
||||||
mat4[6] = 0; \
|
mat4[6] = 0; \
|
||||||
mat4[7] = mat3.e32; \
|
mat4[7] = mat3.e32; \
|
||||||
mat4[8] = 0; \
|
mat4[8] = 0; \
|
||||||
mat4[9] = 0; \
|
mat4[9] = 0; \
|
||||||
mat4[10] = 1; \
|
mat4[10] = 1; \
|
||||||
mat4[11] = 0; \
|
mat4[11] = 0; \
|
||||||
mat4[12] = mat3.e13; \
|
mat4[12] = mat3.e13; \
|
||||||
mat4[13] = mat3.e23; \
|
mat4[13] = mat3.e23; \
|
||||||
mat4[14] = 0; \
|
mat4[14] = 0; \
|
||||||
mat4[15] = mat3.e33; \
|
mat4[15] = mat3.e33; \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,7 +113,6 @@ struct GlGeometry
|
||||||
{
|
{
|
||||||
bool tesselate(const RenderShape& rshape, RenderUpdateFlag flag);
|
bool tesselate(const RenderShape& rshape, RenderUpdateFlag flag);
|
||||||
bool tesselate(const RenderSurface* image, RenderUpdateFlag flag);
|
bool tesselate(const RenderSurface* image, RenderUpdateFlag flag);
|
||||||
void disableVertex(uint32_t location);
|
|
||||||
bool draw(GlRenderTask* task, GlStageBuffer* gpuBuffer, RenderUpdateFlag flag);
|
bool draw(GlRenderTask* task, GlStageBuffer* gpuBuffer, RenderUpdateFlag flag);
|
||||||
GlStencilMode getStencilMode(RenderUpdateFlag flag);
|
GlStencilMode getStencilMode(RenderUpdateFlag flag);
|
||||||
RenderRegion getBounds() const;
|
RenderRegion getBounds() const;
|
||||||
|
|
|
@ -108,12 +108,6 @@ bool GlGeometry::tesselate(const RenderSurface* image, RenderUpdateFlag flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GlGeometry::disableVertex(uint32_t location)
|
|
||||||
{
|
|
||||||
GL_CHECK(glDisableVertexAttribArray(location));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GlGeometry::draw(GlRenderTask* task, GlStageBuffer* gpuBuffer, RenderUpdateFlag flag)
|
bool GlGeometry::draw(GlRenderTask* task, GlStageBuffer* gpuBuffer, RenderUpdateFlag flag)
|
||||||
{
|
{
|
||||||
if (flag == RenderUpdateFlag::None) return false;
|
if (flag == RenderUpdateFlag::None) return false;
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2023 - 2025 the ThorVG project. All rights reserved.
|
|
||||||
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TVG_LIST_H_
|
|
||||||
#define _TVG_LIST_H_
|
|
||||||
|
|
||||||
namespace tvg {
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct LinkedList
|
|
||||||
{
|
|
||||||
T *head = nullptr;
|
|
||||||
T *tail = nullptr;
|
|
||||||
|
|
||||||
LinkedList() = default;
|
|
||||||
LinkedList(T *head, T *tail) : head(head), tail(tail)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template<T *T::*Prev, T *T::*Next>
|
|
||||||
static void insert(T *t, T *prev, T *next, T **head, T **tail)
|
|
||||||
{
|
|
||||||
t->*Prev = prev;
|
|
||||||
t->*Next = next;
|
|
||||||
|
|
||||||
if (prev) {
|
|
||||||
prev->*Next = t;
|
|
||||||
} else if (head) {
|
|
||||||
*head = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next) {
|
|
||||||
next->*Prev = t;
|
|
||||||
} else if (tail) {
|
|
||||||
*tail = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<T *T::*Prev, T *T::*Next>
|
|
||||||
static void remove(T *t, T **head, T **tail)
|
|
||||||
{
|
|
||||||
if (t->*Prev) {
|
|
||||||
t->*Prev->*Next = t->*Next;
|
|
||||||
} else if (head) {
|
|
||||||
*head = t->*Next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t->*Next) {
|
|
||||||
t->*Next->*Prev = t->*Prev;
|
|
||||||
} else if (tail) {
|
|
||||||
*tail = t->*Prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
t->*Prev = t->*Next = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <T* T::*Next>
|
|
||||||
static bool contains(T *t, T **head, T **tail) {
|
|
||||||
for (T *it = *head; it; it = it->*Next) {
|
|
||||||
if (it == t) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // _TVG_LIST_H_
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,51 +23,11 @@
|
||||||
#ifndef _TVG_GL_TESSELLATOR_H_
|
#ifndef _TVG_GL_TESSELLATOR_H_
|
||||||
#define _TVG_GL_TESSELLATOR_H_
|
#define _TVG_GL_TESSELLATOR_H_
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include "tvgGlCommon.h"
|
#include "tvgGlCommon.h"
|
||||||
|
|
||||||
namespace tvg
|
namespace tvg
|
||||||
{
|
{
|
||||||
|
|
||||||
class ObjectHeap;
|
|
||||||
struct Vertex;
|
|
||||||
struct Edge;
|
|
||||||
struct Polygon;
|
|
||||||
struct MonotonePolygon;
|
|
||||||
struct VertexList;
|
|
||||||
struct ActiveEdgeList;
|
|
||||||
struct RenderShape;
|
|
||||||
|
|
||||||
class Tessellator final
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Tessellator(GlGeometryBuffer* buffer);
|
|
||||||
~Tessellator();
|
|
||||||
void tessellate(const Array<const RenderShape*> &shapes);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void visitShape(const RenderPath& path);
|
|
||||||
void buildMesh();
|
|
||||||
void mergeVertices();
|
|
||||||
bool simplifyMesh();
|
|
||||||
bool tessMesh();
|
|
||||||
bool matchFillRule(int32_t winding);
|
|
||||||
Edge *makeEdge(Vertex* p1, Vertex* p2);
|
|
||||||
bool checkIntersection(Edge* left, Edge* right, ActiveEdgeList* ael, Vertex** current);
|
|
||||||
bool splitEdge(Edge* edge, Vertex* v, ActiveEdgeList* ael, Vertex** current);
|
|
||||||
bool intersectPairEdge(Edge* left, Edge* right, ActiveEdgeList* ael, Vertex** current);
|
|
||||||
Polygon *makePoly(Vertex* v, int32_t winding);
|
|
||||||
void emitPoly(MonotonePolygon* poly);
|
|
||||||
void emitTriangle(Vertex* p1, Vertex* p2, Vertex* p3);
|
|
||||||
|
|
||||||
FillRule fillRule = FillRule::NonZero;
|
|
||||||
ObjectHeap* pHeap;
|
|
||||||
Array<VertexList*> outlines;
|
|
||||||
VertexList* pMesh;
|
|
||||||
Polygon* pPolygon;
|
|
||||||
GlGeometryBuffer* buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Stroker
|
class Stroker
|
||||||
{
|
{
|
||||||
struct State
|
struct State
|
||||||
|
@ -79,7 +39,6 @@ class Stroker
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
Stroker(GlGeometryBuffer* buffer, const Matrix& matrix);
|
Stroker(GlGeometryBuffer* buffer, const Matrix& matrix);
|
||||||
~Stroker() = default;
|
|
||||||
void stroke(const RenderShape *rshape, const RenderPath& path);
|
void stroke(const RenderShape *rshape, const RenderPath& path);
|
||||||
RenderRegion bounds() const;
|
RenderRegion bounds() const;
|
||||||
|
|
||||||
|
@ -147,7 +106,6 @@ class BWTessellator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BWTessellator(GlGeometryBuffer* buffer);
|
BWTessellator(GlGeometryBuffer* buffer);
|
||||||
~BWTessellator() = default;
|
|
||||||
void tessellate(const RenderPath& path, const Matrix& matrix);
|
void tessellate(const RenderPath& path, const Matrix& matrix);
|
||||||
RenderRegion bounds() const;
|
RenderRegion bounds() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue