[gimp/wip/gradient-edit: 202/225] app: treat gradient segments as clopen ranges
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/gradient-edit: 202/225] app: treat gradient segments as clopen ranges
- Date: Fri, 6 Oct 2017 17:07:26 +0000 (UTC)
commit b30fac7e1b1625558ca59a49f18c11779673b78e
Author: Ell <ell_se yahoo com>
Date: Sat Aug 12 11:50:54 2017 -0400
app: treat gradient segments as clopen ranges
Treat gradient segment exents as [left, right) ranges, instead of
[left, right], so that they don't overlap, and each point
corresponds to a unique color.
Perform less comparisons in gimp_gradient_get_segment_at_internal().
app/core/gimpgradient.c | 30 ++++++++++--------------------
1 files changed, 10 insertions(+), 20 deletions(-)
---
diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c
index 4d99a8e..520ea72 100644
--- a/app/core/gimpgradient.c
+++ b/app/core/gimpgradient.c
@@ -2077,29 +2077,19 @@ gimp_gradient_get_segment_at_internal (GimpGradient *gradient,
if (! seg)
seg = gradient->segments;
- while (seg)
+ if (pos >= seg->left)
{
- if (pos >= seg->left)
- {
- if (pos <= seg->right)
- {
- return seg;
- }
- else
- {
- seg = seg->next;
- }
- }
- else
- {
- seg = seg->prev;
- }
+ while (seg->next && pos >= seg->right)
+ seg = seg->next;
+ }
+ else
+ {
+ do
+ seg = seg->prev;
+ while (pos < seg->left);
}
- /* Oops: we should have found a segment, but we didn't */
- g_warning ("%s: no matching segment for position %0.15f", G_STRFUNC, pos);
-
- return NULL;
+ return seg;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]