Avoid getLength in ico decoder.

Only call getLength() if hasLength() returned true. Otherwise, copy the
stream into an SkDynamicMemoryWStream and copy it into alloc'ed space.

Share common code between bmp and ico.

BUG=https://b.corp.google.com/issue?id=8432093
R=djsollen@google.com

Review URL: https://codereview.chromium.org/23330002

git-svn-id: http://skia.googlecode.com/svn/trunk@10850 2bbb7eff-a529-9590-31e7-b0007b416f81
5 files changed