Blender V5.3
eyedropper_color.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
13
14#include "MEM_guardedalloc.h"
15
16#include "DNA_material_types.h"
17#include "DNA_scene_types.h"
18#include "DNA_screen_types.h"
19#include "DNA_space_types.h"
20
21#include "BLI_listbase.hh"
22#include "BLI_math_vector_c.hh"
23#include "BLI_string.hh"
24#include "BLI_string_ref.hh"
25
26#include "BKE_context.hh"
27#include "BKE_cryptomatte.h"
28#include "BKE_image.hh"
29#include "BKE_layer.hh"
30#include "BKE_material.hh"
31#include "BKE_report.hh"
32#include "BKE_screen.hh"
33
34#include "BLT_translation.hh"
35
36#include "NOD_composite.hh"
37
38#include "RNA_access.hh"
39#include "RNA_define.hh"
40#include "RNA_path.hh"
41#include "RNA_prototypes.hh"
42
44#include "IMB_imbuf_types.hh"
45
46#include "WM_api.hh"
47#include "WM_types.hh"
48
49#include "interface_intern.hh"
50
51#include "ED_clip.hh"
52#include "ED_image.hh"
53#include "ED_node.hh"
54#include "ED_screen.hh"
55#include "ED_view3d.hh"
56
57#include "RE_pipeline.h"
58
59#include "eyedropper_intern.hh"
60
61namespace blender::ui {
62
63struct Eyedropper {
64 const ColorManagedDisplay *display = nullptr;
65
67 PropertyRNA *prop = nullptr;
68 int index = 0;
69 bool is_undo = false;
70
71 bool is_set = false;
72 float init_col[3] = {}; /* for resetting on cancel */
73
74 bool accum_start = false; /* has mouse been pressed */
75 float accum_col[3] = {};
76 int accum_tot = 0;
77
78 wmWindow *cb_win = nullptr;
79 int cb_win_event_xy[2] = {};
80 void *draw_handle_sample_text = nullptr;
82
83 bNode *crypto_node = nullptr;
86};
87
88static void eyedropper_draw_cb(const wmWindow * /*window*/, void *arg)
89{
90 Eyedropper *eye = static_cast<Eyedropper *>(arg);
92}
93
95{
96 Eyedropper *eye = MEM_new<Eyedropper>(__func__);
97
98 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "prop_data_path");
99 if (prop && RNA_property_is_set(op->ptr, prop)) {
100 std::string prop_data_path = RNA_string_get(op->ptr, "prop_data_path");
101 if (prop_data_path.empty()) {
102 MEM_delete(eye);
103 return false;
104 }
105 PointerRNA ctx_ptr = RNA_pointer_create_discrete(nullptr, RNA_Context, C);
106 if (!RNA_path_resolve(&ctx_ptr, prop_data_path.c_str(), &eye->ptr, &eye->prop)) {
107 BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", prop_data_path.c_str());
108 MEM_delete(eye);
109 return false;
110 }
111 eye->is_undo = true;
112 }
113 else {
114 Button *but = context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index);
115 if (but != nullptr) {
117 }
118 }
119
120 const enum PropertySubType prop_subtype = eye->prop ? RNA_property_subtype(eye->prop) :
122
123 if (!eye->ptr || (eye->prop == nullptr) ||
124 (RNA_property_editable(&eye->ptr, eye->prop) == false) ||
125 (RNA_property_array_length(&eye->ptr, eye->prop) < 3) ||
126 (RNA_property_type(eye->prop) != PROP_FLOAT) ||
127 (ELEM(prop_subtype, PROP_COLOR, PROP_COLOR_GAMMA) == 0))
128 {
129 MEM_delete(eye);
130 return false;
131 }
132 op->customdata = eye;
133
134 float col[4];
136 if (eye->ptr.type == RNA_CompositorNodeCryptomatteV2) {
138 eye->crypto_node = static_cast<bNode *>(eye->ptr.data);
140 eye->cb_win = CTX_wm_window(C);
142 }
143
144 if (prop_subtype != PROP_COLOR) {
145 Scene *scene = CTX_data_scene(C);
146 const char *display_device;
147
148 display_device = scene->display_settings.display_device;
149 eye->display = IMB_colormanagement_display_get_named(display_device);
150
151 /* store initial color */
152 if (eye->display) {
154 }
155 }
156 copy_v3_v3(eye->init_col, col);
157
158 return true;
159}
160
162{
163 Eyedropper *eye = static_cast<Eyedropper *>(op->customdata);
164 wmWindow *window = CTX_wm_window(C);
166
167 ED_workspace_status_text(C, nullptr);
168
169 if (eye->draw_handle_sample_text) {
171 eye->draw_handle_sample_text = nullptr;
172 }
173
174 if (eye->cryptomatte_session) {
176 eye->cryptomatte_session = nullptr;
177 }
178
179 if (eye->viewport_session) {
180 MEM_delete(eye->viewport_session);
181 eye->viewport_session = nullptr;
182 }
183
184 op->customdata = nullptr;
185 MEM_delete(eye);
186}
187
188/* *** eyedropper_color_ helper functions *** */
189
191 const char *type_name,
192 const int mval[2],
193 float r_col[3])
194{
195 int material_slot = 0;
196 Object *object = ED_view3d_give_material_slot_under_cursor(C, mval, &material_slot);
197 if (!object) {
198 return false;
199 }
200
201 const ID *id = nullptr;
202 if (StringRef(type_name).endswith(RE_PASSNAME_CRYPTOMATTE_OBJECT)) {
203 id = &object->id;
204 }
205 else if (StringRef(type_name).endswith(RE_PASSNAME_CRYPTOMATTE_MATERIAL)) {
206 Material *material = BKE_object_material_get(object, material_slot);
207 if (!material) {
208 return false;
209 }
210 id = &material->id;
211 }
212
213 if (!id) {
214 return false;
215 }
216
217 const char *name = &id->name[2];
218 const int name_length = BLI_strnlen(name, MAX_NAME - 2);
219 uint32_t cryptomatte_hash = BKE_cryptomatte_hash(name, name_length);
220 r_col[0] = BKE_cryptomatte_hash_to_float(cryptomatte_hash);
221 return true;
222}
223
225 const char *prefix,
226 const float fpos[2],
227 float r_col[3])
228{
229 if (!render_layer) {
230 return false;
231 }
232
233 const int render_layer_name_len = STRNLEN(render_layer->name);
234 if (strncmp(prefix, render_layer->name, render_layer_name_len) != 0) {
235 return false;
236 }
237
238 const int prefix_len = strlen(prefix);
239 if (prefix_len <= render_layer_name_len + 1) {
240 return false;
241 }
242
243 /* RenderResult from images can have no render layer name. */
244 const char *render_pass_name_prefix = render_layer_name_len ?
245 prefix + 1 + render_layer_name_len :
246 prefix;
247
248 for (RenderPass &render_pass : render_layer->passes) {
249 if (STRPREFIX(render_pass.name, render_pass_name_prefix) &&
250 !STREQLEN(render_pass.name, render_pass_name_prefix, sizeof(render_pass.name)))
251 {
252 BLI_assert(render_pass.channels == 4);
253
254 /* Pass was allocated but not rendered yet. */
255 if (!render_pass.ibuf) {
256 return false;
257 }
258
259 const int x = int(fpos[0] * render_pass.rectx);
260 const int y = int(fpos[1] * render_pass.recty);
261 const int offset = 4 * (y * render_pass.rectx + x);
262 zero_v3(r_col);
263 r_col[0] = render_pass.ibuf->float_data()[offset];
264 return true;
265 }
266 }
267
268 return false;
269}
270
272 const char *prefix,
273 const float fpos[2],
274 float r_col[3])
275{
276 bool success = false;
277 Scene *scene = id_cast<Scene *>(node->id);
278 BLI_assert(GS(scene->id.name) == ID_SCE);
279 Render *re = RE_GetSceneRender(scene);
280
281 if (re) {
283 if (rr) {
284 for (ViewLayer &view_layer : scene->view_layers) {
285 RenderLayer *render_layer = RE_GetRenderLayer(rr, view_layer.name);
286 success = eyedropper_cryptomatte_sample_renderlayer_fl(render_layer, prefix, fpos, r_col);
287 if (success) {
288 break;
289 }
290 }
291 }
293 }
294 return success;
295}
296
298 const bNode *node,
299 NodeCryptomatte *crypto,
300 const char *prefix,
301 const float fpos[2],
302 float r_col[3])
303{
304 bool success = false;
305 Image *image = id_cast<Image *>(node->id);
306 BLI_assert((image == nullptr) || (GS(image->id.name) == ID_IM));
307
308 /* Compute the effective frame number of the image if it was animated. */
309 Scene *scene = CTX_data_scene(C);
310 ImageUser image_user_for_frame = crypto->iuser;
311 BKE_image_user_frame_calc(image, &image_user_for_frame, scene->r.cfra);
312
313 if (image && image->type == IMA_TYPE_MULTILAYER) {
314 ImBuf *ibuf = BKE_image_acquire_ibuf(image, &image_user_for_frame, nullptr);
315 if (image->rr) {
316 for (RenderLayer &render_layer : image->rr->layers) {
317 success = eyedropper_cryptomatte_sample_renderlayer_fl(&render_layer, prefix, fpos, r_col);
318 if (success) {
319 break;
320 }
321 }
322 }
323 BKE_image_release_ibuf(image, ibuf, nullptr);
324 }
325 return success;
326}
327
329 Eyedropper *eye,
330 const int event_xy[2],
331 float r_col[3])
332{
333 bNode *node = eye->crypto_node;
334 NodeCryptomatte *crypto = node ? (static_cast<NodeCryptomatte *>(node->storage)) : nullptr;
335
336 if (!crypto) {
337 return false;
338 }
339
340 ScrArea *area = nullptr;
341
342 int event_xy_win[2];
343 wmWindow *win = WM_window_find_under_cursor(CTX_wm_window(C), event_xy, event_xy_win);
344 if (win) {
346 area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event_xy_win);
347 }
348
349 eye->cb_win_event_xy[0] = event_xy_win[0];
350 eye->cb_win_event_xy[1] = event_xy_win[1];
351
352 if (win && win != eye->cb_win && eye->draw_handle_sample_text) {
354 eye->cb_win = win;
357 }
358
359 if (!area || !ELEM(area->spacetype, SPACE_IMAGE, SPACE_NODE, SPACE_CLIP, SPACE_VIEW3D)) {
360 return false;
361 }
362
363 ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, event_xy_win);
364
365 if (!region) {
366 return false;
367 }
368
369 const int mval[2] = {
370 event_xy_win[0] - region->winrct.xmin,
371 event_xy_win[1] - region->winrct.ymin,
372 };
373 float fpos[2] = {-1.0f, -1.0};
374 switch (area->spacetype) {
375 case SPACE_IMAGE: {
376 SpaceImage *sima = area->spacedata.first_as<SpaceImage>();
377 ED_space_image_get_position(sima, region, mval, fpos);
378 break;
379 }
380 case SPACE_NODE: {
381 Main *bmain = CTX_data_main(C);
382 SpaceNode *snode = area->spacedata.first_as<SpaceNode>();
383 ED_space_node_get_position(bmain, snode, region, mval, fpos);
384 break;
385 }
386 case SPACE_CLIP: {
387 SpaceClip *sc = area->spacedata.first_as<SpaceClip>();
388 ED_space_clip_get_position(sc, region, mval, fpos);
389 break;
390 }
391 default: {
392 break;
393 }
394 }
395
396 if (area->spacetype != SPACE_VIEW3D &&
397 (fpos[0] < 0.0f || fpos[1] < 0.0f || fpos[0] >= 1.0f || fpos[1] >= 1.0f))
398 {
399 return false;
400 }
401
402 /* CMP_NODE_CRYPTOMATTE_SOURCE_RENDER and CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE require a referenced
403 * image/scene to work properly. */
404 if (!node->id) {
405 return false;
406 }
407
408 ED_region_tag_redraw(region);
409
410 /* TODO(jbakker): Migrate this file to cc and use std::string as return param. */
411 char prefix[MAX_NAME + 1];
412 ntreeCompositCryptomatteLayerPrefix(node, prefix, sizeof(prefix) - 1);
413 prefix[MAX_NAME] = '\0';
414
415 if (area->spacetype == SPACE_VIEW3D) {
416 wmWindow *win_prev = CTX_wm_window(C);
417 ScrArea *area_prev = CTX_wm_area(C);
418 ARegion *region_prev = CTX_wm_region(C);
419
420 CTX_wm_window_set(C, win);
421 CTX_wm_area_set(C, area);
422 CTX_wm_region_set(C, region);
423
424 const bool success = eyedropper_cryptomatte_sample_view3d_fl(C, prefix, mval, r_col);
425
426 CTX_wm_window_set(C, win_prev);
427 CTX_wm_area_set(C, area_prev);
428 CTX_wm_region_set(C, region_prev);
429
430 return success;
431 }
433 return eyedropper_cryptomatte_sample_render_fl(node, prefix, fpos, r_col);
434 }
435 if (node->custom1 == CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE) {
436 return eyedropper_cryptomatte_sample_image_fl(C, node, crypto, prefix, fpos, r_col);
437 }
438 return false;
439}
440
442 Eyedropper *eye,
443 const int event_xy[2],
444 float r_col[3])
445{
446 ScrArea *area = nullptr;
447
448 int event_xy_win[2];
449 wmWindow *win = WM_window_find_under_cursor(CTX_wm_window(C), event_xy, event_xy_win);
450 if (win) {
452 area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event_xy_win);
453 }
454
455 if (area) {
456 ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, event_xy_win);
457 if (region) {
458 const int mval[2] = {
459 event_xy_win[0] - region->winrct.xmin,
460 event_xy_win[1] - region->winrct.ymin,
461 };
462 if (area->spacetype == SPACE_IMAGE) {
463 SpaceImage *sima = area->spacedata.first_as<SpaceImage>();
464 if (ED_space_image_color_sample(sima, region, mval, r_col, nullptr)) {
465 return true;
466 }
467 }
468 else if (area->spacetype == SPACE_NODE) {
469 SpaceNode *snode = area->spacedata.first_as<SpaceNode>();
470 Main *bmain = CTX_data_main(C);
471 if (ED_space_node_color_sample(bmain, snode, region, mval, r_col)) {
472 return true;
473 }
474 }
475 else if (area->spacetype == SPACE_CLIP) {
476 SpaceClip *sc = area->spacedata.first_as<SpaceClip>();
477 if (ED_space_clip_color_sample(sc, region, mval, r_col)) {
478 return true;
479 }
480 }
481 else if (eye != nullptr && area->spacetype == SPACE_VIEW3D) {
482 /* Viewport color picking involves a fairly expensive operation to copy the GPU viewport
483 * back to the CPU, so to support smooth dragging with the eyedropper, we keep the copy
484 * around for the entire operation. */
485 if (eye->viewport_session == nullptr) {
486 eye->viewport_session = MEM_new<ViewportColorSampleSession>("viewport_session");
487 eye->viewport_session->init(region);
488 }
489 if (eye->viewport_session->sample(mval, r_col)) {
490 return true;
491 }
492 }
493 }
494 }
495
496 /* Other areas within a Blender window. */
497 if (win) {
498 if (!WM_window_pixels_read_sample(C, win, event_xy_win, r_col)) {
499 WM_window_pixels_read_sample_from_offscreen(C, win, event_xy_win, r_col);
500 }
501 const char *display_device = CTX_data_scene(C)->display_settings.display_device;
502 const ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
504 return true;
505 }
506
507 /* Outside the Blender window if we support it. */
511 return true;
512 }
513 }
514
515 zero_v3(r_col);
516 return false;
517}
518
519/* sets the sample color RGB, maintaining A */
520static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
521{
522 float col_conv[4];
523
524 /* to maintain alpha */
525 RNA_property_float_get_array_at_most(&eye->ptr, eye->prop, col_conv, ARRAY_SIZE(col_conv));
526
527 /* convert from linear rgb space to display space */
528 if (eye->display) {
529 copy_v3_v3(col_conv, col);
531 }
532 else {
533 copy_v3_v3(col_conv, col);
534 }
535
536 RNA_property_float_set_array_at_most(&eye->ptr, eye->prop, col_conv, ARRAY_SIZE(col_conv));
537 eye->is_set = true;
538
539 RNA_property_update(C, &eye->ptr, eye->prop);
540}
541
542static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int event_xy[2])
543{
544 /* Accumulate color. */
545 float col[3];
546 if (eye->crypto_node) {
547 if (!eyedropper_cryptomatte_sample_fl(C, eye, event_xy, col)) {
548 return;
549 }
550 }
551 else {
552 if (!eyedropper_color_sample_fl(C, eye, event_xy, col)) {
553 return;
554 }
555 }
556
557 if (!eye->crypto_node) {
558 add_v3_v3(eye->accum_col, col);
559 eye->accum_tot++;
560 }
561 else {
562 copy_v3_v3(eye->accum_col, col);
563 eye->accum_tot = 1;
564 }
565
566 /* Apply to property. */
567 float accum_col[3];
568 if (eye->accum_tot > 1) {
569 mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / float(eye->accum_tot));
570 }
571 else {
572 copy_v3_v3(accum_col, eye->accum_col);
573 }
574 eyedropper_color_set(C, eye, accum_col);
575}
576
578 Eyedropper *eye,
579 const int event_xy[2])
580{
581 float col[3];
582 eye->sample_text[0] = '\0';
583
584 if (eye->cryptomatte_session) {
585 if (eyedropper_cryptomatte_sample_fl(C, eye, event_xy, col)) {
587 eye->cryptomatte_session, col[0], eye->sample_text, sizeof(eye->sample_text));
588 eye->sample_text[sizeof(eye->sample_text) - 1] = '\0';
589 }
590 }
591}
592
594{
595 Eyedropper *eye = static_cast<Eyedropper *>(op->customdata);
596 if (eye->is_set) {
597 eyedropper_color_set(C, eye, eye->init_col);
598 }
599 eyedropper_exit(C, op);
600}
601
602/* main modal status check */
604{
605 Eyedropper *eye = static_cast<Eyedropper *>(op->customdata);
606
607 /* handle modal keymap */
608 if (event->type == EVT_MODAL_MAP) {
609 switch (event->val) {
610 case EYE_MODAL_CANCEL:
611 eyedropper_cancel(C, op);
612 return OPERATOR_CANCELLED;
614 const bool is_undo = eye->is_undo;
615 if (eye->accum_tot == 0) {
616 eyedropper_color_sample(C, eye, event->xy);
617 }
618 eyedropper_exit(C, op);
619 /* Could support finished & undo-skip. */
620 return is_undo ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
621 }
623 /* enable accum and make first sample */
624 eye->accum_start = true;
625 eyedropper_color_sample(C, eye, event->xy);
626 break;
628 eye->accum_tot = 0;
629 zero_v3(eye->accum_col);
630 eyedropper_color_sample(C, eye, event->xy);
631 break;
632 }
633 }
634 else if (ISMOUSE_MOTION(event->type)) {
635 if (eye->accum_start) {
636 /* button is pressed so keep sampling */
637 eyedropper_color_sample(C, eye, event->xy);
638 WorkspaceStatus status(C);
639 status.item(TIP_("Drag to continue sampling, release when done"), ICON_MOUSE_MOVE);
640 }
641 else {
642 WorkspaceStatus status(C);
643 status.opmodal(IFACE_("Confirm"), op->type, EYE_MODAL_SAMPLE_CONFIRM);
644 status.opmodal(IFACE_("Cancel"), op->type, EYE_MODAL_CANCEL);
645#ifdef __APPLE__
646 status.item(TIP_("Press 'Enter' to sample outside of a Blender window"), ICON_STATUS_INFO);
647#endif
648 }
649
650 if (eye->draw_handle_sample_text) {
652 }
653 }
654
656}
657
658/* Modal Operator init */
660{
661 /* init */
662 if (eyedropper_init(C, op)) {
663 wmWindow *win = CTX_wm_window(C);
664 /* Workaround for de-activating the button clearing the cursor, see #76794 */
667
668 /* add temp handler */
670
672 }
674}
675
676/* Repeat operator */
678{
679 /* init */
680 if (eyedropper_init(C, op)) {
681
682 /* do something */
683
684 /* cleanup */
685 eyedropper_exit(C, op);
686
687 return OPERATOR_FINISHED;
688 }
690}
691
693{
694 /* Actual test for active button happens later, since we don't
695 * know which one is active until mouse over. */
696 return (CTX_wm_window(C) != nullptr);
697}
698
700{
701 /* identifiers */
702 ot->name = "Eyedropper";
703 ot->idname = "UI_OT_eyedropper_color";
704 ot->description = "Sample a color from the Blender window to store in a property";
705
706 /* API callbacks. */
710 ot->exec = eyedropper_exec;
711 ot->poll = eyedropper_poll;
712
713 /* flags */
715
716 /* Paths relative to the context. */
717 PropertyRNA *prop;
718 prop = RNA_def_string(ot->srna,
719 "prop_data_path",
720 nullptr,
721 0,
722 "Data Path",
723 "Path of property to be set with the depth");
725}
726
727} // namespace blender::ui
General operations, lookup, etc. for materials.
#define STRNLEN(str)
#define TIP_(msgid)
#define IFACE_(msgid)
#define MAX_NAME
Definition DNA_defs.h:63
#define RE_PASSNAME_CRYPTOMATTE_MATERIAL
#define RE_PASSNAME_CRYPTOMATTE_OBJECT
#define SPACE_TYPE_ANY
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define STRPREFIX(a, b)
#define STREQLEN(a, b, n)
#define ELEM(...)
constexpr StringRef()
bool sample(const int mval[2], float r_col[3])
void item(std::string text, int icon1, int icon2=0)
Definition area.cc:1076
void opmodal(std::string text, const wmOperatorType *ot, int propvalue, bool inverted=false)
Definition area.cc:1107
static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, const int event_xy[2])
bool eyedropper_color_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
get the color from the screen.
static bool eyedropper_cryptomatte_sample_view3d_fl(bContext *C, const char *type_name, const int mval[2], float r_col[3])
static bool eyedropper_poll(bContext *C)
static wmOperatorStatus eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
bool button_flag_is_set(Button *but, int64_t flag)
static bool eyedropper_init(bContext *C, wmOperator *op)
static wmOperatorStatus eyedropper_exec(bContext *C, wmOperator *op)
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int event_xy[2])
void eyedropper_draw_cursor_text_region(const int xy[2], const char *name)
static void eyedropper_exit(bContext *C, wmOperator *op)
static wmOperatorStatus eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *)
Button * context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
static void eyedropper_cancel(bContext *C, wmOperator *op)
void UI_OT_eyedropper_color(wmOperatorType *ot)
static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
static bool eyedropper_cryptomatte_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
static bool eyedropper_cryptomatte_sample_renderlayer_fl(RenderLayer *render_layer, const char *prefix, const float fpos[2], float r_col[3])
static void eyedropper_draw_cb(const wmWindow *, void *arg)
static bool eyedropper_cryptomatte_sample_image_fl(bContext *C, const bNode *node, NodeCryptomatte *crypto, const char *prefix, const float fpos[2], float r_col[3])
static bool eyedropper_cryptomatte_sample_render_fl(const bNode *node, const char *prefix, const float fpos[2], float r_col[3])
void context_active_but_clear(bContext *C, wmWindow *win, ARegion *region)
void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool BKE_cryptomatte_find_name(const struct CryptomatteSession *session, float encoded_hash, char *r_name, int name_maxncpy)
ScrArea * CTX_wm_area(const bContext *C)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ IMA_TYPE_MULTILAYER
void RNA_property_float_get_array_at_most(PointerRNA *ptr, PropertyRNA *prop, float *values, int values_num)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
MINLINE void copy_v3_v3(float r[3], const float a[3])
bool ED_space_clip_get_position(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_fpos[2])
bool RNA_path_resolve(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition rna_path.cc:529
Material * BKE_object_material_get(Object *ob, short act)
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Object * ED_view3d_give_material_slot_under_cursor(bContext *C, const int mval[2], int *r_material_slot)
wmWindow * WM_window_find_under_cursor(wmWindow *win, const int event_xy[2], int r_event_xy_other[2])
void WM_cursor_modal_set(wmWindow *win, int val)
wmWindow * CTX_wm_window(const bContext *C)
bool WM_window_pixels_read_sample_from_offscreen(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
Definition wm_draw.cc:1524
bool ED_space_image_get_position(SpaceImage *sima, ARegion *region, const int mval[2], float r_fpos[2])
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
uint32_t BKE_cryptomatte_hash(const char *name, int name_len)
void WM_draw_cb_exit(wmWindow *win, void *handle)
Definition wm_draw.cc:652
CryptomatteSession * ntreeCompositCryptomatteSession(bNode *node)
PropertyType RNA_property_type(PropertyRNA *prop)
unsigned int uint32_t
Definition BKE_text.h:81
Render * RE_GetSceneRender(const Scene *scene)
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
Definition wm_draw.cc:1583
bool WM_desktop_cursor_sample_read(float r_col[3])
Definition wm_draw.cc:1592
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
bool ED_space_clip_color_sample(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_col[3])
bool BKE_main_view_layers_synced_ensure(const Main *bmain)
void WM_cursor_modal_restore(wmWindow *win)
void ntreeCompositCryptomatteLayerPrefix(const bNode *node, char *r_prefix, size_t prefix_maxncpy)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void RNA_property_float_set_array_at_most(PointerRNA *ptr, PropertyRNA *prop, const float *values, int values_num)
bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3])
Definition node_view.cc:549
MINLINE void zero_v3(float r[3])
ScrArea ScrArea * BKE_screen_find_area_xy(const bScreen *screen, int spacetype, const int xy[2]) ATTR_NONNULL(1
Definition screen.cc:1226
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], const ColorManagedDisplay *display, ColorManagedDisplaySpace display_space=DISPLAY_SPACE_DRAW)
RenderResult * RE_AcquireResultRead(Render *re)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
@ WM_CAPABILITY_DESKTOP_SAMPLE
Definition WM_api.hh:237
PropertySubType RNA_property_subtype(PropertyRNA *prop)
MINLINE void add_v3_v3(float r[3], const float a[3])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], const ColorManagedDisplay *display, ColorManagedDisplaySpace display_space=DISPLAY_SPACE_DRAW)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
@ WM_CURSOR_EYEDROPPER
Definition wm_cursors.hh:38
Main * CTX_data_main(const bContext *C)
eWM_CapabilitiesFlag WM_capabilities_flag()
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
const ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
float BKE_cryptomatte_hash_to_float(uint32_t cryptomatte_hash)
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_BLOCKING
Definition WM_types.hh:192
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
std::string RNA_string_get(PointerRNA *ptr, const char *name)
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const wmWindow *win, void *customdata), void *customdata)
Definition wm_draw.cc:639
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:329
@ CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE
@ CMP_NODE_CRYPTOMATTE_SOURCE_RENDER
bool ED_space_node_get_position(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float fpos[2])
Definition node_view.cc:522
bScreen * WM_window_get_active_screen(const wmWindow *win)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
void BKE_cryptomatte_free(struct CryptomatteSession *session)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
ocio::Display ColorManagedDisplay
void CTX_wm_area_set(bContext *C, ScrArea *area)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
ARegion * BKE_area_find_region_xy(const ScrArea *area, int regiontype, const int xy[2]) ATTR_NONNULL(3)
Definition screen.cc:1053
char name[258]
Definition DNA_ID.h:433
const float * float_data() const
StructRNA * type
Definition RNA_types.hh:63
ListBaseT< RenderPass > passes
Definition RE_pipeline.h:99
char name[RE_MAXNAME]
Definition RE_pipeline.h:94
struct ImBuf * ibuf
Definition RE_pipeline.h:72
ListBaseT< ViewLayer > view_layers
ColorManagedDisplaySettings display_settings
struct RenderData r
ListBaseT< SpaceLink > spacedata
CryptomatteSession * cryptomatte_session
const ColorManagedDisplay * display
ViewportColorSampleSession * viewport_session
wmEventType type
Definition WM_types.hh:817
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports
struct wmOperatorType * type
#define ISMOUSE_MOTION(event_type)