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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 2749703002: Refactor ImageFrame::setSizeAndColorSpace() (Closed)
Patch Set: Remove comments that focus on transparency, which is no longer explicitly set Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (failed()) 450 if (failed())
451 return false; 451 return false;
452 452
453 DCHECK(isDecodedSizeAvailable()); 453 DCHECK(isDecodedSizeAvailable());
454 454
455 DCHECK_GT(m_frameBufferCache.size(), frameIndex); 455 DCHECK_GT(m_frameBufferCache.size(), frameIndex);
456 ImageFrame& buffer = m_frameBufferCache[frameIndex]; 456 ImageFrame& buffer = m_frameBufferCache[frameIndex];
457 DCHECK_NE(buffer.getStatus(), ImageFrame::FrameComplete); 457 DCHECK_NE(buffer.getStatus(), ImageFrame::FrameComplete);
458 458
459 if (buffer.getStatus() == ImageFrame::FrameEmpty) { 459 if (buffer.getStatus() == ImageFrame::FrameEmpty) {
460 if (!buffer.setSizeAndColorSpace(size().width(), size().height(), 460 if (!buffer.allocatePixelData(size().width(), size().height(),
461 colorSpaceForSkImages())) 461 colorSpaceForSkImages()))
462 return setFailed(); 462 return setFailed();
463 buffer.zeroFillPixelData();
463 buffer.setStatus(ImageFrame::FramePartial); 464 buffer.setStatus(ImageFrame::FramePartial);
464 // The buffer is transparent outside the decoded area while the image is
465 // loading. The correct alpha value for the frame will be set when it is
466 // fully decoded.
467 buffer.setHasAlpha(true);
468 buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); 465 buffer.setOriginalFrameRect(IntRect(IntPoint(), size()));
469 } 466 }
470 467
471 const IntRect& frameRect = buffer.originalFrameRect(); 468 const IntRect& frameRect = buffer.originalFrameRect();
472 if (!m_decoder) { 469 if (!m_decoder) {
473 WEBP_CSP_MODE mode = outputMode(m_formatFlags & ALPHA_FLAG); 470 WEBP_CSP_MODE mode = outputMode(m_formatFlags & ALPHA_FLAG);
474 if (!m_premultiplyAlpha) 471 if (!m_premultiplyAlpha)
475 mode = outputMode(false); 472 mode = outputMode(false);
476 if (colorTransform()) { 473 if (colorTransform()) {
477 // Swizzling between RGBA and BGRA is zero cost in a color transform. 474 // Swizzling between RGBA and BGRA is zero cost in a color transform.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 return false; 509 return false;
513 } 510 }
514 // FALLTHROUGH 511 // FALLTHROUGH
515 default: 512 default:
516 clear(); 513 clear();
517 return setFailed(); 514 return setFailed();
518 } 515 }
519 } 516 }
520 517
521 } // namespace blink 518 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698