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

Side by Side Diff: src/images/SkImageDecoder_libwebp.cpp

Issue 1811613004: Change SkTime::GetMSecs to double; ensure values stored in SkMSec do not overflow. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Rebase. Created 4 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 2010, The Android Open Source Project 2 * Copyright 2010, The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 * http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 typedef SkImageDecoder INHERITED; 125 typedef SkImageDecoder INHERITED;
126 }; 126 };
127 127
128 ////////////////////////////////////////////////////////////////////////// 128 //////////////////////////////////////////////////////////////////////////
129 129
130 #ifdef TIME_DECODE 130 #ifdef TIME_DECODE
131 131
132 #include "SkTime.h" 132 #include "SkTime.h"
133 133
134 class AutoTimeMillis {
135 public:
136 AutoTimeMillis(const char label[]) :
137 fLabel(label) {
138 if (nullptr == fLabel) {
139 fLabel = "";
140 }
141 fNow = SkTime::GetMSecs();
142 }
143 ~AutoTimeMillis() {
144 SkDebugf("---- Time (ms): %s %d\n", fLabel, SkTime::GetMSecs() - fNow);
145 }
146 private:
147 const char* fLabel;
148 SkMSec fNow;
149 };
150
151 #endif 134 #endif
152 135
153 /////////////////////////////////////////////////////////////////////////////// 136 ///////////////////////////////////////////////////////////////////////////////
154 137
155 // This guy exists just to aid in debugging, as it allows debuggers to just 138 // This guy exists just to aid in debugging, as it allows debuggers to just
156 // set a break-point in one place to see all error exists. 139 // set a break-point in one place to see all error exists.
157 static void print_webp_error(const SkBitmap& bm, const char msg[]) { 140 static void print_webp_error(const SkBitmap& bm, const char msg[]) {
158 SkDEBUGF(("libwebp error %s [%d %d]", msg, bm.width(), bm.height())); 141 SkDEBUGF(("libwebp error %s [%d %d]", msg, bm.width(), bm.height()));
159 } 142 }
160 143
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } else { 262 } else {
280 alphaType = kPremul_SkAlphaType; 263 alphaType = kPremul_SkAlphaType;
281 } 264 }
282 } 265 }
283 return decodedBitmap->setInfo(SkImageInfo::Make(width, height, colorType, al phaType)); 266 return decodedBitmap->setInfo(SkImageInfo::Make(width, height, colorType, al phaType));
284 } 267 }
285 268
286 SkImageDecoder::Result SkWEBPImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap, 269 SkImageDecoder::Result SkWEBPImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap,
287 Mode mode) { 270 Mode mode) {
288 #ifdef TIME_DECODE 271 #ifdef TIME_DECODE
289 AutoTimeMillis atm("WEBP Decode"); 272 SkAutoTime atm("WEBP Decode");
290 #endif 273 #endif
291 274
292 int origWidth, origHeight, hasAlpha; 275 int origWidth, origHeight, hasAlpha;
293 if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) { 276 if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) {
294 return kFailure; 277 return kFailure;
295 } 278 }
296 this->fHasAlpha = hasAlpha; 279 this->fHasAlpha = hasAlpha;
297 280
298 const int sampleSize = this->getSampleSize(); 281 const int sampleSize = this->getSampleSize();
299 SkScaledBitmapSampler sampler(origWidth, origHeight, sampleSize); 282 SkScaledBitmapSampler sampler(origWidth, origHeight, sampleSize);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 return SkImageDecoder::kUnknown_Format; 533 return SkImageDecoder::kUnknown_Format;
551 } 534 }
552 535
553 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 536 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
554 return (SkImageEncoder::kWEBP_Type == t) ? new SkWEBPImageEncoder : nullptr; 537 return (SkImageEncoder::kWEBP_Type == t) ? new SkWEBPImageEncoder : nullptr;
555 } 538 }
556 539
557 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); 540 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
558 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); 541 static SkImageDecoder_FormatReg gFormatReg(get_format_webp);
559 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); 542 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698