app: use matrix to determine if doing perspective transform in preview

In GimpCanvasTransformPreview, use the transform matrix to
determine if we're doing a perspective transform, rather than
relying on a separate property, so that we don't use the slow
perspective path unnecessarily.

Consequently, remove the does_perspective member of
GimpTransformTool, since it's no longer used.
This commit is contained in:
Ell 2017-11-14 11:19:42 -05:00
parent 788e04bddb
commit 2e9ab59d19
9 changed files with 10 additions and 40 deletions

View File

@ -57,7 +57,6 @@ enum
PROP_Y1,
PROP_X2,
PROP_Y2,
PROP_PERSPECTIVE,
PROP_OPACITY
};
@ -70,7 +69,6 @@ struct _GimpCanvasTransformPreviewPrivate
GimpMatrix3 transform;
gdouble x1, y1;
gdouble x2, y2;
gboolean perspective;
gdouble opacity;
};
@ -216,12 +214,6 @@ gimp_canvas_transform_preview_class_init (GimpCanvasTransformPreviewClass *klass
0.0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_PERSPECTIVE,
g_param_spec_boolean ("perspective",
NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_OPACITY,
g_param_spec_double ("opacity",
NULL, NULL,
@ -277,10 +269,6 @@ gimp_canvas_transform_preview_set_property (GObject *object,
private->y2 = g_value_get_double (value);
break;
case PROP_PERSPECTIVE:
private->perspective = g_value_get_boolean (value);
break;
case PROP_OPACITY:
private->opacity = g_value_get_double (value);
break;
@ -309,10 +297,6 @@ gimp_canvas_transform_preview_get_property (GObject *object,
g_value_set_boxed (value, &private->transform);
break;
case PROP_PERSPECTIVE:
g_value_set_boolean (value, private->perspective);
break;
case PROP_X1:
g_value_set_double (value, private->x1);
break;
@ -445,7 +429,7 @@ gimp_canvas_transform_preview_draw (GimpCanvasItem *item,
&mask_offx, &mask_offy);
}
if (private->perspective)
if (! gimp_matrix3_is_affine (&private->transform))
{
/* approximate perspective transform by subdivision
*
@ -575,8 +559,7 @@ gimp_canvas_transform_preview_new (GimpDisplayShell *shell,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gboolean perspective)
gdouble y2)
{
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
@ -590,7 +573,6 @@ gimp_canvas_transform_preview_new (GimpDisplayShell *shell,
"y1", y1,
"x2", x2,
"y2", y2,
"perspective", perspective,
NULL);
}

View File

@ -55,8 +55,7 @@ GimpCanvasItem * gimp_canvas_transform_preview_new (GimpDisplayShell *shel
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gboolean perspective);
gdouble y2);
#endif /* __GIMP_CANVAS_TRANSFORM_PREVIEW_H__ */

View File

@ -1167,8 +1167,7 @@ gimp_draw_tool_add_transform_preview (GimpDrawTool *draw_tool,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gboolean perspective)
gdouble y2)
{
GimpCanvasItem *item;
@ -1178,8 +1177,7 @@ gimp_draw_tool_add_transform_preview (GimpDrawTool *draw_tool,
item = gimp_canvas_transform_preview_new (gimp_display_get_shell (draw_tool->display),
drawable, transform,
x1, y1, x2, y2,
perspective);
x1, y1, x2, y2);
gimp_draw_tool_add_preview (draw_tool, item);
g_object_unref (item);

View File

@ -150,8 +150,7 @@ GimpCanvasItem * gimp_draw_tool_add_transform_preview(GimpDrawTool *draw_too
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gboolean perspective);
gdouble y2);
GimpCanvasItem * gimp_draw_tool_add_handle (GimpDrawTool *draw_tool,
GimpHandleType type,

View File

@ -144,7 +144,6 @@ gimp_handle_transform_tool_init (GimpHandleTransformTool *ht_tool)
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (ht_tool);
tr_tool->progress_text = _("Handle transformation");
tr_tool->does_perspective = TRUE;
ht_tool->saved_handle_mode = GIMP_HANDLE_MODE_ADD_TRANSFORM;
}

View File

@ -114,7 +114,6 @@ gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
GIMP_TOOL_CURSOR_PERSPECTIVE);
tr_tool->progress_text = _("Perspective transformation");
tr_tool->does_perspective = TRUE;
}
static void

View File

@ -657,8 +657,7 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
tr_tool->x1,
tr_tool->y1,
tr_tool->x2,
tr_tool->y2,
tr_tool->does_perspective);
tr_tool->y2);
g_object_add_weak_pointer (G_OBJECT (tr_tool->preview),
(gpointer) &tr_tool->preview);

View File

@ -63,10 +63,6 @@ struct _GimpTransformTool
GimpItem *hidden_item; /* the item that was hidden during
the transform */
gboolean does_perspective; /* does the tool do non-affine
* transformations
*/
GimpToolWidget *widget;
GimpToolWidget *grab_widget;
GimpCanvasItem *preview;

View File

@ -111,7 +111,6 @@ gimp_unified_transform_tool_init (GimpUnifiedTransformTool *unified_tool)
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (unified_tool);
tr_tool->progress_text = _("Unified transform");
tr_tool->does_perspective = TRUE;
}
static void