Fix T91662: VSE Image overlay is drawn for backdrop
[blender.git] / source / blender / draw / DRW_select_buffer.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2016, Blender Foundation.
17  */
18
19 /** \file
20  * \ingroup draw
21  */
22
23 #pragma once
24
25 #include "BLI_sys_types.h" /* for bool and uint */
26
27 struct ARegion;
28 struct Base;
29 struct Depsgraph;
30 struct Object;
31 struct View3D;
32 struct rcti;
33
34 typedef struct SELECTID_ObjectData {
35   DrawData dd;
36
37   uint drawn_index;
38   bool is_drawn;
39 } SELECTID_ObjectData;
40
41 struct ObjectOffsets {
42   /* For convenience only. */
43   union {
44     uint offset;
45     uint face_start;
46   };
47   union {
48     uint face;
49     uint edge_start;
50   };
51   union {
52     uint edge;
53     uint vert_start;
54   };
55   uint vert;
56 };
57
58 typedef struct SELECTID_Context {
59   /* All context objects */
60   struct Object **objects;
61
62   /* Array with only drawn objects. When a new object is found within the rect,
63    * it is added to the end of the list.
64    * The list is reset to any viewport or context update. */
65   struct Object **objects_drawn;
66   struct ObjectOffsets *index_offsets;
67   uint objects_len;
68   uint objects_drawn_len;
69
70   /** Total number of element indices `index_offsets[object_drawn_len - 1].vert`. */
71   uint index_drawn_len;
72
73   short select_mode;
74
75   /* rect is used to check which objects whose indexes need to be drawn. */
76   rcti last_rect;
77
78   /* To check for updates. */
79   float persmat[4][4];
80   bool is_dirty;
81 } SELECTID_Context;
82
83 /* draw_select_buffer.c */
84 bool DRW_select_buffer_elem_get(const uint sel_id,
85                                 uint *r_elem,
86                                 uint *r_base_index,
87                                 char *r_elem_type);
88 uint DRW_select_buffer_context_offset_for_object_elem(struct Depsgraph *depsgraph,
89                                                       struct Object *object,
90                                                       char elem_type);
91 uint *DRW_select_buffer_read(struct Depsgraph *depsgraph,
92                              struct ARegion *region,
93                              struct View3D *v3d,
94                              const rcti *rect,
95                              uint *r_buf_len);
96 uint *DRW_select_buffer_bitmap_from_rect(struct Depsgraph *depsgraph,
97                                          struct ARegion *region,
98                                          struct View3D *v3d,
99                                          const struct rcti *rect,
100                                          uint *r_bitmap_len);
101 uint *DRW_select_buffer_bitmap_from_circle(struct Depsgraph *depsgraph,
102                                            struct ARegion *region,
103                                            struct View3D *v3d,
104                                            const int center[2],
105                                            const int radius,
106                                            uint *r_bitmap_len);
107 uint *DRW_select_buffer_bitmap_from_poly(struct Depsgraph *depsgraph,
108                                          struct ARegion *region,
109                                          struct View3D *v3d,
110                                          const int poly[][2],
111                                          const int poly_len,
112                                          const struct rcti *rect,
113                                          uint *r_bitmap_len);
114 uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph,
115                                     struct ARegion *region,
116                                     struct View3D *v3d,
117                                     const int center[2]);
118 uint DRW_select_buffer_find_nearest_to_point(struct Depsgraph *depsgraph,
119                                              struct ARegion *region,
120                                              struct View3D *v3d,
121                                              const int center[2],
122                                              const uint id_min,
123                                              const uint id_max,
124                                              uint *dist);
125 void DRW_select_buffer_context_create(struct Base **bases,
126                                       const uint bases_len,
127                                       short select_mode);