mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
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:
parent
af8c278c5e
commit
ee1522a446
2 changed files with 14 additions and 11 deletions
|
@ -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_ */
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
||||
|
@ -415,3 +416,14 @@ SwFixed mathDiff(SwFixed angle1, SwFixed angle2)
|
|||
|
||||
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)};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue