mirror of https://github.com/GNOME/gimp.git
Minimal speedup by avoiding to do a inverse->inverse matrix calculation.
Use transform_core_do() for scaling too. This gives a consistent behaviour regarding the corrective transform and seems to be faster too... --Sven
This commit is contained in:
parent
7f0ea3f587
commit
e3c27c9751
|
@ -1,3 +1,12 @@
|
|||
Tue Nov 10 23:44:07 MET 1998 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimp/gimpmatrix.[ch]
|
||||
* app/transform_core.c: minimal speedup
|
||||
|
||||
* app/scale_tool.c: Use transform_core_do() for scaling too.
|
||||
This gives a consistent behaviour regarding the corrective transform
|
||||
and seems to be faster anyway...
|
||||
|
||||
Mon Nov 9 16:20:33 MET 1998 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/session.c: use gdk_window_get_root_origin to get the window
|
||||
|
|
|
@ -335,8 +335,7 @@ scale_tool_motion (tool, gdisp_ptr)
|
|||
if (*y1 <= *y2) *y1 = *y2 + 1;
|
||||
}
|
||||
|
||||
/* if both the control key & shift keys are down, keep the aspect ratio intac
|
||||
t */
|
||||
/* if both the control key & shift keys are down, keep the aspect ratio intact */
|
||||
if (transform_core->state & GDK_CONTROL_MASK && transform_core->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
ratio = (double) (transform_core->x2 - transform_core->x1) /
|
||||
|
@ -432,35 +431,7 @@ scale_tool_scale (gimage, drawable, trans_info, float_tiles, interpolation, matr
|
|||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
TileManager *new_tiles;
|
||||
int x1, y1, x2, y2;
|
||||
PixelRegion srcPR, destPR;
|
||||
|
||||
x1 = trans_info[X1];
|
||||
y1 = trans_info[Y1];
|
||||
x2 = trans_info[X2];
|
||||
y2 = trans_info[Y2];
|
||||
|
||||
pixel_region_init (&srcPR, float_tiles, 0, 0,
|
||||
float_tiles->width,
|
||||
float_tiles->height, FALSE);
|
||||
|
||||
/* Create the new tile manager */
|
||||
new_tiles = tile_manager_new ((x2 - x1), (y2 - y1), float_tiles->bpp);
|
||||
pixel_region_init (&destPR, new_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
|
||||
|
||||
|
||||
if (drawable_type (drawable) == INDEXED_GIMAGE ||
|
||||
drawable_type (drawable) == INDEXEDA_GIMAGE ||
|
||||
!interpolation)
|
||||
scale_region_no_resample (&srcPR, &destPR);
|
||||
else
|
||||
scale_region (&srcPR, &destPR);
|
||||
|
||||
new_tiles->x = x1;
|
||||
new_tiles->y = y1;
|
||||
|
||||
return (void *) new_tiles;
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -335,8 +335,7 @@ scale_tool_motion (tool, gdisp_ptr)
|
|||
if (*y1 <= *y2) *y1 = *y2 + 1;
|
||||
}
|
||||
|
||||
/* if both the control key & shift keys are down, keep the aspect ratio intac
|
||||
t */
|
||||
/* if both the control key & shift keys are down, keep the aspect ratio intact */
|
||||
if (transform_core->state & GDK_CONTROL_MASK && transform_core->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
ratio = (double) (transform_core->x2 - transform_core->x1) /
|
||||
|
@ -432,35 +431,7 @@ scale_tool_scale (gimage, drawable, trans_info, float_tiles, interpolation, matr
|
|||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
TileManager *new_tiles;
|
||||
int x1, y1, x2, y2;
|
||||
PixelRegion srcPR, destPR;
|
||||
|
||||
x1 = trans_info[X1];
|
||||
y1 = trans_info[Y1];
|
||||
x2 = trans_info[X2];
|
||||
y2 = trans_info[Y2];
|
||||
|
||||
pixel_region_init (&srcPR, float_tiles, 0, 0,
|
||||
float_tiles->width,
|
||||
float_tiles->height, FALSE);
|
||||
|
||||
/* Create the new tile manager */
|
||||
new_tiles = tile_manager_new ((x2 - x1), (y2 - y1), float_tiles->bpp);
|
||||
pixel_region_init (&destPR, new_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
|
||||
|
||||
|
||||
if (drawable_type (drawable) == INDEXED_GIMAGE ||
|
||||
drawable_type (drawable) == INDEXEDA_GIMAGE ||
|
||||
!interpolation)
|
||||
scale_region_no_resample (&srcPR, &destPR);
|
||||
else
|
||||
scale_region (&srcPR, &destPR);
|
||||
|
||||
new_tiles->x = x1;
|
||||
new_tiles->y = y1;
|
||||
|
||||
return (void *) new_tiles;
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -335,8 +335,7 @@ scale_tool_motion (tool, gdisp_ptr)
|
|||
if (*y1 <= *y2) *y1 = *y2 + 1;
|
||||
}
|
||||
|
||||
/* if both the control key & shift keys are down, keep the aspect ratio intac
|
||||
t */
|
||||
/* if both the control key & shift keys are down, keep the aspect ratio intact */
|
||||
if (transform_core->state & GDK_CONTROL_MASK && transform_core->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
ratio = (double) (transform_core->x2 - transform_core->x1) /
|
||||
|
@ -432,35 +431,7 @@ scale_tool_scale (gimage, drawable, trans_info, float_tiles, interpolation, matr
|
|||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
TileManager *new_tiles;
|
||||
int x1, y1, x2, y2;
|
||||
PixelRegion srcPR, destPR;
|
||||
|
||||
x1 = trans_info[X1];
|
||||
y1 = trans_info[Y1];
|
||||
x2 = trans_info[X2];
|
||||
y2 = trans_info[Y2];
|
||||
|
||||
pixel_region_init (&srcPR, float_tiles, 0, 0,
|
||||
float_tiles->width,
|
||||
float_tiles->height, FALSE);
|
||||
|
||||
/* Create the new tile manager */
|
||||
new_tiles = tile_manager_new ((x2 - x1), (y2 - y1), float_tiles->bpp);
|
||||
pixel_region_init (&destPR, new_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
|
||||
|
||||
|
||||
if (drawable_type (drawable) == INDEXED_GIMAGE ||
|
||||
drawable_type (drawable) == INDEXEDA_GIMAGE ||
|
||||
!interpolation)
|
||||
scale_region_no_resample (&srcPR, &destPR);
|
||||
else
|
||||
scale_region (&srcPR, &destPR);
|
||||
|
||||
new_tiles->x = x1;
|
||||
new_tiles->y = y1;
|
||||
|
||||
return (void *) new_tiles;
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "temp_buf.h"
|
||||
#include "tools.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "layer_pvt.h"
|
||||
#include "drawable_pvt.h"
|
||||
#include "tile_manager_pvt.h"
|
||||
|
@ -996,12 +995,17 @@ transform_core_do (gimage, drawable, float_tiles, interpolation, matrix)
|
|||
|
||||
if (transform_tool_direction () == TRANSFORM_CORRECTIVE)
|
||||
{
|
||||
/* keep the original matrix here, so we dont need to recalculate
|
||||
the inverse later */
|
||||
gimp_matrix_duplicate (matrix, m);
|
||||
gimp_matrix_invert (matrix, im);
|
||||
matrix = im;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Find the inverse of the transformation matrix */
|
||||
gimp_matrix_invert (matrix, m);
|
||||
}
|
||||
|
||||
x1 = float_tiles->x;
|
||||
y1 = float_tiles->y;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "temp_buf.h"
|
||||
#include "tools.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "layer_pvt.h"
|
||||
#include "drawable_pvt.h"
|
||||
#include "tile_manager_pvt.h"
|
||||
|
@ -996,12 +995,17 @@ transform_core_do (gimage, drawable, float_tiles, interpolation, matrix)
|
|||
|
||||
if (transform_tool_direction () == TRANSFORM_CORRECTIVE)
|
||||
{
|
||||
/* keep the original matrix here, so we dont need to recalculate
|
||||
the inverse later */
|
||||
gimp_matrix_duplicate (matrix, m);
|
||||
gimp_matrix_invert (matrix, im);
|
||||
matrix = im;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Find the inverse of the transformation matrix */
|
||||
gimp_matrix_invert (matrix, m);
|
||||
}
|
||||
|
||||
x1 = float_tiles->x;
|
||||
y1 = float_tiles->y;
|
||||
|
|
|
@ -169,3 +169,13 @@ gimp_matrix_invert (GimpMatrix m, GimpMatrix m_inv)
|
|||
m_inv[1][2] = - ( m[0][0] * m[1][2] - m[0][2] * m[1][0] ) * det_1;
|
||||
m_inv[2][2] = ( m[0][0] * m[1][1] - m[0][1] * m[1][0] ) * det_1;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_matrix_duplicate (GimpMatrix src, GimpMatrix target)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
for (j=0; j<3; j++)
|
||||
target[i][j] = src[i][j];
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ void gimp_matrix_xshear (GimpMatrix, double);
|
|||
void gimp_matrix_yshear (GimpMatrix, double);
|
||||
double gimp_matrix_determinant (GimpMatrix);
|
||||
void gimp_matrix_invert (GimpMatrix m, GimpMatrix m_inv);
|
||||
void gimp_matrix_duplicate (GimpMatrix src, GimpMatrix target);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue