Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/util_gpu.c
| Show First 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | GPUTexture *IMB_create_gpu_texture(const char *name, | ||||
| ImBuf *ibuf, | ImBuf *ibuf, | ||||
| bool use_high_bitdepth, | bool use_high_bitdepth, | ||||
| bool use_premult) | bool use_premult) | ||||
| { | { | ||||
| GPUTexture *tex = NULL; | GPUTexture *tex = NULL; | ||||
| int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)}; | int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)}; | ||||
| bool do_rescale = (ibuf->x != size[0]) || (ibuf->y != size[1]); | bool do_rescale = (ibuf->x != size[0]) || (ibuf->y != size[1]); | ||||
| /* Correct the smaller size to maintain the original aspect ratio of the image. */ | |||||
| if (do_rescale && ibuf->x != ibuf->y) { | |||||
| if (size[0] > size[1]) { | |||||
| size[1] = (int)(ibuf->y * ((float)size[0] / ibuf->x)); | |||||
| } | |||||
| else { | |||||
| size[0] = (int)(ibuf->x * ((float)size[1] / ibuf->y)); | |||||
| } | |||||
| } | |||||
| #ifdef WITH_DDS | #ifdef WITH_DDS | ||||
| if (ibuf->ftype == IMB_FTYPE_DDS) { | if (ibuf->ftype == IMB_FTYPE_DDS) { | ||||
| eGPUTextureFormat compressed_format; | eGPUTextureFormat compressed_format; | ||||
| if (!IMB_gpu_get_compressed_format(ibuf, &compressed_format)) { | if (!IMB_gpu_get_compressed_format(ibuf, &compressed_format)) { | ||||
| fprintf(stderr, "Unable to find a suitable DXT compression,"); | fprintf(stderr, "Unable to find a suitable DXT compression,"); | ||||
| } | } | ||||
| else if (do_rescale) { | else if (do_rescale) { | ||||
| fprintf(stderr, "Unable to load DXT image resolution,"); | fprintf(stderr, "Unable to load DXT image resolution,"); | ||||
| ▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines | |||||