diff options
Diffstat (limited to 'modules/squish/image_compress_squish.cpp')
-rw-r--r-- | modules/squish/image_compress_squish.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index 2427dac8a7..e927f1ceaa 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -59,9 +59,9 @@ void image_decompress_squish(Image *p_image) { squish_flags = squish::kDxt3; } else if (p_image->get_format() == Image::FORMAT_DXT5) { squish_flags = squish::kDxt5; - } else if (p_image->get_format() == Image::FORMAT_LATC_L || p_image->get_format() == Image::FORMAT_RGTC_R) { + } else if (p_image->get_format() == Image::FORMAT_RGTC_R) { squish_flags = squish::kBc4; - } else if (p_image->get_format() == Image::FORMAT_LATC_LA || p_image->get_format() == Image::FORMAT_RGTC_RG) { + } else if (p_image->get_format() == Image::FORMAT_RGTC_RG) { squish_flags = squish::kBc5; } else { ERR_FAIL_COND(true); @@ -79,7 +79,7 @@ void image_decompress_squish(Image *p_image) { p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data); } -void image_compress_squish(Image *p_image) { +void image_compress_squish(Image *p_image, bool p_srgb) { if (p_image->get_format() >= Image::FORMAT_DXT1) return; //do not compress, already compressed @@ -96,16 +96,21 @@ void image_compress_squish(Image *p_image) { p_image->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert + if (p_srgb && (dc == Image::DETECTED_R || dc == Image::DETECTED_RG)) { + //R and RG do not support SRGB + dc = Image::DETECTED_RGB; + } + switch (dc) { case Image::DETECTED_L: { - target_format = Image::FORMAT_LATC_L; - squish_comp |= squish::kBc4; + target_format = Image::FORMAT_DXT1; + squish_comp |= squish::kDxt1; } break; case Image::DETECTED_LA: { - target_format = Image::FORMAT_LATC_LA; - squish_comp |= squish::kBc5; + target_format = Image::FORMAT_DXT5; + squish_comp |= squish::kDxt5; } break; case Image::DETECTED_R: { @@ -148,8 +153,8 @@ void image_compress_squish(Image *p_image) { int bh = h % 4 != 0 ? h + (4 - h % 4) : h; int src_ofs = p_image->get_mipmap_offset(i); - squish::CompressImage(&rb[src_ofs], bw, bh, &wb[dst_ofs], squish_comp); - dst_ofs += (MAX(4, w) * MAX(4, h)) >> shift; + squish::CompressImage(&rb[src_ofs], w, h, &wb[dst_ofs], squish_comp); + dst_ofs += (MAX(4, bw) * MAX(4, bh)) >> shift; w >>= 1; h >>= 1; } |