summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2012-08-07 18:34:36 +0800
committerDave Parker <dparker@chromium.org>2012-08-16 19:00:20 -0700
commit9a5e8f99894922c0ee8e50daeaf13024e2e64211 (patch)
tree3740b5606770eb36d927bce8182ff5074c3f0026
parent3a7fd867f1c0fa0bdbb7363f68b9bb0c494af4aa (diff)
downloadvboot-9a5e8f99894922c0ee8e50daeaf13024e2e64211.tar.gz
Cherry-Pick: Generates x86 and arm firmware bitmap blocks.
X86 (coreboot) uses 800x600 resolution while ARM systems (uboot) initialze LCD as its maximum size, so we must refine the bmpblk build scripts to generate output with different scaling parameters. BUG=chrome-os-partner:11078 TEST=make # got ARM bmpblock and verified to work on daisy. Original-Change-Id: Ib9e9a0dc3b6695cef451772391f207a5b57977df Reviewed-on: https://gerrit.chromium.org/gerrit/29606 Reviewed-by: Dave Parker <dparker@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Ready: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org> Conflicts: scripts/newbitmaps/fonts/make_ascii_bmps.py scripts/newbitmaps/images/Makefile Change-Id: I01a857a628efa37f37c076bb89798353853b8677 Reviewed-on: https://gerrit.chromium.org/gerrit/30623 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: Dave Parker <dparker@chromium.org>
-rw-r--r--.gitignore4
-rw-r--r--scripts/newbitmaps/Makefile23
-rwxr-xr-xscripts/newbitmaps/fonts/make_ascii_bmps.py33
-rw-r--r--scripts/newbitmaps/images/Makefile78
-rwxr-xr-xscripts/newbitmaps/images/build_images90
-rwxr-xr-xscripts/newbitmaps/images/make_default_yaml6
6 files changed, 128 insertions, 106 deletions
diff --git a/.gitignore b/.gitignore
index db3c8b0d..13faa806 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,6 @@
/build
ID
+scripts/newbitmaps/lib/*.pyc
+scripts/newbitmaps/strings/localized_text/*/*.png
+scripts/newbitmaps/fonts/outdir
+scripts/newbitmaps/images/out_*
diff --git a/scripts/newbitmaps/Makefile b/scripts/newbitmaps/Makefile
index de34f7b9..945bd413 100644
--- a/scripts/newbitmaps/Makefile
+++ b/scripts/newbitmaps/Makefile
@@ -13,7 +13,7 @@ ALL_LOCALES=en es_419 pt_BR en_GB fr es pt_PT ca it de \
# Here are the launch locales for Stumpy/Lumpy (issue 6595), same ordering.
DEFAULT_LOCALES=en es_419 pt_BR en_GB fr es it de nl da no sv ko ja
-default: outside_chroot fonts x86 arm clean
+default: outside_chroot fonts strings x86 arm clean
outside_chroot:
@if [ -e /etc/debian_chroot ]; then \
@@ -25,25 +25,24 @@ outside_chroot:
fonts:
+ # TODO(hungte) Move fonts generation to its own Makefile.
cd fonts && ./make_ascii_bmps.py
bmpblk_font --outfile images/hwid_fonts.bin fonts/outdir/*.bmp
+strings:
+ $(MAKE) -C strings/localized_text
+
x86:
- $(MAKE) -C strings/localized_text PT=15
- cd strings/localized_text && tar cf temp.tar */*.bmp
- mkdir -p images/out_$@/localized_images
- cd images/out_$@/localized_images && \
- tar xf ../../../strings/localized_text/temp.tar
$(MAKE) -C images $@ DEFAULT_LOCALES="$(DEFAULT_LOCALES)"
cp -f images/out_$@/bmpblock.bin bmpblock_$@.bin
arm:
- @echo "FIXME: ARM bitmaps are not yet autogenerated"
+ $(MAKE) -C images $@ DEFAULT_LOCALES="$(DEFAULT_LOCALES)"
+ cp -f images/out_$@/bmpblock.bin bmpblock_$@.bin
clean:
- rm -rf fonts/outdir strings/localized_text/*/*.bmp \
- strings/localized_text/temp.tar \
- images/localized_images \
- images/out_x86 images/out_arm
+ rm -rf fonts/outdir
+ $(MAKE) -C strings/localized_text clean
+ $(MAKE) -C images clean
-.PHONY: outside_chroot fonts x86 arm
+.PHONY: outside_chroot fonts strings x86 arm
diff --git a/scripts/newbitmaps/fonts/make_ascii_bmps.py b/scripts/newbitmaps/fonts/make_ascii_bmps.py
index 2b36275a..e96e8736 100755
--- a/scripts/newbitmaps/fonts/make_ascii_bmps.py
+++ b/scripts/newbitmaps/fonts/make_ascii_bmps.py
@@ -58,33 +58,25 @@ def main():
count=0
for ascii in chars:
- pngfile = os.path.join(options.outdir,
- "idx%03d_%x.png" % (count,ord(ascii)))
- bmpfile = os.path.join(options.outdir,
+ outfile = os.path.join(options.outdir,
"idx%03d_%x.bmp" % (count,ord(ascii)))
- cmd = ('pango-view', '-q', '--no-auto-dir',
- '--background=%s' % options.bg,
- '--foreground=%s' % options.fg,
- '--font="%s %s"' % (options.font, options.size),
- '--dpi', '72',
- '--margin', '0',
- '--text="%s"' % ascii,
- '-o', pngfile)
-
- cmd = ' '.join(cmd)
- print cmd
- os.system(cmd) # This must be run in a subshell for correct font rendering.
-
+ # TODO(hungte) Support assigning size & scaling for character images.
+ print outfile
cmd = ('convert',
+ '-font', options.font,
+ '-background', options.bg,
+ '-fill', options.fg,
'-bordercolor', options.bg,
'-border', '0x3',
- '-resize', '59%x78%', # Scale the same as other images.
- '-colors', '256',
+ '-gravity', 'Center',
+ '-pointsize', options.size,
+ '-resize', '120%x100', # Yes, magic.
+ '-scale', '59%x78%', # Here, too.
+ 'label:%s' % ascii,
'-remap', gradient_file,
'-compress', 'none',
'-alpha', 'off',
- pngfile,
- bmpfile)
+ outfile)
print ' '.join(cmd)
count += 1
subprocess.call(cmd)
@@ -95,3 +87,4 @@ def main():
# Start it all off
if __name__ == '__main__':
main()
+
diff --git a/scripts/newbitmaps/images/Makefile b/scripts/newbitmaps/images/Makefile
index 4dbdfe9a..cb5eaf22 100644
--- a/scripts/newbitmaps/images/Makefile
+++ b/scripts/newbitmaps/images/Makefile
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+#Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -18,19 +18,13 @@ DEFAULT_LOCALES=en es_419 pt_BR en_GB fr es pt_PT ca it de \
el nl da no sv fi et lv lt ru pl cs sk hu sl sr hr bg ro \
uk tr iw ar fa hi th vi id fil zh_CN zh_TW ko ja
-BACKGROUND_IMAGE=Background_white.bmp
-GRAYSCALE_IMAGES=arrow_left.bmp arrow_right.bmp divider_top.bmp divider_btm.bmp
-OTHER_IMAGES=Devmode_graphic.bmp Insert_graphic.bmp Remove_graphic.bmp \
- Remove_graphic_usbonly.bmp Yuck_graphic.bmp Url.bmp hwid_unknown.bmp \
- chrome_logo.bmp
-
-FONTS=hwid_fonts.bin
-
default: outside_chroot
@echo "Specify a target to build for:"
@echo " ${TARGETS}"
outside_chroot:
+ # TODO(hungte) It's now not easy to have bmpblk_utility outside
+ # chroot... We need some better way to do this.
@if [ -e /etc/debian_chroot ]; then \
echo "ImageMagick is too complex to build inside the chroot."; \
echo "You must be outside the chroot to do this"; \
@@ -40,76 +34,18 @@ outside_chroot:
${TARGETS}:: outside_chroot
-
-# The image size with UEFI BIOS is always 800x600, which is stretched to fill
-# the entire screen. With previous devices the physical screen size was either
-# 1280x800 (16:10) or 1366x768 (16:9). There's not a lot of difference between
-# those, so let's just assume 16:9 for future platforms to make things simpler.
-_x86_max=800x600!
-_x86_scale=59%x78%
-_x86_opts=-colors 256 -compress none -alpha off
-_arm_max=800x600!
-_arm_scale=59%x78%
-
x86::
- # create output directories
- mkdir -p "out_$@"
- # copy stuff we need
- cp "${FONTS}" "out_$@"
- # Scale and preserve the 256 color index of background image
- echo " out_$@/${BACKGROUND_IMAGE}" && \
- convert ${BACKGROUND_IMAGE} -scale '${_x86_max}' ${_x86_opts} \
- -remap gradient.png "BMP3:out_$@/${BACKGROUND_IMAGE}" || \
- exit 1;
- # Preserve the 256 color index of grayscale images
- @for i in ${GRAYSCALE_IMAGES}; do \
- echo " out_$@/$$i" && \
- convert $$i -scale '${_x86_scale}' ${_x86_opts} \
- -remap gradient.png "BMP3:out_$@/$$i" || \
- exit 1; \
- done
- @for i in ${OTHER_IMAGES}; do \
- echo " out_$@/$$i" && \
- convert $$i -scale '${_x86_scale}' ${_x86_opts} \
- "BMP3:out_$@/$$i" || \
- exit 1; \
- done
- # produce the new yaml
+ ./build_images "$@"
cd "out_$@" && ../make_default_yaml ${DEFAULT_LOCALES}
cd "out_$@" && bmpblk_utility -c DEFAULT.yaml bmpblock.bin
ls -l "out_$@"/bmpblock.bin
arm::
- # create output directories
- mkdir -p "out_$@"
- for i in localized_images/*; do \
- mkdir -p "out_$@/$$i"; \
- done
- # copy stuff we need
- cp "${FONTS}" "out_$@"
- convert ${BACKGROUND_IMAGE} -append \
- -colors 256 -unique-colors "out_$@/base_cmap.png"
- convert localized_images/*/*.bmp -append \
- -colors 256 -unique-colors "out_$@/loc_cmap.png"
- # scale the background exactly...
- echo " out_$@/${BACKGROUND_IMAGE}"; \
- convert ${BACKGROUND_IMAGE} -scale "${_arm_max}" \
- -remap "out_$@/base_cmap.png" "out_$@/${BACKGROUND_IMAGE}"; \
- done
- # scale the localized string images using percentages...
- @for i in ${GRAYSCALE_IMAGES} ${OTHER_IMAGES} localized_images/*/*.bmp; do \
- echo " out_$@/$$i"; \
- convert $$i -scale "${_arm_scale}" \
- -remap "out_$@/loc_cmap.png" "out_$@/$$i"; \
- done
- # produce the new yaml
+ ./build_images "$@"
cd "out_$@" && ../make_default_yaml ${DEFAULT_LOCALES}
- perl -i -p -e 's/^compression:.*/compression: 2/;' "out_$@/DEFAULT.yaml"
- # Note: manually use bmpblk_utility to create the binary from out_$@
-
-
-
+ cd "out_$@" && bmpblk_utility -c DEFAULT.yaml bmpblock.bin
+ ls -l "out_$@"/bmpblock.bin
clean:
rm -rf out_*
diff --git a/scripts/newbitmaps/images/build_images b/scripts/newbitmaps/images/build_images
new file mode 100755
index 00000000..9245d0f0
--- /dev/null
+++ b/scripts/newbitmaps/images/build_images
@@ -0,0 +1,90 @@
+#!/bin/sh
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Prepares image resources into output folder.
+
+# Composition settings
+BACKGROUND_COLOR=white
+
+# The only file that uses different scaling parameter.
+BACKGROUND_IMAGE=Background_white.bmp
+
+die() {
+ echo "$*" >&2
+ exit 1
+}
+
+convert_to_bmp3() {
+ local input="$1"
+ local folder="$2"
+ local param="$3"
+ local output="$(basename "$input")"
+
+ # Always output as .bmp
+ output="${output%.*}.bmp"
+ mkdir -p "$folder"
+
+ # TODO(hungte) Add -flatten to support converting images with transparency.
+ # Syntax: -background "$BACKGROUND_COLOR" -flatten
+ # (Currently conflicts with -colors that will create 1 bit /pixel images)
+ echo "$input -> $folder/$output"
+ convert "$input" \
+ -compress none -alpha off -colors 256 \
+ $param "BMP3:$folder/$output"
+}
+
+main() {
+ local profile="$1"
+ local output="out_$1"
+ local scale_param="" background_scale_param=""
+ local base locale X
+
+ # Currently we use image resources originally designed for 1366x768, and
+ # re-scale to different aspects on demand.
+ case "$profile" in
+ x86 )
+ # The image size with x86 UEFI BIOS (also applies to coreboot) is always
+ # 800x600, which is stretched to fill the entire screen. With previous
+ # devices the physical screen size was either 1280x800 (16:10) or 1366x768
+ # (16:9). There's not a lot of difference between those, so let's just
+ # assume 16:9 for future platforms to make things simpler.
+ scale_param="-scale 59%x78%"
+ background_scale_param="-scale 800x600!"
+ ;;
+ arm )
+ # On ARM platforms, we need to provide a bitmap with full size.
+ # TODO(hungte) Support more profiles, ex 1280x800.
+ true
+ ;;
+ * )
+ die "Sorry, unknown profile $profile."
+ esac
+
+ # Prepare output folder
+ mkdir -p "$output"
+ cp hwid_fonts.bin "$output"
+
+ # Prepare images in current folder
+ # TODO(hungte) Deprecate arrow*.bmp by markup &#x25c0; and &#x25b6;, and
+ # Url.bmp by <span foreground="blue">http://</span>.
+ for X in *.bmp *.png; do
+ if [ "$X" = "$BACKGROUND_IMAGE" ]; then
+ convert_to_bmp3 "$X" "$output" "$background_scale_param"
+ else
+ convert_to_bmp3 "$X" "$output" "$convert_param"
+ fi
+ done
+
+ # Prepares localized images
+ base="../strings/localized_text"
+ for X in $base/*/*.png; do
+ locale="$(basename $(dirname $X))"
+ convert_to_bmp3 "$X" "$output/locale/$locale" "$scale_param"
+ done
+}
+
+set -e
+main "$@"
+
diff --git a/scripts/newbitmaps/images/make_default_yaml b/scripts/newbitmaps/images/make_default_yaml
index 2bc2fb91..14d76f4a 100755
--- a/scripts/newbitmaps/images/make_default_yaml
+++ b/scripts/newbitmaps/images/make_default_yaml
@@ -10,7 +10,7 @@ yaml_file="DEFAULT.yaml"
# I'm sorting the locales in more-or-less geographical order. Right should move
# east, left should move west. Of course we'll start in the US. :-)
locales="en es_419 pt_BR en_GB fr es pt_PT ca it de el nl da no sv fi et lv lt ru pl cs sk hu sl sr hr bg ro uk tr iw ar fa hi th vi id fil zh_CN zh_TW ko ja"
-localedir="./localized_images"
+localedir="./locale"
# These render right-to-left
rtol="ar fa iw"
@@ -69,7 +69,7 @@ set_centered_y_percent() {
# Return width of a .bmp file specified by a variable.
get_width() {
local filename="$(eval "echo \$$1")"
- file ${filename} | awk '{print $7}' | sed -e 's/[^0-9]//g'
+ identify -format "%[fx:w]" "$filename"
}
# Return the width of a list of images.
@@ -84,7 +84,7 @@ total_width() {
# Return height of a .bmp file specified by a variable.
get_height() {
local filename="$(eval "echo \$${1}")"
- file ${filename} | awk '{print $9}' | sed -e 's/[^0-9]//g'
+ identify -format "%[fx:h]" "$filename"
}
# Returns the max height of a list of images.