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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h

Issue 2173603003: Revert of Cancel image loads if decoding failed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 enum AlphaOption { 87 enum AlphaOption {
88 AlphaPremultiplied, 88 AlphaPremultiplied,
89 AlphaNotPremultiplied 89 AlphaNotPremultiplied
90 }; 90 };
91 91
92 enum GammaAndColorProfileOption { 92 enum GammaAndColorProfileOption {
93 GammaAndColorProfileApplied, 93 GammaAndColorProfileApplied,
94 GammaAndColorProfileIgnored 94 GammaAndColorProfileIgnored
95 }; 95 };
96 96
97 enum class SniffResult {
98 JPEG,
99 PNG,
100 GIF,
101 WEBP,
102 ICO,
103 BMP,
104 InsufficientData,
105 Invalid
106 };
107
108 static SniffResult determineImageType(const char* data, size_t length);
109 static SniffResult determineImageType(const SharedBuffer&);
110 static SniffResult determineImageType(const SegmentReader&);
111
112 ImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption colorOption s, size_t maxDecodedBytes) 97 ImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption colorOption s, size_t maxDecodedBytes)
113 : m_premultiplyAlpha(alphaOption == AlphaPremultiplied) 98 : m_premultiplyAlpha(alphaOption == AlphaPremultiplied)
114 , m_ignoreGammaAndColorProfile(colorOptions == GammaAndColorProfileIgnor ed) 99 , m_ignoreGammaAndColorProfile(colorOptions == GammaAndColorProfileIgnor ed)
115 , m_maxDecodedBytes(maxDecodedBytes) 100 , m_maxDecodedBytes(maxDecodedBytes)
116 , m_sizeAvailable(false) 101 , m_sizeAvailable(false)
117 , m_isAllDataReceived(false) 102 , m_isAllDataReceived(false)
118 , m_failed(false) { } 103 , m_failed(false) { }
119 104
120 virtual ~ImageDecoder() { } 105 virtual ~ImageDecoder() { }
121 106
122 // Returns a caller-owned decoder of the appropriate type. Returns 0 if 107 // Returns a caller-owned decoder of the appropriate type. Returns 0 if
123 // we can't sniff a supported type from the provided data (possibly 108 // we can't sniff a supported type from the provided data (possibly
124 // because there isn't enough data yet). 109 // because there isn't enough data yet).
125 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes(). 110 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes().
126 static std::unique_ptr<ImageDecoder> create(SniffResult, AlphaOption, GammaA ndColorProfileOption); 111 static std::unique_ptr<ImageDecoder> create(const char* data, size_t length, AlphaOption, GammaAndColorProfileOption);
112 static std::unique_ptr<ImageDecoder> create(const SharedBuffer&, AlphaOption , GammaAndColorProfileOption);
113 static std::unique_ptr<ImageDecoder> create(const SegmentReader&, AlphaOptio n, GammaAndColorProfileOption);
127 114
128 virtual String filenameExtension() const = 0; 115 virtual String filenameExtension() const = 0;
129 116
130 bool isAllDataReceived() const { return m_isAllDataReceived; } 117 bool isAllDataReceived() const { return m_isAllDataReceived; }
131 118
132 void setData(PassRefPtr<SegmentReader> data, bool allDataReceived) 119 void setData(PassRefPtr<SegmentReader> data, bool allDataReceived)
133 { 120 {
134 if (m_failed) 121 if (m_failed)
135 return; 122 return;
136 m_data = data; 123 m_data = data;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 bool m_failed; 331 bool m_failed;
345 332
346 #if USE(QCMSLIB) 333 #if USE(QCMSLIB)
347 QCMSTransformUniquePtr m_sourceToOutputDeviceColorTransform; 334 QCMSTransformUniquePtr m_sourceToOutputDeviceColorTransform;
348 #endif 335 #endif
349 }; 336 };
350 337
351 } // namespace blink 338 } // namespace blink
352 339
353 #endif 340 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698