Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: src/images/SkImageDecoder.cpp

Issue 33573002: Revert "Revert "cache SkImage::Info calculation in lazypixelref"" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/lazy/SkLazyPixelRef.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 return false; 398 return false;
399 } 399 }
400 400
401 bitmap->swap(bm8888); 401 bitmap->swap(bm8888);
402 return true; 402 return true;
403 } 403 }
404 404
405 bool SkImageDecoder::DecodeMemoryToTarget(const void* buffer, size_t size, 405 bool SkImageDecoder::DecodeMemoryToTarget(const void* buffer, size_t size,
406 SkImage::Info* info, 406 SkImage::Info* info,
407 const SkBitmapFactory::Target* target) { 407 const SkBitmapFactory::Target* target) {
408 if (NULL == info) {
409 return false;
410 }
411
412 // FIXME: Just to get this working, implement in terms of existing 408 // FIXME: Just to get this working, implement in terms of existing
413 // ImageDecoder calls. 409 // ImageDecoder calls.
414 SkBitmap bm; 410 SkBitmap bm;
415 SkMemoryStream stream(buffer, size); 411 SkMemoryStream stream(buffer, size);
416 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream)); 412 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&stream));
417 if (NULL == decoder.get()) { 413 if (NULL == decoder.get()) {
418 return false; 414 return false;
419 } 415 }
420 416
421 if (!decode_bounds_to_8888(decoder.get(), &stream, &bm)) { 417 if (!decode_bounds_to_8888(decoder.get(), &stream, &bm)) {
422 return false; 418 return false;
423 } 419 }
424 420
425 SkASSERT(bm.config() == SkBitmap::kARGB_8888_Config); 421 SkASSERT(bm.config() == SkBitmap::kARGB_8888_Config);
426 422
427 // Now set info properly. 423 // Now set info properly.
428 // Since Config is SkBitmap::kARGB_8888_Config, SkBitmapToImageInfo 424 // Since Config is SkBitmap::kARGB_8888_Config, SkBitmapToImageInfo
429 // will always succeed. 425 // will always succeed.
430 SkAssertResult(SkBitmapToImageInfo(bm, info)); 426 if (info) {
427 SkAssertResult(SkBitmapToImageInfo(bm, info));
428 }
431 429
432 if (NULL == target) { 430 if (NULL == target) {
433 return true; 431 return true;
434 } 432 }
435 433
436 if (target->fRowBytes != SkToU32(bm.rowBytes())) { 434 if (target->fRowBytes != SkToU32(bm.rowBytes())) {
437 if (target->fRowBytes < SkImageMinRowBytes(*info)) { 435 size_t minRB = SkBitmap::ComputeRowBytes(bm.config(), bm.width());
436 if (target->fRowBytes < minRB) {
438 SkDEBUGFAIL("Desired row bytes is too small"); 437 SkDEBUGFAIL("Desired row bytes is too small");
439 return false; 438 return false;
440 } 439 }
441 bm.setConfig(bm.config(), bm.width(), bm.height(), target->fRowBytes); 440 bm.setConfig(bm.config(), bm.width(), bm.height(), target->fRowBytes);
442 } 441 }
443 442
444 // SkMemoryStream.rewind() will always return true. 443 // SkMemoryStream.rewind() will always return true.
445 SkAssertResult(stream.rewind()); 444 SkAssertResult(stream.rewind());
446 return decode_pixels_to_8888(decoder.get(), &stream, &bm, target->fAddr); 445 return decode_pixels_to_8888(decoder.get(), &stream, &bm, target->fAddr);
447 } 446 }
(...skipping 15 matching lines...) Expand all
463 if (kUnknown_Format == *format) { 462 if (kUnknown_Format == *format) {
464 if (stream->rewind()) { 463 if (stream->rewind()) {
465 *format = GetStreamFormat(stream); 464 *format = GetStreamFormat(stream);
466 } 465 }
467 } 466 }
468 } 467 }
469 delete codec; 468 delete codec;
470 } 469 }
471 return success; 470 return success;
472 } 471 }
OLDNEW
« no previous file with comments | « no previous file | src/lazy/SkLazyPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698