Fix preview renders not immediately updating with color management changes #109026
@ -620,7 +620,8 @@ static Scene *preview_prepare_scene(
|
||||
|
||||
/* new UI convention: draw is in pixel space already. */
|
||||
/* uses UI_BTYPE_ROUNDBOX button in block to get the rect */
|
||||
static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect, rcti *newrect)
|
||||
static bool ed_preview_draw_rect(
|
||||
Scene *scene, ScrArea *area, int split, int first, rcti *rect, rcti *newrect)
|
||||
{
|
||||
Render *re;
|
||||
RenderView *rv;
|
||||
@ -668,35 +669,21 @@ static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect
|
||||
}
|
||||
|
||||
if (rv && rv->combined_buffer.data) {
|
||||
|
||||
if (abs(rres.rectx - newx) < 2 && abs(rres.recty - newy) < 2) {
|
||||
|
||||
newrect->xmax = max_ii(newrect->xmax, rect->xmin + rres.rectx + offx);
|
||||
newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty);
|
||||
|
||||
if (rres.rectx && rres.recty) {
|
||||
uchar *rect_byte = static_cast<uchar *>(
|
||||
MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect"));
|
||||
float fx = rect->xmin + offx;
|
||||
float fy = rect->ymin;
|
||||
|
||||
/* material preview only needs monoscopy (view 0) */
|
||||
RE_AcquiredResultGet32(re, &rres, (uint *)rect_byte, 0);
|
||||
ImBuf *ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 0, 0);
|
||||
IMB_assign_float_buffer(ibuf, rv->combined_buffer.data, IB_DO_NOT_TAKE_OWNERSHIP);
|
||||
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_3D_IMAGE_COLOR);
|
||||
immDrawPixelsTexTiled(&state,
|
||||
fx,
|
||||
fy,
|
||||
rres.rectx,
|
||||
rres.recty,
|
||||
GPU_RGBA8,
|
||||
false,
|
||||
rect_byte,
|
||||
1.0f,
|
||||
1.0f,
|
||||
nullptr);
|
||||
ED_draw_imbuf(
|
||||
ibuf, fx, fy, false, &scene->view_settings, &scene->display_settings, 1.0f, 1.0f);
|
||||
|
||||
MEM_freeN(rect_byte);
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
||||
ok = true;
|
||||
}
|
||||
@ -711,6 +698,7 @@ static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect
|
||||
void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect)
|
||||
{
|
||||
if (idp) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
ID *id = (ID *)idp;
|
||||
@ -730,11 +718,11 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
|
||||
newrect.ymax = rect->ymin;
|
||||
|
||||
if (parent) {
|
||||
ok = ed_preview_draw_rect(area, 1, 1, rect, &newrect);
|
||||
ok &= ed_preview_draw_rect(area, 1, 0, rect, &newrect);
|
||||
ok = ed_preview_draw_rect(scene, area, 1, 1, rect, &newrect);
|
||||
ok &= ed_preview_draw_rect(scene, area, 1, 0, rect, &newrect);
|
||||
}
|
||||
else {
|
||||
ok = ed_preview_draw_rect(area, 0, 0, rect, &newrect);
|
||||
ok = ed_preview_draw_rect(scene, area, 0, 0, rect, &newrect);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
|
@ -264,15 +264,6 @@ struct RenderStats *RE_GetStats(struct Render *re);
|
||||
* Caller is responsible for allocating `rect` in correct size!
|
||||
*/
|
||||
void RE_ResultGet32(struct Render *re, unsigned int *rect);
|
||||
/**
|
||||
* Only for acquired results, for lock.
|
||||
*
|
||||
* \note The caller is responsible for allocating `rect` in correct size!
|
||||
*/
|
||||
void RE_AcquiredResultGet32(struct Render *re,
|
||||
struct RenderResult *result,
|
||||
unsigned int *rect,
|
||||
int view_id);
|
||||
|
||||
void RE_render_result_full_channel_name(char *fullname,
|
||||
const char *layname,
|
||||
|
@ -507,17 +507,6 @@ void RE_ResultGet32(Render *re, uint *rect)
|
||||
RE_ReleaseResultImageViews(re, &rres);
|
||||
}
|
||||
|
||||
void RE_AcquiredResultGet32(Render *re, RenderResult *result, uint *rect, const int view_id)
|
||||
{
|
||||
render_result_rect_get_pixels(result,
|
||||
rect,
|
||||
re->rectx,
|
||||
re->recty,
|
||||
&re->scene->view_settings,
|
||||
&re->scene->display_settings,
|
||||
view_id);
|
||||
}
|
||||
|
||||
RenderStats *RE_GetStats(Render *re)
|
||||
{
|
||||
return &re->i;
|
||||
|
Loading…
Reference in New Issue
Block a user