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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.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) 2006 Apple Computer, Inc. 2 * Copyright (C) 2006 Apple Computer, Inc.
3 * 3 *
4 * Portions are Copyright (C) 2001-6 mozilla.org 4 * Portions are Copyright (C) 2001-6 mozilla.org
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Stuart Parmenter <stuart@mozilla.com> 7 * Stuart Parmenter <stuart@mozilla.com>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 jpeg_decompress_struct* info = m_reader->info(); 930 jpeg_decompress_struct* info = m_reader->info();
931 931
932 // Initialize the framebuffer if needed. 932 // Initialize the framebuffer if needed.
933 ImageFrame& buffer = m_frameBufferCache[0]; 933 ImageFrame& buffer = m_frameBufferCache[0];
934 if (buffer.getStatus() == ImageFrame::FrameEmpty) { 934 if (buffer.getStatus() == ImageFrame::FrameEmpty) {
935 DCHECK_EQ(info->output_width, 935 DCHECK_EQ(info->output_width,
936 static_cast<JDIMENSION>(m_decodedSize.width())); 936 static_cast<JDIMENSION>(m_decodedSize.width()));
937 DCHECK_EQ(info->output_height, 937 DCHECK_EQ(info->output_height,
938 static_cast<JDIMENSION>(m_decodedSize.height())); 938 static_cast<JDIMENSION>(m_decodedSize.height()));
939 939
940 if (!buffer.setSizeAndColorSpace(info->output_width, info->output_height, 940 if (!buffer.allocatePixelData(info->output_width, info->output_height,
941 colorSpaceForSkImages())) 941 colorSpaceForSkImages()))
942 return setFailed(); 942 return setFailed();
943 943
944 buffer.zeroFillPixelData();
945
944 // The buffer is transparent outside the decoded area while the image is 946 // The buffer is transparent outside the decoded area while the image is
scroggo_chromium 2017/03/17 14:36:38 This comment seems to apply to the line that you h
cblume 2017/03/17 18:05:45 Done.
945 // loading. The image will be marked fully opaque in complete(). 947 // loading. The image will be marked fully opaque in complete().
946 buffer.setStatus(ImageFrame::FramePartial); 948 buffer.setStatus(ImageFrame::FramePartial);
947 buffer.setHasAlpha(true);
948 949
949 // For JPEGs, the frame always fills the entire image. 950 // For JPEGs, the frame always fills the entire image.
950 buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); 951 buffer.setOriginalFrameRect(IntRect(IntPoint(), size()));
951 } 952 }
952 953
953 #if defined(TURBO_JPEG_RGB_SWIZZLE) 954 #if defined(TURBO_JPEG_RGB_SWIZZLE)
954 if (turboSwizzled(info->out_color_space)) { 955 if (turboSwizzled(info->out_color_space)) {
955 while (info->output_scanline < info->output_height) { 956 while (info->output_scanline < info->output_height) {
956 unsigned char* row = reinterpret_cast_ptr<unsigned char*>( 957 unsigned char* row = reinterpret_cast_ptr<unsigned char*>(
957 buffer.getAddr(0, info->output_scanline)); 958 buffer.getAddr(0, info->output_scanline));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 // has failed. 1010 // has failed.
1010 if (!m_reader->decode(onlySize) && isAllDataReceived()) 1011 if (!m_reader->decode(onlySize) && isAllDataReceived())
1011 setFailed(); 1012 setFailed();
1012 1013
1013 // If decoding is done or failed, we don't need the JPEGImageReader anymore. 1014 // If decoding is done or failed, we don't need the JPEGImageReader anymore.
1014 if (isComplete(this, onlySize) || failed()) 1015 if (isComplete(this, onlySize) || failed())
1015 m_reader.reset(); 1016 m_reader.reset();
1016 } 1017 }
1017 1018
1018 } // namespace blink 1019 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698