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

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

Issue 122283002: Revert of remove Sk64 from public API, and start to remove usage internally (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkRegion_path.cpp ('k') | tests/BitmapCopyTest.cpp » ('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 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 VP8StatusCode status = WebPGetFeatures(buffer, totalBytesRead, &features); 73 VP8StatusCode status = WebPGetFeatures(buffer, totalBytesRead, &features);
74 if (VP8_STATUS_OK != status) { 74 if (VP8_STATUS_OK != status) {
75 return false; // Invalid WebP file. 75 return false; // Invalid WebP file.
76 } 76 }
77 *width = features.width; 77 *width = features.width;
78 *height = features.height; 78 *height = features.height;
79 *alpha = features.has_alpha; 79 *alpha = features.has_alpha;
80 80
81 // sanity check for image size that's about to be decoded. 81 // sanity check for image size that's about to be decoded.
82 { 82 {
83 int64_t size = sk_64_mul(*width, *height); 83 Sk64 size;
84 if (!sk_64_isS32(size)) { 84 size.setMul(*width, *height);
85 if (size.isNeg() || !size.is32()) {
85 return false; 86 return false;
86 } 87 }
87 // now check that if we are 4-bytes per pixel, we also don't overflow 88 // now check that if we are 4-bytes per pixel, we also don't overflow
88 if (sk_64_asS32(size) > (0x7FFFFFFF >> 2)) { 89 if (size.get32() > (0x7FFFFFFF >> 2)) {
89 return false; 90 return false;
90 } 91 }
91 } 92 }
92 return true; 93 return true;
93 } 94 }
94 95
95 class SkWEBPImageDecoder: public SkImageDecoder { 96 class SkWEBPImageDecoder: public SkImageDecoder {
96 public: 97 public:
97 SkWEBPImageDecoder() { 98 SkWEBPImageDecoder() {
98 fInputStream = NULL; 99 fInputStream = NULL;
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 return SkImageDecoder::kUnknown_Format; 596 return SkImageDecoder::kUnknown_Format;
596 } 597 }
597 598
598 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 599 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
599 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 600 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L;
600 } 601 }
601 602
602 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); 603 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
603 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); 604 static SkImageDecoder_FormatReg gFormatReg(get_format_webp);
604 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); 605 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory);
OLDNEW
« no previous file with comments | « src/core/SkRegion_path.cpp ('k') | tests/BitmapCopyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698