Blender V4.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
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.h"
22#include "BLI_math_vector.h"
23#include "BLI_string.h"
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_material.h"
30#include "BKE_report.hh"
31#include "BKE_screen.hh"
32
33#include "NOD_composite.hh"
34
35#include "RNA_access.hh"
36#include "RNA_define.hh"
37#include "RNA_path.hh"
38#include "RNA_prototypes.hh"
39
40#include "UI_interface.hh"
41
43#include "IMB_imbuf_types.hh"
44
45#include "WM_api.hh"
46#include "WM_types.hh"
47
48#include "interface_intern.hh"
49
50#include "ED_clip.hh"
51#include "ED_image.hh"
52#include "ED_node.hh"
53#include "ED_screen.hh"
54#include "ED_view3d.hh"
55
56#include "RE_pipeline.h"
57
58#include "eyedropper_intern.hh"
59
84
85static void eyedropper_draw_cb(const wmWindow * /*window*/, void *arg)
86{
87 Eyedropper *eye = static_cast<Eyedropper *>(arg);
89}
90
92{
93 Eyedropper *eye = MEM_new<Eyedropper>(__func__);
94
95 PropertyRNA *prop;
96 if ((prop = RNA_struct_find_property(op->ptr, "prop_data_path")) &&
97 RNA_property_is_set(op->ptr, prop))
98 {
99 char *prop_data_path = RNA_string_get_alloc(op->ptr, "prop_data_path", nullptr, 0, nullptr);
100 BLI_SCOPED_DEFER([&] { MEM_SAFE_FREE(prop_data_path); });
101 if (!prop_data_path || prop_data_path[0] == '\0') {
102 MEM_freeN(eye);
103 return false;
104 }
105 PointerRNA ctx_ptr = RNA_pointer_create(nullptr, &RNA_Context, C);
106 if (!RNA_path_resolve(&ctx_ptr, prop_data_path, &eye->ptr, &eye->prop)) {
107 BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", prop_data_path);
108 MEM_freeN(eye);
109 return false;
110 }
111 eye->is_undo = true;
112 }
113 else {
114 uiBut *but = UI_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.data == nullptr) || (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) {
137 eye->crypto_node = (bNode *)eye->ptr.data;
139 eye->cb_win = CTX_wm_window(C);
141 }
142
143 if (prop_subtype != PROP_COLOR) {
144 Scene *scene = CTX_data_scene(C);
145 const char *display_device;
146
147 display_device = scene->display_settings.display_device;
148 eye->display = IMB_colormanagement_display_get_named(display_device);
149
150 /* store initial color */
151 if (eye->display) {
153 }
154 }
155 copy_v3_v3(eye->init_col, col);
156
157 return true;
158}
159
161{
162 Eyedropper *eye = static_cast<Eyedropper *>(op->customdata);
163 wmWindow *window = CTX_wm_window(C);
165
166 if (eye->draw_handle_sample_text) {
168 eye->draw_handle_sample_text = nullptr;
169 }
170
171 if (eye->cryptomatte_session) {
173 eye->cryptomatte_session = nullptr;
174 }
175
176 if (eye->viewport_session) {
177 MEM_delete(eye->viewport_session);
178 eye->viewport_session = nullptr;
179 }
180
181 op->customdata = nullptr;
182 MEM_delete(eye);
183}
184
185/* *** eyedropper_color_ helper functions *** */
186
188 const char *type_name,
189 const int mval[2],
190 float r_col[3])
191{
192 int material_slot = 0;
193 Object *object = ED_view3d_give_material_slot_under_cursor(C, mval, &material_slot);
194 if (!object) {
195 return false;
196 }
197
198 const ID *id = nullptr;
199 if (blender::StringRef(type_name).endswith(RE_PASSNAME_CRYPTOMATTE_OBJECT)) {
200 id = &object->id;
201 }
202 else if (blender::StringRef(type_name).endswith(RE_PASSNAME_CRYPTOMATTE_MATERIAL)) {
203 Material *material = BKE_object_material_get(object, material_slot);
204 if (!material) {
205 return false;
206 }
207 id = &material->id;
208 }
209
210 if (!id) {
211 return false;
212 }
213
214 const char *name = &id->name[2];
215 const int name_length = BLI_strnlen(name, MAX_NAME - 2);
216 uint32_t cryptomatte_hash = BKE_cryptomatte_hash(name, name_length);
217 r_col[0] = BKE_cryptomatte_hash_to_float(cryptomatte_hash);
218 return true;
219}
220
222 const char *prefix,
223 const float fpos[2],
224 float r_col[3])
225{
226 if (!render_layer) {
227 return false;
228 }
229
230 const int render_layer_name_len = BLI_strnlen(render_layer->name, sizeof(render_layer->name));
231 if (strncmp(prefix, render_layer->name, render_layer_name_len) != 0) {
232 return false;
233 }
234
235 const int prefix_len = strlen(prefix);
236 if (prefix_len <= render_layer_name_len + 1) {
237 return false;
238 }
239
240 /* RenderResult from images can have no render layer name. */
241 const char *render_pass_name_prefix = render_layer_name_len ?
242 prefix + 1 + render_layer_name_len :
243 prefix;
244
245 LISTBASE_FOREACH (RenderPass *, render_pass, &render_layer->passes) {
246 if (STRPREFIX(render_pass->name, render_pass_name_prefix) &&
247 !STREQLEN(render_pass->name, render_pass_name_prefix, sizeof(render_pass->name)))
248 {
249 BLI_assert(render_pass->channels == 4);
250
251 /* Pass was allocated but not rendered yet. */
252 if (!render_pass->ibuf) {
253 return false;
254 }
255
256 const int x = int(fpos[0] * render_pass->rectx);
257 const int y = int(fpos[1] * render_pass->recty);
258 const int offset = 4 * (y * render_pass->rectx + x);
259 zero_v3(r_col);
260 r_col[0] = render_pass->ibuf->float_buffer.data[offset];
261 return true;
262 }
263 }
264
265 return false;
266}
267
269 const char *prefix,
270 const float fpos[2],
271 float r_col[3])
272{
273 bool success = false;
274 Scene *scene = (Scene *)node->id;
275 BLI_assert(GS(scene->id.name) == ID_SCE);
276 Render *re = RE_GetSceneRender(scene);
277
278 if (re) {
280 if (rr) {
281 LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
282 RenderLayer *render_layer = RE_GetRenderLayer(rr, view_layer->name);
283 success = eyedropper_cryptomatte_sample_renderlayer_fl(render_layer, prefix, fpos, r_col);
284 if (success) {
285 break;
286 }
287 }
288 }
290 }
291 return success;
292}
293
295 NodeCryptomatte *crypto,
296 const char *prefix,
297 const float fpos[2],
298 float r_col[3])
299{
300 bool success = false;
301 Image *image = (Image *)node->id;
302 BLI_assert((image == nullptr) || (GS(image->id.name) == ID_IM));
303 ImageUser *iuser = &crypto->iuser;
304
305 if (image && image->type == IMA_TYPE_MULTILAYER) {
306 ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, nullptr);
307 if (image->rr) {
308 LISTBASE_FOREACH (RenderLayer *, render_layer, &image->rr->layers) {
309 success = eyedropper_cryptomatte_sample_renderlayer_fl(render_layer, prefix, fpos, r_col);
310 if (success) {
311 break;
312 }
313 }
314 }
315 BKE_image_release_ibuf(image, ibuf, nullptr);
316 }
317 return success;
318}
319
321 Eyedropper *eye,
322 const int event_xy[2],
323 float r_col[3])
324{
325 bNode *node = eye->crypto_node;
326 NodeCryptomatte *crypto = node ? ((NodeCryptomatte *)node->storage) : nullptr;
327
328 if (!crypto) {
329 return false;
330 }
331
332 ScrArea *area = nullptr;
333
334 int event_xy_win[2];
335 wmWindow *win = WM_window_find_under_cursor(CTX_wm_window(C), event_xy, event_xy_win);
336 if (win) {
338 area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event_xy_win);
339 }
340
341 eye->cb_win_event_xy[0] = event_xy_win[0];
342 eye->cb_win_event_xy[1] = event_xy_win[1];
343
344 if (win && win != eye->cb_win && eye->draw_handle_sample_text) {
346 eye->cb_win = win;
349 }
350
351 if (!area || !ELEM(area->spacetype, SPACE_IMAGE, SPACE_NODE, SPACE_CLIP, SPACE_VIEW3D)) {
352 return false;
353 }
354
355 ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, event_xy_win);
356
357 if (!region) {
358 return false;
359 }
360
361 const int mval[2] = {
362 event_xy_win[0] - region->winrct.xmin,
363 event_xy_win[1] - region->winrct.ymin,
364 };
365 float fpos[2] = {-1.0f, -1.0};
366 switch (area->spacetype) {
367 case SPACE_IMAGE: {
368 SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
369 ED_space_image_get_position(sima, region, mval, fpos);
370 break;
371 }
372 case SPACE_NODE: {
373 Main *bmain = CTX_data_main(C);
374 SpaceNode *snode = static_cast<SpaceNode *>(area->spacedata.first);
375 ED_space_node_get_position(bmain, snode, region, mval, fpos);
376 break;
377 }
378 case SPACE_CLIP: {
379 SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
380 ED_space_clip_get_position(sc, region, mval, fpos);
381 break;
382 }
383 default: {
384 break;
385 }
386 }
387
388 if (area->spacetype != SPACE_VIEW3D &&
389 (fpos[0] < 0.0f || fpos[1] < 0.0f || fpos[0] >= 1.0f || fpos[1] >= 1.0f))
390 {
391 return false;
392 }
393
394 /* CMP_NODE_CRYPTOMATTE_SOURCE_RENDER and CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE require a referenced
395 * image/scene to work properly. */
396 if (!node->id) {
397 return false;
398 }
399
400 ED_region_tag_redraw(region);
401
402 /* TODO(jbakker): Migrate this file to cc and use std::string as return param. */
403 char prefix[MAX_NAME + 1];
404 ntreeCompositCryptomatteLayerPrefix(node, prefix, sizeof(prefix) - 1);
405 prefix[MAX_NAME] = '\0';
406
407 if (area->spacetype == SPACE_VIEW3D) {
408 wmWindow *win_prev = CTX_wm_window(C);
409 ScrArea *area_prev = CTX_wm_area(C);
410 ARegion *region_prev = CTX_wm_region(C);
411
412 CTX_wm_window_set(C, win);
413 CTX_wm_area_set(C, area);
414 CTX_wm_region_set(C, region);
415
416 const bool success = eyedropper_cryptomatte_sample_view3d_fl(C, prefix, mval, r_col);
417
418 CTX_wm_window_set(C, win_prev);
419 CTX_wm_area_set(C, area_prev);
420 CTX_wm_region_set(C, region_prev);
421
422 return success;
423 }
424 if (node->custom1 == CMP_NODE_CRYPTOMATTE_SOURCE_RENDER) {
425 return eyedropper_cryptomatte_sample_render_fl(node, prefix, fpos, r_col);
426 }
427 if (node->custom1 == CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE) {
428 return eyedropper_cryptomatte_sample_image_fl(node, crypto, prefix, fpos, r_col);
429 }
430 return false;
431}
432
434 Eyedropper *eye,
435 const int event_xy[2],
436 float r_col[3])
437{
438 ScrArea *area = nullptr;
439
440 int event_xy_win[2];
441 wmWindow *win = WM_window_find_under_cursor(CTX_wm_window(C), event_xy, event_xy_win);
442 if (win) {
444 area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event_xy_win);
445 }
446
447 if (area) {
448 ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, event_xy_win);
449 if (region) {
450 const int mval[2] = {
451 event_xy_win[0] - region->winrct.xmin,
452 event_xy_win[1] - region->winrct.ymin,
453 };
454 if (area->spacetype == SPACE_IMAGE) {
455 SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
456 if (ED_space_image_color_sample(sima, region, mval, r_col, nullptr)) {
457 return;
458 }
459 }
460 else if (area->spacetype == SPACE_NODE) {
461 SpaceNode *snode = static_cast<SpaceNode *>(area->spacedata.first);
462 Main *bmain = CTX_data_main(C);
463 if (ED_space_node_color_sample(bmain, snode, region, mval, r_col)) {
464 return;
465 }
466 }
467 else if (area->spacetype == SPACE_CLIP) {
468 SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
469 if (ED_space_clip_color_sample(sc, region, mval, r_col)) {
470 return;
471 }
472 }
473 else if (eye != nullptr && area->spacetype == SPACE_VIEW3D) {
474 /* Viewport color picking involves a fairly expensive operation to copy the GPU viewport
475 * back to the CPU, so to support smooth dragging with the eyedropper, we keep the copy
476 * around for the entire operation. */
477 if (eye->viewport_session == nullptr) {
478 eye->viewport_session = MEM_new<ViewportColorSampleSession>("viewport_session");
479 eye->viewport_session->init(region);
480 }
481 if (eye->viewport_session->sample(mval, r_col)) {
482 return;
483 }
484 }
485 }
486 }
487
488 if (win) {
489 /* Other areas within a Blender window. */
490 if (!WM_window_pixels_read_sample(C, win, event_xy_win, r_col)) {
491 WM_window_pixels_read_sample_from_offscreen(C, win, event_xy_win, r_col);
492 }
493 const char *display_device = CTX_data_scene(C)->display_settings.display_device;
496 }
499 {
500 /* Outside of the Blender window if we support it. */
502 }
503 else {
504 zero_v3(r_col);
505 }
506}
507
508/* sets the sample color RGB, maintaining A */
509static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
510{
511 float col_conv[4];
512
513 /* to maintain alpha */
514 RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv);
515
516 /* convert from linear rgb space to display space */
517 if (eye->display) {
518 copy_v3_v3(col_conv, col);
520 }
521 else {
522 copy_v3_v3(col_conv, col);
523 }
524
525 RNA_property_float_set_array(&eye->ptr, eye->prop, col_conv);
526 eye->is_set = true;
527
528 RNA_property_update(C, &eye->ptr, eye->prop);
529}
530
531static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int event_xy[2])
532{
533 /* Accumulate color. */
534 float col[3];
535 if (eye->crypto_node) {
536 if (!eyedropper_cryptomatte_sample_fl(C, eye, event_xy, col)) {
537 return;
538 }
539 }
540 else {
541 eyedropper_color_sample_fl(C, eye, event_xy, col);
542 }
543
544 if (!eye->crypto_node) {
545 add_v3_v3(eye->accum_col, col);
546 eye->accum_tot++;
547 }
548 else {
549 copy_v3_v3(eye->accum_col, col);
550 eye->accum_tot = 1;
551 }
552
553 /* Apply to property. */
554 float accum_col[3];
555 if (eye->accum_tot > 1) {
556 mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / float(eye->accum_tot));
557 }
558 else {
559 copy_v3_v3(accum_col, eye->accum_col);
560 }
561 eyedropper_color_set(C, eye, accum_col);
562}
563
565 Eyedropper *eye,
566 const int event_xy[2])
567{
568 float col[3];
569 eye->sample_text[0] = '\0';
570
571 if (eye->cryptomatte_session) {
572 if (eyedropper_cryptomatte_sample_fl(C, eye, event_xy, col)) {
574 eye->cryptomatte_session, col[0], eye->sample_text, sizeof(eye->sample_text));
575 eye->sample_text[sizeof(eye->sample_text) - 1] = '\0';
576 }
577 }
578}
579
581{
582 Eyedropper *eye = static_cast<Eyedropper *>(op->customdata);
583 if (eye->is_set) {
584 eyedropper_color_set(C, eye, eye->init_col);
585 }
586 eyedropper_exit(C, op);
587}
588
589/* main modal status check */
590static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
591{
592 Eyedropper *eye = (Eyedropper *)op->customdata;
593
594 /* handle modal keymap */
595 if (event->type == EVT_MODAL_MAP) {
596 switch (event->val) {
597 case EYE_MODAL_CANCEL:
598 eyedropper_cancel(C, op);
599 return OPERATOR_CANCELLED;
601 const bool is_undo = eye->is_undo;
602 if (eye->accum_tot == 0) {
603 eyedropper_color_sample(C, eye, event->xy);
604 }
605 eyedropper_exit(C, op);
606 /* Could support finished & undo-skip. */
607 return is_undo ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
608 }
610 /* enable accum and make first sample */
611 eye->accum_start = true;
612 eyedropper_color_sample(C, eye, event->xy);
613 break;
615 eye->accum_tot = 0;
616 zero_v3(eye->accum_col);
617 eyedropper_color_sample(C, eye, event->xy);
618 break;
619 }
620 }
621 else if (ISMOUSE_MOTION(event->type)) {
622 if (eye->accum_start) {
623 /* button is pressed so keep sampling */
624 eyedropper_color_sample(C, eye, event->xy);
625 }
626
627 if (eye->draw_handle_sample_text) {
629 }
630 }
631
633}
634
635/* Modal Operator init */
636static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
637{
638 /* init */
639 if (eyedropper_init(C, op)) {
640 wmWindow *win = CTX_wm_window(C);
641 /* Workaround for de-activating the button clearing the cursor, see #76794 */
644
645 /* add temp handler */
647
649 }
651}
652
653/* Repeat operator */
655{
656 /* init */
657 if (eyedropper_init(C, op)) {
658
659 /* do something */
660
661 /* cleanup */
662 eyedropper_exit(C, op);
663
664 return OPERATOR_FINISHED;
665 }
667}
668
670{
671 /* Actual test for active button happens later, since we don't
672 * know which one is active until mouse over. */
673 return (CTX_wm_window(C) != nullptr);
674}
675
677{
678 /* identifiers */
679 ot->name = "Eyedropper";
680 ot->idname = "UI_OT_eyedropper_color";
681 ot->description = "Sample a color from the Blender window to store in a property";
682
683 /* api callbacks */
689
690 /* flags */
692
693 /* Paths relative to the context. */
694 PropertyRNA *prop;
695 prop = RNA_def_string(ot->srna,
696 "prop_data_path",
697 nullptr,
698 0,
699 "Data Path",
700 "Path of property to be set with the depth");
702}
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Main * CTX_data_main(const bContext *C)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
float BKE_cryptomatte_hash_to_float(uint32_t cryptomatte_hash)
uint32_t BKE_cryptomatte_hash(const char *name, int name_len)
bool BKE_cryptomatte_find_name(const struct CryptomatteSession *session, float encoded_hash, char *r_name, int name_maxncpy)
void BKE_cryptomatte_free(struct CryptomatteSession *session)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
ARegion * BKE_area_find_region_xy(const ScrArea *area, int regiontype, const int xy[2]) ATTR_NONNULL(3)
Definition screen.cc:844
ScrArea ScrArea * BKE_screen_find_area_xy(const bScreen *screen, int spacetype, const int xy[2]) ATTR_NONNULL(1
#define BLI_assert(a)
Definition BLI_assert.h:50
#define LISTBASE_FOREACH(type, var, list)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
#define BLI_SCOPED_DEFER(function_to_defer)
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition string.c:909
#define STRPREFIX(a, b)
#define STREQLEN(a, b, n)
#define ELEM(...)
@ ID_IM
@ ID_SCE
#define MAX_NAME
Definition DNA_defs.h:50
@ IMA_TYPE_MULTILAYER
@ CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE
@ CMP_NODE_CRYPTOMATTE_SOURCE_RENDER
#define RE_PASSNAME_CRYPTOMATTE_MATERIAL
#define RE_PASSNAME_CRYPTOMATTE_OBJECT
@ RGN_TYPE_WINDOW
@ SPACE_CLIP
@ SPACE_NODE
@ SPACE_IMAGE
@ SPACE_VIEW3D
#define SPACE_TYPE_ANY
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
bool ED_space_clip_get_position(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_fpos[2])
bool ED_space_clip_color_sample(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_col[3])
bool ED_space_image_get_position(SpaceImage *sima, ARegion *region, const int mval[2], float r_fpos[2])
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
bool ED_space_node_get_position(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float fpos[2])
Definition node_view.cc:469
bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3])
Definition node_view.cc:496
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:634
Object * ED_view3d_give_material_slot_under_cursor(bContext *C, const int mval[2], int *r_material_slot)
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManagedDisplay *display)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManagedDisplay *display)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_SKIP_SAVE
Definition RNA_types.hh:245
@ PROP_HIDDEN
Definition RNA_types.hh:239
PropertySubType
Definition RNA_types.hh:135
@ PROP_COLOR
Definition RNA_types.hh:163
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:175
uiBut * UI_context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
void UI_context_active_but_clear(bContext *C, wmWindow *win, ARegion *region)
bool UI_but_flag_is_set(uiBut *but, int flag)
@ UI_BUT_UNDO
@ WM_CAPABILITY_DESKTOP_SAMPLE
Definition WM_api.hh:184
@ OPTYPE_INTERNAL
Definition WM_types.hh:182
@ OPTYPE_BLOCKING
Definition WM_types.hh:164
@ OPTYPE_UNDO
Definition WM_types.hh:162
bool init(ARegion *region)
bool sample(const int mval[2], float r_col[3])
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, const int event_xy[2])
static bool eyedropper_init(bContext *C, wmOperator *op)
static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
static void eyedropper_cancel(bContext *C, wmOperator *op)
static void eyedropper_exit(bContext *C, wmOperator *op)
static bool eyedropper_cryptomatte_sample_renderlayer_fl(RenderLayer *render_layer, const char *prefix, const float fpos[2], float r_col[3])
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int event_xy[2])
static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bool eyedropper_cryptomatte_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void eyedropper_draw_cb(const wmWindow *, void *arg)
static bool eyedropper_cryptomatte_sample_render_fl(const bNode *node, const char *prefix, const float fpos[2], float r_col[3])
void UI_OT_eyedropper_color(wmOperatorType *ot)
static bool eyedropper_poll(bContext *C)
static bool eyedropper_cryptomatte_sample_image_fl(const bNode *node, NodeCryptomatte *crypto, const char *prefix, const float fpos[2], float r_col[3])
static int eyedropper_exec(bContext *C, wmOperator *op)
static bool eyedropper_cryptomatte_sample_view3d_fl(bContext *C, const char *type_name, const int mval[2], float r_col[3])
void eyedropper_color_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
@ EYE_MODAL_SAMPLE_BEGIN
@ EYE_MODAL_SAMPLE_RESET
@ EYE_MODAL_CANCEL
@ EYE_MODAL_SAMPLE_CONFIRM
void eyedropper_draw_cursor_text_region(const int xy[2], const char *name)
uint col
#define GS(x)
Definition iris.cc:202
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void ntreeCompositCryptomatteLayerPrefix(const bNode *node, char *r_prefix, size_t prefix_maxncpy)
CryptomatteSession * ntreeCompositCryptomatteSession(bNode *node)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
PropertyType RNA_property_type(PropertyRNA *prop)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
bool RNA_path_resolve(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition rna_path.cc:525
RenderResult * RE_AcquireResultRead(Render *re)
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
void RE_ReleaseResult(Render *re)
Render * RE_GetSceneRender(const Scene *scene)
unsigned int uint32_t
Definition stdint.h:80
bNode * crypto_node
int cb_win_event_xy[2]
char sample_text[MAX_NAME]
float accum_col[3]
ColorManagedDisplay * display
ViewportColorSampleSession * viewport_session
float init_col[3]
PropertyRNA * prop
PointerRNA ptr
CryptomatteSession * cryptomatte_session
void * draw_handle_sample_text
wmWindow * cb_win
Definition DNA_ID.h:413
StructRNA * type
Definition RNA_types.hh:41
void * data
Definition RNA_types.hh:42
ListBase passes
Definition RE_pipeline.h:97
char name[RE_MAXNAME]
Definition RE_pipeline.h:89
ColorManagedDisplaySettings display_settings
short val
Definition WM_types.hh:724
int xy[2]
Definition WM_types.hh:726
short type
Definition WM_types.hh:722
const char * name
Definition WM_types.hh:990
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1042
const char * idname
Definition WM_types.hh:992
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1036
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1022
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1006
const char * description
Definition WM_types.hh:996
StructRNA * srna
Definition WM_types.hh:1080
void(* cancel)(bContext *C, wmOperator *op)
Definition WM_types.hh:1028
struct ReportList * reports
struct PointerRNA * ptr
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
@ WM_CURSOR_EYEDROPPER
Definition wm_cursors.hh:35
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const wmWindow *win, void *customdata), void *customdata)
Definition wm_draw.cc:607
bool WM_window_pixels_read_sample_from_offscreen(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
Definition wm_draw.cc:1380
void WM_draw_cb_exit(wmWindow *win, void *handle)
Definition wm_draw.cc:620
bool WM_desktop_cursor_sample_read(float r_col[3])
Definition wm_draw.cc:1428
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
Definition wm_draw.cc:1419
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
#define ISMOUSE_MOTION(event_type)
@ EVT_MODAL_MAP
wmOperatorType * ot
Definition wm_files.cc:4125
wmWindow * WM_window_find_under_cursor(wmWindow *win, const int event_xy[2], int r_event_xy_other[2])
eWM_CapabilitiesFlag WM_capabilities_flag()
bScreen * WM_window_get_active_screen(const wmWindow *win)