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

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

Issue 2749703002: Refactor ImageFrame::setSizeAndColorSpace() (Closed)
Patch Set: Call setHasAlpha(true); from within zeroFillPixelData() 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.setStatus(ImageFrame::FramePartial); 463 buffer.zeroFillPixelData();
464 // The buffer is transparent outside the decoded area while the image is 464 // The buffer is transparent outside the decoded area while the image is
scroggo_chromium 2017/03/17 14:36:38 Similarly, this comment seems to apply to the line
cblume 2017/03/17 18:05:46 Done.
465 // loading. The correct alpha value for the frame will be set when it is 465 // loading. The correct alpha value for the frame will be set when it is
466 // fully decoded. 466 // fully decoded.
467 buffer.setHasAlpha(true); 467 buffer.setStatus(ImageFrame::FramePartial);
468 buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); 468 buffer.setOriginalFrameRect(IntRect(IntPoint(), size()));
469 } 469 }
470 470
471 const IntRect& frameRect = buffer.originalFrameRect(); 471 const IntRect& frameRect = buffer.originalFrameRect();
472 if (!m_decoder) { 472 if (!m_decoder) {
473 WEBP_CSP_MODE mode = outputMode(m_formatFlags & ALPHA_FLAG); 473 WEBP_CSP_MODE mode = outputMode(m_formatFlags & ALPHA_FLAG);
474 if (!m_premultiplyAlpha) 474 if (!m_premultiplyAlpha)
475 mode = outputMode(false); 475 mode = outputMode(false);
476 if (colorTransform()) { 476 if (colorTransform()) {
477 // Swizzling between RGBA and BGRA is zero cost in a color transform. 477 // 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; 512 return false;
513 } 513 }
514 // FALLTHROUGH 514 // FALLTHROUGH
515 default: 515 default:
516 clear(); 516 clear();
517 return setFailed(); 517 return setFailed();
518 } 518 }
519 } 519 }
520 520
521 } // namespace blink 521 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698