50 state.do_shader_unbind =
true;
61 const bool use_filter,
69 static const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
70 const float draw_width = img_w * scaleX * xzoom;
71 const float draw_height = img_h * scaleY * yzoom;
75 const bool use_mipmap = use_filter && ((draw_width < img_w) || (draw_height < img_h));
76 const int mip_len = use_mipmap ? 9999 : 1;
118 if (
state->do_shader_unbind) {
142 const float color[4])
144 int subpart_x, subpart_y, tex_w = 256, tex_h = 256;
156 int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y;
158 const bool use_clipping = ((clip_min_x < clip_max_x) && (clip_min_y < clip_max_y));
159 const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
177 size_t stride = components * ((use_float_data) ?
sizeof(
float) :
sizeof(
uchar));
188 seamless = ((tex_w < img_w || tex_h < img_h) && tex_w > 2 && tex_h > 2) ? 2 : 0;
190 offset_x = tex_w - seamless;
191 offset_y = tex_h - seamless;
193 nsubparts_x = (img_w + (offset_x - 1)) / (offset_x);
194 nsubparts_y = (img_h + (offset_y - 1)) / (offset_y);
206 for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) {
207 for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) {
208 int remainder_x = img_w - subpart_x * offset_x;
209 int remainder_y = img_h - subpart_y * offset_y;
210 int subpart_w = (remainder_x < tex_w) ? remainder_x : tex_w;
211 int subpart_h = (remainder_y < tex_h) ? remainder_y : tex_h;
212 int offset_left = (seamless && subpart_x != 0) ? 1 : 0;
213 int offset_bot = (seamless && subpart_y != 0) ? 1 : 0;
214 int offset_right = (seamless && remainder_x > tex_w) ? 1 : 0;
215 int offset_top = (seamless && remainder_y > tex_h) ? 1 : 0;
216 float rast_x = x + subpart_x * offset_x * xzoom;
217 float rast_y = y + subpart_y * offset_y * yzoom;
219 if (subpart_w <= seamless || subpart_h <= seamless) {
223 int right = subpart_w - offset_right;
224 int top = subpart_h - offset_top;
225 int bottom = 0 + offset_bot;
226 int left = 0 + offset_left;
229 if (rast_x + right * xzoom * scaleX < clip_min_x ||
230 rast_y + top * yzoom * scaleY < clip_min_y)
234 if (rast_x + left * xzoom > clip_max_x || rast_y + bottom * yzoom > clip_max_y) {
240 int src_y = subpart_y * offset_y;
241 int src_x = subpart_x * offset_x;
243#define DATA(_y, _x) (static_cast<const char *>(rect) + stride * (size_t(_y) * img_w + (_x)))
245 const void *data =
DATA(src_y, src_x);
250 if (subpart_w < tex_w) {
251 const void *data =
DATA(src_y, src_x + subpart_w - 1);
252 const int offset[2] = {subpart_w, 0};
253 const int extent[2] = {1, subpart_h};
256 if (subpart_h < tex_h) {
257 const void *data =
DATA(src_y + subpart_h - 1, src_x);
258 const int offset[2] = {0, subpart_h};
259 const int extent[2] = {subpart_w, 1};
263 if (subpart_w < tex_w && subpart_h < tex_h) {
264 const void *data =
DATA(src_y + subpart_h - 1, src_x + subpart_w - 1);
265 const int offset[2] = {subpart_w, subpart_h};
266 const int extent[2] = {1, 1};
275 immAttr2f(texco, left /
float(tex_w), bottom /
float(tex_h));
276 immVertex2f(
pos, rast_x + offset_left * xzoom, rast_y + offset_bot * yzoom);
278 immAttr2f(texco, right /
float(tex_w), bottom /
float(tex_h));
279 immVertex2f(
pos, rast_x + right * xzoom * scaleX, rast_y + offset_bot * yzoom);
281 immAttr2f(texco, right /
float(tex_w), top /
float(tex_h));
282 immVertex2f(
pos, rast_x + right * xzoom * scaleX, rast_y + top * yzoom * scaleY);
284 immAttr2f(texco, left /
float(tex_w), top /
float(tex_h));
285 immVertex2f(
pos, rast_x + offset_left * xzoom, rast_y + top * yzoom * scaleY);
290 if (
state->do_shader_unbind) {
313 const float color[4])
344 const float color[4])
379 const float color[4])
415 bool force_fallback =
false;
416 bool need_fallback =
true;
424 force_fallback |= ibuf->
channels == 1;
430 if (force_fallback ==
false) {
449 view_settings, display_settings, ibuf->
dither,
true);
472 BLI_assert_msg(0,
"Incompatible number of channels for GLSL display");
514 need_fallback =
false;
520 uchar *display_buffer;
524 ibuf, view_settings, display_settings, &cache_handle);
526 if (display_buffer) {
604 const bContext *C,
ImBuf *ibuf,
float x,
float y,
bool use_filter,
float zoom_x,
float zoom_y)
606 ED_draw_imbuf_ctx_clipping(C, ibuf, x, y, use_filter, 0.0f, 0.0f, 0.0f, 0.0f, zoom_x, zoom_y);
614 const size_t threshold =
sizeof(
float[4]) * 2048 * 2048;
616 const size_t size = size_t(ibuf->
x) * size_t(ibuf->
y) * size_t(ibuf->
channels) * data_size;
620 return U.image_draw_method;
#define BLI_assert_msg(a, msg)
MINLINE float min_ff(float a, float b)
@ IMAGE_DRAW_METHOD_2DTEXTURE
eGPUBackendType GPU_backend_get_type()
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
GPUShader * GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
@ GPU_SHADER_3D_IMAGE_COLOR
void GPU_texture_bind(GPUTexture *texture, int unit)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(GPUTexture *texture)
void GPU_texture_unbind(GPUTexture *texture)
void GPU_texture_extend_mode(GPUTexture *texture, GPUSamplerExtendMode extend_mode)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
void GPU_texture_update_sub(GPUTexture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
void GPU_texture_mipmap_mode(GPUTexture *texture, bool use_mipmap, bool use_filter)
void GPU_texture_filter_mode(GPUTexture *texture, bool use_filter)
void GPU_texture_update_mipmap_chain(GPUTexture *texture)
void GPU_unpack_row_length_set(uint len)
void GPU_texture_update(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
unsigned char * IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, void **cache_handle)
bool IMB_colormanagement_setup_glsl_draw(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float dither, bool predivide)
void IMB_display_buffer_release(void *cache_handle)
void IMB_colormanagement_display_settings_from_ctx(const bContext *C, ColorManagedViewSettings **r_view_settings, ColorManagedDisplaySettings **r_display_settings)
void IMB_colormanagement_finish_glsl_draw()
bool IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, ColorSpace *from_colorspace, float dither, bool predivide, bool do_overlay_merge)
Contains defines and structs used throughout the imbuf module.
RAYTRACE_GROUP_SIZE additional_info("eevee_shared", "eevee_gbuffer_data", "eevee_global_ubo", "eevee_sampling_data", "eevee_utility_texture", "eevee_hiz_data", "draw_view") .specialization_constant(Type RAYTRACE_GROUP_SIZE in_sh_0_tx in_sh_2_tx screen_normal_tx GPU_RGBA8
void immDrawPixelsTexTiled_scaling_clipping(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, const void *rect, float scaleX, float scaleY, float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y, float xzoom, float yzoom, const float color[4])
void ED_draw_imbuf_ctx(const bContext *C, ImBuf *ibuf, float x, float y, bool use_filter, float zoom_x, float zoom_y)
void immDrawPixelsTexTiled_scaling(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, const void *rect, float scaleX, float scaleY, float xzoom, float yzoom, const float color[4])
void ED_draw_imbuf_clipping(ImBuf *ibuf, float x, float y, bool use_filter, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y, float zoom_x, float zoom_y)
void immDrawPixelsTexTiled_clipping(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, const void *rect, float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y, float xzoom, float yzoom, const float color[4])
void ED_draw_imbuf(ImBuf *ibuf, float x, float y, bool use_filter, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float zoom_x, float zoom_y)
void immDrawBorderCorners(uint pos, const rcti *border, float zoomx, float zoomy)
void ED_draw_imbuf_ctx_clipping(const bContext *C, ImBuf *ibuf, float x, float y, bool use_filter, float clip_min_x, float clip_min_y, float clip_max_x, float clip_max_y, float zoom_x, float zoom_y)
void immDrawPixelsTexTiled(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, const void *rect, float xzoom, float yzoom, const float color[4])
int ED_draw_imbuf_method(const ImBuf *ibuf)
void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state, const float x, const float y, const int img_w, const int img_h, const eGPUTextureFormat gpu_format, const bool use_filter, const void *rect, const float scaleX, const float scaleY, const float xzoom, const float yzoom, const float color[4])
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state)
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer