Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_draw.c
| Show First 20 Lines • Show All 701 Lines • ▼ Show 20 Lines | #ifdef WITH_HEADLESS | ||||
| (void)but; | (void)but; | ||||
| #else | #else | ||||
| ImBuf *ibuf = (ImBuf *)but->poin; | ImBuf *ibuf = (ImBuf *)but->poin; | ||||
| if (!ibuf) { | if (!ibuf) { | ||||
| return; | return; | ||||
| } | } | ||||
| float facx = 1.0f; | |||||
| float facy = 1.0f; | |||||
| int w = BLI_rcti_size_x(rect); | int w = BLI_rcti_size_x(rect); | ||||
| int h = BLI_rcti_size_y(rect); | int h = BLI_rcti_size_y(rect); | ||||
| /* scissor doesn't seem to be doing the right thing...? */ | /* scissor doesn't seem to be doing the right thing...? */ | ||||
| # if 0 | # if 0 | ||||
| /* prevent drawing outside widget area */ | /* prevent drawing outside widget area */ | ||||
| int scissor[4]; | int scissor[4]; | ||||
| GPU_scissor_get_i(scissor); | GPU_scissor_get_i(scissor); | ||||
| GPU_scissor(rect->xmin, rect->ymin, w, h); | GPU_scissor(rect->xmin, rect->ymin, w, h); | ||||
| # endif | # endif | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| /* Combine with premultiplied alpha. */ | |||||
| GPU_blend_set_func_separate(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); | |||||
| if (w != ibuf->x || h != ibuf->y) { | if (w != ibuf->x || h != ibuf->y) { | ||||
| facx = (float)w / (float)ibuf->x; | /* We scale the bitmap, rather than have OGL do a worse job. */ | ||||
| facy = (float)h / (float)ibuf->y; | IMB_scaleImBuf(ibuf, w, h); | ||||
| } | |||||
| float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | |||||
| if (but->col[3] != 0) { | |||||
| /* Optionally use uiBut's col to recolor the image. */ | |||||
| rgba_uchar_to_float(col, but->col); | |||||
| } | } | ||||
| IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); | IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); | ||||
| immDrawPixelsTex(&state, | immDrawPixelsTex(&state, | ||||
| (float)rect->xmin, | (float)rect->xmin, | ||||
| (float)rect->ymin, | (float)rect->ymin, | ||||
| ibuf->x, | ibuf->x, | ||||
| ibuf->y, | ibuf->y, | ||||
| GL_RGBA, | GL_RGBA, | ||||
| GL_UNSIGNED_BYTE, | GL_UNSIGNED_BYTE, | ||||
| GL_NEAREST, | GL_NEAREST, | ||||
| ibuf->rect, | ibuf->rect, | ||||
| facx, | 1.0f, | ||||
| facy, | 1.0f, | ||||
| NULL); | col); | ||||
| GPU_blend(false); | GPU_blend(false); | ||||
| /* Reset default. */ | |||||
| GPU_blend_set_func_separate( | |||||
| GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); | |||||
| # if 0 | # if 0 | ||||
| // restore scissortest | // restore scissortest | ||||
| GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); | GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); | ||||
| # endif | # endif | ||||
| #endif | #endif | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,932 Lines • Show Last 20 Lines | |||||