Repository navigation
color picker: misc. improvements - #9925
Conversation
Go from pleasing compiler and producing potential NULL dereference to just using a default on the default case. In reality the default case should never happen.
If turn the primary colorpicker on after an image has loaded, it can initially appears with a blank central swatch. This is because the preview pipe is still executing when the center view is redrawn, and there is no sample. To fix this, redraw the center view yet again once the sample is calculated. This should also guarantee that the sample swatch at the center of the picker keeps up with most recent pixelpipe output.
Previously every time the center view was drawn the colorpicker widget in the left panel would be redrawn. Now that DT_SIGNAL_CONTROL_PICKERDATA_READY is raised when the primary picker and live samples are recalculated, just use that signal as the cue to redraw.
Previously the picker was turned off but the eyedropper widget may not have been turned off. Also dt_iop_color_picker_reset() now sets sample size to none. This was done by hand in image change/leave code. It should be the right thing to do this in general when the picker proxy is reset.
No need to test for non-NULL sample twice. Use extant pointer to primary sample later in the function.
When iop picker is initally started, its swatch is blank due to a recent commit. Fix so that the swatch has data. Always update swatch and live samples in lib when receive signal that the pixelpipe has done the primary picking, regardless of whether sample area has changed -- this could have been a pixelpipe run due to a change to an iop. Trigger redraw of center whenever we have new point picker data. Remove unneeded center view redraw. This presumably happens elsewhere due to DT_SIGNAL_DEVELOP_PREVIEW_PIPE_FINISHED.
It's enough to catch DT_SIGNAL_DEVELOP_PREVIEW_PIPE_FINISHED and do the updates needed there. Also, make _iop_record_point_area() return whether the picker has been changed, and only pay attention to that for iop pickers.
If the preview pipe is valid, we can trust the swatch, otherwise it is stale.
There's a bug since c259208 that the cursor flickers on/off when dragging the point picker. This is because it keeps re-appearing as a GDK_LEFT_PTR then disappears when set to GDK_BLANK_CURSOR. This is only with point samples. I can't find the bug, but to work around, now only change the cursor for a box sample. Use a GDK_CROSSHAIR in that case rather than GDK_BLANK_CURSOR. Also, invalidate the pixelpipe via dt_dev_invalidate_from_gui() if we only need the primary picker and live samples, not an iop picker.
The current picker is off when darktable.lib->proxy.colorpicker.picker_proxy is off. Don't double up and expect the size of the primary picker to contain overlapping information. Also, in pixelpipe, iop sampler doesn't have to check if there is an extant sample -- it won't be called if there isn't one. Also reset the primary picker when gui_cleanup() for primary picker -- though presumably this only gets called on shutdown so isn't urgent.
Cursor reflects which corner is being dragged. Change area cursor for initial area from crosshair to fleur.
Rather than separate arrays for each sort of picker result by statistic, make one array for each indexed by statistic. Allows for more succinct code. Also now clamp hex values in label display to 00-FF, as negative hex values in particular are confusing to display.
Just use GDK_FLEUR. Using cursors based on corners when dragging corners doesn't make sense as they can cross center line and be meaningless.
Make a typedef for a dt_aligned_pixel_t for each statistic type (mean, max, min). Then simplify the _pixelpipe_pick_from_image() used for primary picker and live samples. Eliminates some temporary rgb/lab value buffers. Also generally tidy this code.
So that won't do colorspace conversions mean/min/max when only need to do one and copy over the rest. Eliminate temp variables in point sample path. Use memcpy(), which may be slower than for_each_channel(). This code may be slightly faster, but may be illegible in its succinctness. Fix bug where mean/min/max initializers for point sample were in wrong order. Clamp hex readout in tooltip to 0-255.
Remove _iop_ from proxy internal functions: As the color picker proxy may work for iop or for the lib colorpicker. And as it sits in the gui subdirectory. Don't change the public facing API, those, these still are dt_iop_*. When applying an iop color picker, we should always be in the preview pipe, and hence piece->pipe == dev->preview_pipe. So don't need to figure out dev from module -- saves one reference/test. Note how when the preview pipe updates and hence the picker data updates, that it appears that we don't need to redraw center view by hand as the center view will redraw when preview pipe changes. It makes sense to call the current sample primary_sample as it will always be shown as the primary sample. Leave in mouse move optimization to limit colorpicker calls -- it actually is helpful. Don't think about pulling new picker data from output_backbuf, which is 8-bit rather than float.
Just set the preview pipe to dirty. These updates are fast. Don't need optimization to detect if mouse moved past a preview pipe pixel, which also is wrong for iops. The dt_dev_invalidate_from_gui() path is slow -- remove it. Also simplifes/clarifies the code. Always draw a center swatch of picker, even if pixelpipe is invalid, to avoid flickering.
|
0.o weird... the CI crashed on trying to run |
|
@dtorop I will test this PR as soon I have time. |
I tested and it crashed here as well. So that's why CI is helpful... I'll look into it...
Wrote a note on #9920 about this... |
If there's no GUI, darktable.lib will be NULL. Hence test for GUI before dereferencing darktable.lib to see if there's an active picker widget.
|
YAY for CI :D |
|
Great! This should be the major part of tidying the color picker code. Still possible to do:
Probably a few other things, as always... |
|
@dtorop Dan what is the whole status on the processing of data from the working profile through the display profile to get to the histogram and hence provide the data for the pickers...is this still something that is being worked on to avoid the colorspace clipping introduced by the display profile in this pathway or have there been some changes introduced?? |
@todd-prior Belatedly -- I haven't worked on this. My memory is that it'll take a bunch more work on colorout and module order to make this work. My guess is that if that display profile is unbounded, that the work -> display -> histogram conversion doesn't lose data, it just wastes a step and introduces a tiny error. |
…ements-post-9835 color picker: misc. improvements
These are some improvements/fixes to the color picker code, meant as a follow-up to #9835.
User-visible changes:
Internal fixes:
picked_color_rgb_{mean,min,max}) and turns a bunch of switch statements by statistic into one line array lookups.DT_SIGNAL_CONTROL_PICKERDATA_READYwhen the primary picker is changed. It's enough to catchDT_SIGNAL_DEVELOP_PREVIEW_PIPE_FINISHED.DT_LIB_COLORPICKER_SIZE_NONEas a picker state. Now pickers can either be point or box. An inactive picker is signified bydarktable.lib->proxy.colorpicker.picker_proxybeing NULL.