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

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

Issue 17620004: Remove bitmap reuse from SkImageDecoder. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add documentation. Created 7 years, 5 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 | « src/images/SkImageDecoder_libpng.cpp ('k') | src/images/SkImageDecoder_wbmp.cpp » ('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 2010, The Android Open Source Project 2 * Copyright 2010, The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 * http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 #endif 405 #endif
406 406
407 int origWidth, origHeight, hasAlpha; 407 int origWidth, origHeight, hasAlpha;
408 if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) { 408 if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) {
409 return false; 409 return false;
410 } 410 }
411 this->fHasAlpha = hasAlpha; 411 this->fHasAlpha = hasAlpha;
412 412
413 const int sampleSize = this->getSampleSize(); 413 const int sampleSize = this->getSampleSize();
414 SkScaledBitmapSampler sampler(origWidth, origHeight, sampleSize); 414 SkScaledBitmapSampler sampler(origWidth, origHeight, sampleSize);
415
416 // If only bounds are requested, done
417 if (SkImageDecoder::kDecodeBounds_Mode == mode) {
418 if (!setDecodeConfig(decodedBitmap, sampler.scaledWidth(),
419 sampler.scaledHeight())) {
420 return false;
421 }
422 return true;
423 }
424
425 // No Bitmap reuse supported for this format
426 if (!decodedBitmap->isNull()) {
427 return false;
428 }
429 if (!setDecodeConfig(decodedBitmap, sampler.scaledWidth(), 415 if (!setDecodeConfig(decodedBitmap, sampler.scaledWidth(),
430 sampler.scaledHeight())) { 416 sampler.scaledHeight())) {
431 return false; 417 return false;
432 } 418 }
433 419
420 // If only bounds are requested, done
421 if (SkImageDecoder::kDecodeBounds_Mode == mode) {
422 return true;
423 }
424
434 if (!this->allocPixelRef(decodedBitmap, NULL)) { 425 if (!this->allocPixelRef(decodedBitmap, NULL)) {
435 return return_false(*decodedBitmap, "allocPixelRef"); 426 return return_false(*decodedBitmap, "allocPixelRef");
436 } 427 }
437 428
438 SkAutoLockPixels alp(*decodedBitmap); 429 SkAutoLockPixels alp(*decodedBitmap);
439 430
440 WebPDecoderConfig config; 431 WebPDecoderConfig config;
441 if (!webp_get_config_resize(&config, decodedBitmap, origWidth, origHeight, 432 if (!webp_get_config_resize(&config, decodedBitmap, origWidth, origHeight,
442 this->shouldPremultiply())) { 433 this->shouldPremultiply())) {
443 return false; 434 return false;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 return SkImageDecoder::kUnknown_Format; 593 return SkImageDecoder::kUnknown_Format;
603 } 594 }
604 595
605 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 596 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
606 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 597 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L;
607 } 598 }
608 599
609 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libwebp_dfactory); 600 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libwebp_dfactory);
610 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_webp ); 601 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_webp );
611 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libwebp_efact ory); 602 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libwebp_efact ory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | src/images/SkImageDecoder_wbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698