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

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

Issue 2749703002: Refactor ImageFrame::setSizeAndColorSpace() (Closed)
Patch Set: Moving to another CR the separation of zeroing pixel data from setting alpha 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) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 ImageFrame* const buffer = &m_frameBufferCache[frameIndex]; 348 ImageFrame* const buffer = &m_frameBufferCache[frameIndex];
349 349
350 // If the frame is already initialized, return true. 350 // If the frame is already initialized, return true.
351 if (buffer->getStatus() != ImageFrame::FrameEmpty) 351 if (buffer->getStatus() != ImageFrame::FrameEmpty)
352 return true; 352 return true;
353 353
354 size_t requiredPreviousFrameIndex = buffer->requiredPreviousFrameIndex(); 354 size_t requiredPreviousFrameIndex = buffer->requiredPreviousFrameIndex();
355 if (requiredPreviousFrameIndex == kNotFound) { 355 if (requiredPreviousFrameIndex == kNotFound) {
356 // This frame doesn't rely on any previous data. 356 // This frame doesn't rely on any previous data.
357 if (!buffer->setSizeAndColorSpace(size().width(), size().height(), 357 if (!buffer->allocatePixelData(size().width(), size().height(),
358 colorSpaceForSkImages())) { 358 colorSpaceForSkImages())) {
359 return false; 359 return false;
360 } 360 }
361 buffer->zeroFillPixelData();
361 } else { 362 } else {
362 ImageFrame* const prevBuffer = 363 ImageFrame* const prevBuffer =
363 &m_frameBufferCache[requiredPreviousFrameIndex]; 364 &m_frameBufferCache[requiredPreviousFrameIndex];
364 DCHECK(prevBuffer->getStatus() == ImageFrame::FrameComplete); 365 DCHECK(prevBuffer->getStatus() == ImageFrame::FrameComplete);
365 366
366 // We try to reuse |prevBuffer| as starting state to avoid copying. 367 // We try to reuse |prevBuffer| as starting state to avoid copying.
367 // If canReusePreviousFrameBuffer returns false, we must copy the data since 368 // If canReusePreviousFrameBuffer returns false, we must copy the data since
368 // |prevBuffer| is necessary to decode this or later frames. In that case, 369 // |prevBuffer| is necessary to decode this or later frames. In that case,
369 // copy the data instead. 370 // copy the data instead.
370 if ((!canReusePreviousFrameBuffer(frameIndex) || 371 if ((!canReusePreviousFrameBuffer(frameIndex) ||
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 sk_sp<SkColorSpace> ImageDecoder::colorSpaceForSkImages() const { 548 sk_sp<SkColorSpace> ImageDecoder::colorSpaceForSkImages() const {
548 if (!m_colorBehavior.isTag()) 549 if (!m_colorBehavior.isTag())
549 return nullptr; 550 return nullptr;
550 551
551 if (m_embeddedColorSpace) 552 if (m_embeddedColorSpace)
552 return m_embeddedColorSpace; 553 return m_embeddedColorSpace;
553 return SkColorSpace::MakeSRGB(); 554 return SkColorSpace::MakeSRGB();
554 } 555 }
555 556
556 } // namespace blink 557 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698