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

Side by Side Diff: Source/platform/image-decoders/ImageDecoder.cpp

Issue 1161203004: blink: Allow image decodes to work without a Platform (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | no next file » | 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 (C) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 inline bool matchesBMPSignature(char* contents) 81 inline bool matchesBMPSignature(char* contents)
82 { 82 {
83 return !memcmp(contents, "BM", 2); 83 return !memcmp(contents, "BM", 2);
84 } 84 }
85 85
86 PassOwnPtr<ImageDecoder> ImageDecoder::create(const SharedBuffer& data, ImageSou rce::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndCo lorProfileOption) 86 PassOwnPtr<ImageDecoder> ImageDecoder::create(const SharedBuffer& data, ImageSou rce::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndCo lorProfileOption)
87 { 87 {
88 const unsigned longestSignatureLength = sizeof("RIFF????WEBPVP") - 1; 88 const unsigned longestSignatureLength = sizeof("RIFF????WEBPVP") - 1;
89 ASSERT(longestSignatureLength == 14); 89 ASSERT(longestSignatureLength == 14);
90 90
91 size_t maxDecodedBytes = Platform::current()->maxDecodedImageBytes(); 91 size_t maxDecodedBytes = Platform::current() ? Platform::current()->maxDecod edImageBytes() : noDecodedImageByteLimit;
92 92
93 char contents[longestSignatureLength]; 93 char contents[longestSignatureLength];
94 if (copyFromSharedBuffer(contents, longestSignatureLength, data, 0) < longes tSignatureLength) 94 if (copyFromSharedBuffer(contents, longestSignatureLength, data, 0) < longes tSignatureLength)
95 return nullptr; 95 return nullptr;
96 96
97 if (matchesJPEGSignature(contents)) 97 if (matchesJPEGSignature(contents))
98 return adoptPtr(new JPEGImageDecoder(alphaOption, gammaAndColorProfileOp tion, maxDecodedBytes)); 98 return adoptPtr(new JPEGImageDecoder(alphaOption, gammaAndColorProfileOp tion, maxDecodedBytes));
99 99
100 if (matchesPNGSignature(contents)) 100 if (matchesPNGSignature(contents))
101 return adoptPtr(new PNGImageDecoder(alphaOption, gammaAndColorProfileOpt ion, maxDecodedBytes)); 101 return adoptPtr(new PNGImageDecoder(alphaOption, gammaAndColorProfileOpt ion, maxDecodedBytes));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 return m_planes[i]; 255 return m_planes[i];
256 } 256 }
257 257
258 size_t ImagePlanes::rowBytes(int i) const 258 size_t ImagePlanes::rowBytes(int i) const
259 { 259 {
260 ASSERT((i >= 0) && i < 3); 260 ASSERT((i >= 0) && i < 3);
261 return m_rowBytes[i]; 261 return m_rowBytes[i];
262 } 262 }
263 263
264 } // namespace blink 264 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698