sw_engine math: fix regression bug.

There is 1 pixel misaligned issue observed.
Found out transform() increases 0.5 pt always.

This transform() logic was broken by this change - e00f948705
and now recorvered to origin.
This commit is contained in:
Hermet Park 2020-12-03 18:26:21 +09:00
parent af8c278c5e
commit ee1522a446
2 changed files with 14 additions and 11 deletions

View file

@ -273,6 +273,7 @@ SwFixed mathDiff(SwFixed angle1, SwFixed angle2);
SwFixed mathLength(SwPoint& pt);
bool mathSmallCubic(SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
SwFixed mathMean(SwFixed angle1, SwFixed angle2);
SwPoint mathTransform(const Point* to, const Matrix* transform);
void shapeReset(SwShape* shape);
bool shapeGenOutline(SwShape* shape, const Shape* sdata, unsigned tid, const Matrix* transform);
@ -353,14 +354,4 @@ static inline void rasterRGBA32(uint32_t *dst, uint32_t val, uint32_t offset, in
#endif
}
static inline SwPoint mathTransform(const Point* to, const Matrix* transform)
{
if (!transform) return {TO_SWCOORD(to->x), TO_SWCOORD(to->y)};
auto tx = ((to->x * transform->e11 + to->y * transform->e12 + transform->e13) + 0.5f);
auto ty = ((to->x * transform->e21 + to->y * transform->e22 + transform->e23) + 0.5f);
return {TO_SWCOORD(tx), TO_SWCOORD(ty)};
}
#endif /* _TVG_SW_COMMON_H_ */

View file

@ -19,6 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <math.h>
#include "tvgSwCommon.h"
@ -414,4 +415,15 @@ SwFixed mathDiff(SwFixed angle1, SwFixed angle2)
if (delta > SW_ANGLE_PI) delta -= SW_ANGLE_2PI;
return delta;
}
}
SwPoint mathTransform(const Point* to, const Matrix* transform)
{
if (!transform) return {TO_SWCOORD(to->x), TO_SWCOORD(to->y)};
auto tx = round(to->x * transform->e11 + to->y * transform->e12 + transform->e13);
auto ty = round(to->x * transform->e21 + to->y * transform->e22 + transform->e23);
return {TO_SWCOORD(tx), TO_SWCOORD(ty)};
}