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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp

Issue 2257513002: Refactor ImageDecoder factories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 3 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 PlatformInstrumentation::willDecodeLazyPixelRef(uniqueID()); 114 PlatformInstrumentation::willDecodeLazyPixelRef(uniqueID());
115 bool decoded = m_frameGenerator->decodeToYUV(m_data.get(), m_frameIndex, siz eInfo.fSizes, planes, sizeInfo.fWidthBytes); 115 bool decoded = m_frameGenerator->decodeToYUV(m_data.get(), m_frameIndex, siz eInfo.fSizes, planes, sizeInfo.fWidthBytes);
116 PlatformInstrumentation::didDecodeLazyPixelRef(); 116 PlatformInstrumentation::didDecodeLazyPixelRef();
117 117
118 return decoded; 118 return decoded;
119 } 119 }
120 120
121 SkImageGenerator* DecodingImageGenerator::create(SkData* data) 121 SkImageGenerator* DecodingImageGenerator::create(SkData* data)
122 { 122 {
123 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkData(sk_ref _sp(data));
123 // We just need the size of the image, so we have to temporarily create an I mageDecoder. Since 124 // We just need the size of the image, so we have to temporarily create an I mageDecoder. Since
124 // we only need the size, it doesn't really matter about premul or not, or g amma settings. 125 // we only need the size, it doesn't really matter about premul or not, or g amma settings.
125 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(ImageDecoder::d etermineImageType(static_cast<const char*>(data->data()), data->size()), 126 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(segmentReader, true,
126 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl ied); 127 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl ied);
127 if (!decoder) 128 if (!decoder || !decoder->isSizeAvailable())
128 return 0; 129 return nullptr;
129
130 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkData(sk_ref _sp(data));
131 decoder->setData(segmentReader.get(), true);
132 if (!decoder->isSizeAvailable())
133 return 0;
134 130
135 const IntSize size = decoder->size(); 131 const IntSize size = decoder->size();
136 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh t()); 132 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh t());
137 133
138 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak e(size.width(), size.height()), false); 134 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak e(size.width(), size.height()), false);
139 if (!frame) 135 if (!frame)
140 return 0; 136 return nullptr;
141 137
142 return new DecodingImageGenerator(frame, info, segmentReader.release(), true , 0); 138 return new DecodingImageGenerator(frame, info, segmentReader.release(), true , 0);
143 } 139 }
144 140
145 } // namespace blink 141 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698