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

Side by Side Diff: src/codec/SkIcoCodec.cpp

Issue 1820073002: Add SkEncodedInfo to report properties of encoded image data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Order of param eval bug Created 4 years, 8 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
« no previous file with comments | « src/codec/SkIcoCodec.h ('k') | src/codec/SkJpegCodec.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBmpCodec.h" 8 #include "SkBmpCodec.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 uint32_t maxSize = 0; 161 uint32_t maxSize = 0;
162 uint32_t maxIndex = 0; 162 uint32_t maxIndex = 0;
163 for (int32_t i = 0; i < codecs->count(); i++) { 163 for (int32_t i = 0; i < codecs->count(); i++) {
164 SkImageInfo info = codecs->operator[](i)->getInfo(); 164 SkImageInfo info = codecs->operator[](i)->getInfo();
165 uint32_t size = info.width() * info.height(); 165 uint32_t size = info.width() * info.height();
166 if (size > maxSize) { 166 if (size > maxSize) {
167 maxSize = size; 167 maxSize = size;
168 maxIndex = i; 168 maxIndex = i;
169 } 169 }
170 } 170 }
171 SkImageInfo info = codecs->operator[](maxIndex)->getInfo(); 171 int width = codecs->operator[](maxIndex)->getInfo().width();
172 int height = codecs->operator[](maxIndex)->getInfo().height();
173 SkEncodedInfo info = codecs->operator[](maxIndex)->getEncodedInfo();
172 174
173 // Note that stream is owned by the embedded codec, the ico does not need 175 // Note that stream is owned by the embedded codec, the ico does not need
174 // direct access to the stream. 176 // direct access to the stream.
175 return new SkIcoCodec(info, codecs.release()); 177 return new SkIcoCodec(width, height, info, codecs.release());
176 } 178 }
177 179
178 /* 180 /*
179 * Creates an instance of the decoder 181 * Creates an instance of the decoder
180 * Called only by NewFromStream 182 * Called only by NewFromStream
181 */ 183 */
182 SkIcoCodec::SkIcoCodec(const SkImageInfo& info, 184 SkIcoCodec::SkIcoCodec(int width, int height, const SkEncodedInfo& info,
183 SkTArray<SkAutoTDelete<SkCodec>, true>* codecs) 185 SkTArray<SkAutoTDelete<SkCodec>, true>* codecs)
184 : INHERITED(info, nullptr) 186 : INHERITED(width, height, info, nullptr)
185 , fEmbeddedCodecs(codecs) 187 , fEmbeddedCodecs(codecs)
186 , fCurrScanlineCodec(nullptr) 188 , fCurrScanlineCodec(nullptr)
187 {} 189 {}
188 190
189 /* 191 /*
190 * Chooses the best dimensions given the desired scale 192 * Chooses the best dimensions given the desired scale
191 */ 193 */
192 SkISize SkIcoCodec::onGetScaledDimensions(float desiredScale) const { 194 SkISize SkIcoCodec::onGetScaledDimensions(float desiredScale) const {
193 // We set the dimensions to the largest candidate image by default. 195 // We set the dimensions to the largest candidate image by default.
194 // Regardless of the scale request, this is the largest image that we 196 // Regardless of the scale request, this is the largest image that we
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 SkCodec::SkScanlineOrder SkIcoCodec::onGetScanlineOrder() const { 312 SkCodec::SkScanlineOrder SkIcoCodec::onGetScanlineOrder() const {
311 // FIXME: This function will possibly return the wrong value if it is called 313 // FIXME: This function will possibly return the wrong value if it is called
312 // before startScanlineDecode(). 314 // before startScanlineDecode().
313 return fCurrScanlineCodec ? fCurrScanlineCodec->getScanlineOrder() : 315 return fCurrScanlineCodec ? fCurrScanlineCodec->getScanlineOrder() :
314 INHERITED::onGetScanlineOrder(); 316 INHERITED::onGetScanlineOrder();
315 } 317 }
316 318
317 SkSampler* SkIcoCodec::getSampler(bool createIfNecessary) { 319 SkSampler* SkIcoCodec::getSampler(bool createIfNecessary) {
318 return fCurrScanlineCodec ? fCurrScanlineCodec->getSampler(createIfNecessary ) : nullptr; 320 return fCurrScanlineCodec ? fCurrScanlineCodec->getSampler(createIfNecessary ) : nullptr;
319 } 321 }
OLDNEW
« no previous file with comments | « src/codec/SkIcoCodec.h ('k') | src/codec/SkJpegCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698