Revert "Revert "cache SkImage::Info calculation in lazypixelref""
This reverts commit 81eba32ab10f9210c742938819cf1218be5611c9.
ImageDecoder is changed to allow info to be NULL, since it is an output-only parameter.
R=scroggo@google.com
Review URL: https://codereview.chromium.org/33573002
git-svn-id: http://skia.googlecode.com/svn/trunk@11896 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index 3ee4112..89bd059 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -405,10 +405,6 @@
bool SkImageDecoder::DecodeMemoryToTarget(const void* buffer, size_t size,
SkImage::Info* info,
const SkBitmapFactory::Target* target) {
- if (NULL == info) {
- return false;
- }
-
// FIXME: Just to get this working, implement in terms of existing
// ImageDecoder calls.
SkBitmap bm;
@@ -427,14 +423,17 @@
// Now set info properly.
// Since Config is SkBitmap::kARGB_8888_Config, SkBitmapToImageInfo
// will always succeed.
- SkAssertResult(SkBitmapToImageInfo(bm, info));
+ if (info) {
+ SkAssertResult(SkBitmapToImageInfo(bm, info));
+ }
if (NULL == target) {
return true;
}
if (target->fRowBytes != SkToU32(bm.rowBytes())) {
- if (target->fRowBytes < SkImageMinRowBytes(*info)) {
+ size_t minRB = SkBitmap::ComputeRowBytes(bm.config(), bm.width());
+ if (target->fRowBytes < minRB) {
SkDEBUGFAIL("Desired row bytes is too small");
return false;
}