renderer: code clean up

This commit is contained in:
Hermet Park 2024-06-08 00:15:43 +09:00
parent b5b6a5c527
commit 3b821c33cc
4 changed files with 26 additions and 44 deletions

View file

@ -26,18 +26,6 @@
#include "tvgCommon.h"
#include "tvgRender.h"
#include <algorithm>
#if 0
#include <sys/time.h>
static double timeStamp()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec + tv.tv_usec / 1000000.0);
}
#endif
#define SW_CURVE_TYPE_POINT 0
#define SW_CURVE_TYPE_CUBIC 1
#define SW_ANGLE_PI (180L << 16)

View file

@ -34,14 +34,6 @@ struct AASpans
int32_t yEnd;
};
static inline void _swap(float& a, float& b, float& tmp)
{
tmp = a;
a = b;
b = tmp;
}
//Careful! Shared resource, No support threading
static float dudx, dvdx;
static float dxdya, dxdyb, dudya, dvdya;
@ -650,28 +642,27 @@ static void _rasterPolygonImage(SwSurface* surface, const SwImage* image, const
float off_y;
float dxdy[3] = {0.0f, 0.0f, 0.0f};
float tmp;
auto upper = false;
//Sort the vertices in ascending Y order
if (y[0] > y[1]) {
_swap(x[0], x[1], tmp);
_swap(y[0], y[1], tmp);
_swap(u[0], u[1], tmp);
_swap(v[0], v[1], tmp);
std::swap(x[0], x[1]);
std::swap(y[0], y[1]);
std::swap(u[0], u[1]);
std::swap(v[0], v[1]);
}
if (y[0] > y[2]) {
_swap(x[0], x[2], tmp);
_swap(y[0], y[2], tmp);
_swap(u[0], u[2], tmp);
_swap(v[0], v[2], tmp);
std::swap(x[0], x[2]);
std::swap(y[0], y[2]);
std::swap(u[0], u[2]);
std::swap(v[0], v[2]);
}
if (y[1] > y[2]) {
_swap(x[1], x[2], tmp);
_swap(y[1], y[2], tmp);
_swap(u[1], u[2], tmp);
_swap(v[1], v[2], tmp);
std::swap(x[1], x[2]);
std::swap(y[1], y[2]);
std::swap(u[1], u[2]);
std::swap(v[1], v[2]);
}
//Y indexes

View file

@ -87,4 +87,16 @@ uint16_t THORVG_VERSION_NUMBER();
#define P(A) ((A)->pImpl) //Access to pimpl.
#define PP(A) (((Paint*)(A))->pImpl) //Access to pimpl.
//for debugging
#if 0
#include <sys/time.h>
static inline double THORVG_TIMESTAMP()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec + tv.tv_usec / 1000000.0);
}
#endif
#endif //_TVG_COMMON_H_

View file

@ -85,17 +85,8 @@ static Result _compFastTrack(Paint* cmpTarget, const RenderTransform* pTransform
}
//sorting
if (v1.x > v2.x) {
auto tmp = v2.x;
v2.x = v1.x;
v1.x = tmp;
}
if (v1.y > v2.y) {
auto tmp = v2.y;
v2.y = v1.y;
v1.y = tmp;
}
if (v1.x > v2.x) std::swap(v1.x, v2.x);
if (v1.y > v2.y) std::swap(v1.y, v2.y);
viewport.x = static_cast<int32_t>(v1.x);
viewport.y = static_cast<int32_t>(v1.y);