Check pixelRef before attempting to ktx encode.

If there is no pixelRef, do not attempt to dereference it.

This was caught running on Android, where we don't have the resources
folder (tracked in b/14406768). We fail to decode anything, and then
attempt to encode an SkBitmap without a pixelRef.

R=krajcevski@google.com

Author: scroggo@google.com

Review URL: https://codereview.chromium.org/362413005
This commit is contained in:
scroggo 2014-07-02 15:00:07 -07:00 committed by Commit bot
parent 0e3fac215d
commit c2dcf4a4a5

View File

@ -209,6 +209,9 @@ private:
};
bool SkKTXImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int) {
if (!bitmap.pixelRef()) {
return false;
}
SkAutoDataUnref data(bitmap.pixelRef()->refEncodedData());
// Is this even encoded data?