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:
@ -57,7 +57,6 @@ enum
|
|||||||
PROP_Y1,
|
PROP_Y1,
|
||||||
PROP_X2,
|
PROP_X2,
|
||||||
PROP_Y2,
|
PROP_Y2,
|
||||||
PROP_PERSPECTIVE,
|
|
||||||
PROP_OPACITY
|
PROP_OPACITY
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,7 +69,6 @@ struct _GimpCanvasTransformPreviewPrivate
|
|||||||
GimpMatrix3 transform;
|
GimpMatrix3 transform;
|
||||||
gdouble x1, y1;
|
gdouble x1, y1;
|
||||||
gdouble x2, y2;
|
gdouble x2, y2;
|
||||||
gboolean perspective;
|
|
||||||
gdouble opacity;
|
gdouble opacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -216,12 +214,6 @@ gimp_canvas_transform_preview_class_init (GimpCanvasTransformPreviewClass *klass
|
|||||||
0.0,
|
0.0,
|
||||||
GIMP_PARAM_READWRITE));
|
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_object_class_install_property (object_class, PROP_OPACITY,
|
||||||
g_param_spec_double ("opacity",
|
g_param_spec_double ("opacity",
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
@ -277,10 +269,6 @@ gimp_canvas_transform_preview_set_property (GObject *object,
|
|||||||
private->y2 = g_value_get_double (value);
|
private->y2 = g_value_get_double (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_PERSPECTIVE:
|
|
||||||
private->perspective = g_value_get_boolean (value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_OPACITY:
|
case PROP_OPACITY:
|
||||||
private->opacity = g_value_get_double (value);
|
private->opacity = g_value_get_double (value);
|
||||||
break;
|
break;
|
||||||
@ -309,10 +297,6 @@ gimp_canvas_transform_preview_get_property (GObject *object,
|
|||||||
g_value_set_boxed (value, &private->transform);
|
g_value_set_boxed (value, &private->transform);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_PERSPECTIVE:
|
|
||||||
g_value_set_boolean (value, private->perspective);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_X1:
|
case PROP_X1:
|
||||||
g_value_set_double (value, private->x1);
|
g_value_set_double (value, private->x1);
|
||||||
break;
|
break;
|
||||||
@ -445,7 +429,7 @@ gimp_canvas_transform_preview_draw (GimpCanvasItem *item,
|
|||||||
&mask_offx, &mask_offy);
|
&mask_offx, &mask_offy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (private->perspective)
|
if (! gimp_matrix3_is_affine (&private->transform))
|
||||||
{
|
{
|
||||||
/* approximate perspective transform by subdivision
|
/* approximate perspective transform by subdivision
|
||||||
*
|
*
|
||||||
@ -575,8 +559,7 @@ gimp_canvas_transform_preview_new (GimpDisplayShell *shell,
|
|||||||
gdouble x1,
|
gdouble x1,
|
||||||
gdouble y1,
|
gdouble y1,
|
||||||
gdouble x2,
|
gdouble x2,
|
||||||
gdouble y2,
|
gdouble y2)
|
||||||
gboolean perspective)
|
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
||||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
||||||
@ -590,7 +573,6 @@ gimp_canvas_transform_preview_new (GimpDisplayShell *shell,
|
|||||||
"y1", y1,
|
"y1", y1,
|
||||||
"x2", x2,
|
"x2", x2,
|
||||||
"y2", y2,
|
"y2", y2,
|
||||||
"perspective", perspective,
|
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +55,7 @@ GimpCanvasItem * gimp_canvas_transform_preview_new (GimpDisplayShell *shel
|
|||||||
gdouble x1,
|
gdouble x1,
|
||||||
gdouble y1,
|
gdouble y1,
|
||||||
gdouble x2,
|
gdouble x2,
|
||||||
gdouble y2,
|
gdouble y2);
|
||||||
gboolean perspective);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_CANVAS_TRANSFORM_PREVIEW_H__ */
|
#endif /* __GIMP_CANVAS_TRANSFORM_PREVIEW_H__ */
|
||||||
|
@ -1167,8 +1167,7 @@ gimp_draw_tool_add_transform_preview (GimpDrawTool *draw_tool,
|
|||||||
gdouble x1,
|
gdouble x1,
|
||||||
gdouble y1,
|
gdouble y1,
|
||||||
gdouble x2,
|
gdouble x2,
|
||||||
gdouble y2,
|
gdouble y2)
|
||||||
gboolean perspective)
|
|
||||||
{
|
{
|
||||||
GimpCanvasItem *item;
|
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),
|
item = gimp_canvas_transform_preview_new (gimp_display_get_shell (draw_tool->display),
|
||||||
drawable, transform,
|
drawable, transform,
|
||||||
x1, y1, x2, y2,
|
x1, y1, x2, y2);
|
||||||
perspective);
|
|
||||||
|
|
||||||
gimp_draw_tool_add_preview (draw_tool, item);
|
gimp_draw_tool_add_preview (draw_tool, item);
|
||||||
g_object_unref (item);
|
g_object_unref (item);
|
||||||
|
@ -150,8 +150,7 @@ GimpCanvasItem * gimp_draw_tool_add_transform_preview(GimpDrawTool *draw_too
|
|||||||
gdouble x1,
|
gdouble x1,
|
||||||
gdouble y1,
|
gdouble y1,
|
||||||
gdouble x2,
|
gdouble x2,
|
||||||
gdouble y2,
|
gdouble y2);
|
||||||
gboolean perspective);
|
|
||||||
|
|
||||||
GimpCanvasItem * gimp_draw_tool_add_handle (GimpDrawTool *draw_tool,
|
GimpCanvasItem * gimp_draw_tool_add_handle (GimpDrawTool *draw_tool,
|
||||||
GimpHandleType type,
|
GimpHandleType type,
|
||||||
|
@ -143,8 +143,7 @@ gimp_handle_transform_tool_init (GimpHandleTransformTool *ht_tool)
|
|||||||
{
|
{
|
||||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (ht_tool);
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (ht_tool);
|
||||||
|
|
||||||
tr_tool->progress_text = _("Handle transformation");
|
tr_tool->progress_text = _("Handle transformation");
|
||||||
tr_tool->does_perspective = TRUE;
|
|
||||||
|
|
||||||
ht_tool->saved_handle_mode = GIMP_HANDLE_MODE_ADD_TRANSFORM;
|
ht_tool->saved_handle_mode = GIMP_HANDLE_MODE_ADD_TRANSFORM;
|
||||||
}
|
}
|
||||||
|
@ -113,8 +113,7 @@ gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
|
|||||||
gimp_tool_control_set_tool_cursor (tool->control,
|
gimp_tool_control_set_tool_cursor (tool->control,
|
||||||
GIMP_TOOL_CURSOR_PERSPECTIVE);
|
GIMP_TOOL_CURSOR_PERSPECTIVE);
|
||||||
|
|
||||||
tr_tool->progress_text = _("Perspective transformation");
|
tr_tool->progress_text = _("Perspective transformation");
|
||||||
tr_tool->does_perspective = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -657,8 +657,7 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
|
|||||||
tr_tool->x1,
|
tr_tool->x1,
|
||||||
tr_tool->y1,
|
tr_tool->y1,
|
||||||
tr_tool->x2,
|
tr_tool->x2,
|
||||||
tr_tool->y2,
|
tr_tool->y2);
|
||||||
tr_tool->does_perspective);
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (tr_tool->preview),
|
g_object_add_weak_pointer (G_OBJECT (tr_tool->preview),
|
||||||
(gpointer) &tr_tool->preview);
|
(gpointer) &tr_tool->preview);
|
||||||
|
|
||||||
|
@ -63,10 +63,6 @@ struct _GimpTransformTool
|
|||||||
GimpItem *hidden_item; /* the item that was hidden during
|
GimpItem *hidden_item; /* the item that was hidden during
|
||||||
the transform */
|
the transform */
|
||||||
|
|
||||||
gboolean does_perspective; /* does the tool do non-affine
|
|
||||||
* transformations
|
|
||||||
*/
|
|
||||||
|
|
||||||
GimpToolWidget *widget;
|
GimpToolWidget *widget;
|
||||||
GimpToolWidget *grab_widget;
|
GimpToolWidget *grab_widget;
|
||||||
GimpCanvasItem *preview;
|
GimpCanvasItem *preview;
|
||||||
|
@ -110,8 +110,7 @@ gimp_unified_transform_tool_init (GimpUnifiedTransformTool *unified_tool)
|
|||||||
{
|
{
|
||||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (unified_tool);
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (unified_tool);
|
||||||
|
|
||||||
tr_tool->progress_text = _("Unified transform");
|
tr_tool->progress_text = _("Unified transform");
|
||||||
tr_tool->does_perspective = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user