Skip to content

Commit

Permalink
appIndicator: Use simpler implementation for argbToRgba
Browse files Browse the repository at this point in the history
While bit-shifting should be faster and DataView should allow to manage data
structs without overhead, it looks like is way slower [1] than the simplest
implementation, so let's just go with it.

Related to #202

[1] https://jsfiddle.net/3vLfd0x6/3/
  • Loading branch information
3v1n0 committed Mar 12, 2020
1 parent c17e4b7 commit 005fe8b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions appIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,14 @@ class AppIndicators_IconActor extends St.Icon {

argbToRgba(src) {
let dest = new Uint8Array(src.length);
let srcView = new DataView(src.buffer);
let destView = new DataView(dest.buffer);

for (let i = 0; i < src.length; i += 4) {
let argb = srcView.getUint32(i);
let rgba = (argb & 0x00FFFFFF) << 8 |
(argb & 0xFF000000) >>> 24;
destView.setUint32(i, rgba);
let srcAlpha = src[i]

dest[i] = src[i + 1]; /* red */
dest[i + 1] = src[i + 2]; /* green */
dest[i + 2] = src[i + 3]; /* blue */
dest[i + 3] = srcAlpha; /* alpha */
}

return dest;
Expand Down

0 comments on commit 005fe8b

Please sign in to comment.