diff options
Diffstat (limited to 'source/blender/blenkernel/intern/image_gpu.cc')
-rw-r--r-- | source/blender/blenkernel/intern/image_gpu.cc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index 6506b40b603..6893a50638a 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -138,6 +138,8 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf) int arraywidth = 0, arrayheight = 0; ListBase boxes = {nullptr}; + int planes = 0; + LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { ImageUser iuser; BKE_imageuser_default(&iuser); @@ -164,6 +166,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf) BKE_image_release_ibuf(ima, ibuf, nullptr); BLI_addtail(&boxes, packtile); + planes = max_ii(planes, ibuf->planes); } } @@ -195,9 +198,15 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf) } const bool use_high_bitdepth = (ima->flag & IMA_HIGH_BITDEPTH); + const bool use_grayscale = planes <= 8; /* Create Texture without content. */ - GPUTexture *tex = IMB_touch_gpu_texture( - ima->id.name + 2, main_ibuf, arraywidth, arrayheight, arraylayers, use_high_bitdepth); + GPUTexture *tex = IMB_touch_gpu_texture(ima->id.name + 2, + main_ibuf, + arraywidth, + arrayheight, + arraylayers, + use_high_bitdepth, + use_grayscale); /* Upload each tile one by one. */ LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { @@ -223,6 +232,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf) tilelayer, UNPACK2(tilesize), use_high_bitdepth, + use_grayscale, store_premultiplied); } @@ -541,7 +551,7 @@ void BKE_image_free_anim_gputextures(Main *bmain) void BKE_image_free_old_gputextures(Main *bmain) { static int lasttime = 0; - int ctime = (int)PIL_check_seconds_timer(); + int ctime = int(PIL_check_seconds_timer()); /* * Run garbage collector once for every collecting period of time @@ -592,8 +602,8 @@ static ImBuf *update_do_scale(uchar *rect, int full_h) { /* Partial update with scaling. */ - float xratio = limit_w / (float)full_w; - float yratio = limit_h / (float)full_h; + float xratio = limit_w / float(full_w); + float yratio = limit_h / float(full_h); int part_w = *w, part_h = *h; @@ -601,8 +611,8 @@ static ImBuf *update_do_scale(uchar *rect, * losing 1 pixel due to rounding errors in x,y. */ *x *= xratio; *y *= yratio; - *w = (int)ceil(xratio * (*w)); - *h = (int)ceil(yratio * (*h)); + *w = int(ceil(xratio * (*w))); + *h = int(ceil(yratio * (*h))); /* ...but take back if we are over the limit! */ if (*x + *w > limit_w) { |