[adwaita-icon-theme] anicursorgen: change the PNG compression use logic
- From: Jakub Steiner <jimmac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [adwaita-icon-theme] anicursorgen: change the PNG compression use logic
- Date: Mon, 22 Aug 2016 18:54:03 +0000 (UTC)
commit a6275c6cb201eae72a8839777a3ee5d0113738b9
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Mon Aug 22 15:23:29 2016 +0000
anicursorgen: change the PNG compression use logic
Previously anicursorgen used PNG compression for any
cursor frames larger than 48x48, for no immediately
apparent reason, even to me (the author of anicursorgen).
Tests on Windows 10 revealed that this logic is faulty:
Windows 10 does not recognize PNG-compressed frames as valid, thus
all Adwaita cursors are effectively 32x32 and 48x48 (all larger
frames are ignored by the OS). This becomes obvious in HiDPI mode,
where the OS will try to use larger cursor sizes.
Windows 10 loads up uncompressed cursors just fine, and
stock Windows 10 cursors are uncompressed. However, animated
cursors with large numbers of frames, when stored without
compression, are also ignored by the OS (probably due to their
massive size).
My hypothesis is that the correct way of using PNG compression
is to compress or not compress *all* frames, not just the large ones.
However, verifying that requires more tests (or asking MS developers).
In the end i've settled enabling PNG compression for all frames
in animated cursors and disabling PNG compression for all frames
in non-animated cursors. This works for Adwaita, and that's all we
really need.
src/cursors/anicursorgen.py | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/cursors/anicursorgen.py b/src/cursors/anicursorgen.py
index 425eb73..ad4b7c0 100755
--- a/src/cursors/anicursorgen.py
+++ b/src/cursors/anicursorgen.py
@@ -128,7 +128,7 @@ def frames_have_animation (frames):
return False
-def make_cur (frames, args):
+def make_cur (frames, args, animated=False):
buf = io.BytesIO ()
buf.write (p ('<HHH', 0, 2, len (frames)))
frame_offsets = []
@@ -165,7 +165,17 @@ def make_cur (frames, args):
frame_png.close ()
frame_png = shadowed
- compressed = frame[0] > 48
+# Windows 10 fails to read PNG-compressed cursors for some reason
+# and the information about storing PNG-compressed cursors is
+# sparse. This is why PNG compression is not used.
+# Previously this was conditional on cursor size (<= 48 to be uncompressed).
+ compressed = False
+
+# On the other hand, Windows 10 refuses to read very large
+# uncompressed animated cursor files, but does accept
+# PNG-compressed animated cursors for some reason. Go figure.
+ if animated:
+ compressed = True
if compressed:
write_png (buf, frame, frame_png)
@@ -264,7 +274,7 @@ def make_ani (frames, out, args):
for frameset in framesets:
buf.write (b'icon')
- cur = make_cur (frameset, args)
+ cur = make_cur (frameset, args, animated=True)
cur_size = cur.seek (0, io.SEEK_END)
aligned_cur_size = cur_size
#if cur_size % 4 != 0:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]