vendor: Add half-resolution boot animations for low-end devices

Add half-resolution variants of the boot animations which display 2x upscaled
-- this greatly speeds the boot process and makes the boot animation run more
smoothly.

Changes for SlimRoms: Andreas Blaesius <skate4life@gmx.de>

Change-Id: I0140616ca38c52a06dd4622f1c20a9ca0da95f4b
diff --git a/config/common.mk b/config/common.mk
index 5c1f858..f5f3e2a 100644
--- a/config/common.mk
+++ b/config/common.mk
@@ -143,9 +143,14 @@
 endef
 $(foreach size,$(bootanimation_sizes), $(call check_and_set_bootanimation,$(size)))
 
+ifeq ($(TARGET_BOOTANIMATION_HALF_RES),true)
+PRODUCT_COPY_FILES += \
+    vendor/slim/prebuilt/common/bootanimation/halfres/$(TARGET_BOOTANIMATION_NAME).zip:system/media/bootanimation.zip
+else
 PRODUCT_COPY_FILES += \
     vendor/slim/prebuilt/common/bootanimation/$(TARGET_BOOTANIMATION_NAME).zip:system/media/bootanimation.zip
 endif
+endif
 
 # Versioning System
 # SlimLP first version.
diff --git a/prebuilt/common/bootanimation/halfres/1080.zip b/prebuilt/common/bootanimation/halfres/1080.zip
new file mode 100644
index 0000000..4728275
--- /dev/null
+++ b/prebuilt/common/bootanimation/halfres/1080.zip
Binary files differ
diff --git a/prebuilt/common/bootanimation/halfres/1200.zip b/prebuilt/common/bootanimation/halfres/1200.zip
new file mode 100644
index 0000000..05e21bf
--- /dev/null
+++ b/prebuilt/common/bootanimation/halfres/1200.zip
Binary files differ
diff --git a/prebuilt/common/bootanimation/halfres/1600.zip b/prebuilt/common/bootanimation/halfres/1600.zip
new file mode 100644
index 0000000..f12b0d5
--- /dev/null
+++ b/prebuilt/common/bootanimation/halfres/1600.zip
Binary files differ
diff --git a/prebuilt/common/bootanimation/halfres/480.zip b/prebuilt/common/bootanimation/halfres/480.zip
new file mode 100644
index 0000000..b5c6bf8
--- /dev/null
+++ b/prebuilt/common/bootanimation/halfres/480.zip
Binary files differ
diff --git a/prebuilt/common/bootanimation/halfres/600.zip b/prebuilt/common/bootanimation/halfres/600.zip
new file mode 100644
index 0000000..d3a2aa6
--- /dev/null
+++ b/prebuilt/common/bootanimation/halfres/600.zip
Binary files differ
diff --git a/prebuilt/common/bootanimation/halfres/720.zip b/prebuilt/common/bootanimation/halfres/720.zip
new file mode 100644
index 0000000..6ae6d65
--- /dev/null
+++ b/prebuilt/common/bootanimation/halfres/720.zip
Binary files differ
diff --git a/prebuilt/common/bootanimation/halfres/800.zip b/prebuilt/common/bootanimation/halfres/800.zip
new file mode 100644
index 0000000..945accb
--- /dev/null
+++ b/prebuilt/common/bootanimation/halfres/800.zip
Binary files differ
diff --git a/prebuilt/common/bootanimation/halfres/generate-half-res-anims.sh b/prebuilt/common/bootanimation/halfres/generate-half-res-anims.sh
new file mode 100755
index 0000000..730f535
--- /dev/null
+++ b/prebuilt/common/bootanimation/halfres/generate-half-res-anims.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+HALF_RES_RESOLUTIONS="480 600 720 800 1080 1200 1600"
+
+for i in $HALF_RES_RESOLUTIONS; do
+	rm -f $i.zip
+	mkdir $i
+	cd $i
+	if [ -f ../../$(($i/2)).zip ]; then
+		# use the existing scaled images
+		echo "Using existing half-scale images instead of scaling from $i px"
+		unzip ../../$(($i/2)).zip
+		rm -f desc.txt
+		unzip ../../$i.zip desc.txt
+	else
+		unzip ../../$i.zip
+		for j in */*.[pP][nN][gG]; do
+			convert $j -resize 50% tmp.png
+			mv tmp.png $j
+		done
+	fi
+	zip -r0 ../$i.zip .
+	cd ..
+	rm -rf $i
+done