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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.h

Issue 1460523002: GIF decoding to Index8, unit tests and misusing unit test as benchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment #25 processed. Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); 70 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived);
71 71
72 // Return our encoded image data. Caller takes ownership and must unref the data 72 // Return our encoded image data. Caller takes ownership and must unref the data
73 // according to the contract SkImageGenerator::refEncodedData. Returns null if 73 // according to the contract SkImageGenerator::refEncodedData. Returns null if
74 // the data is has not been fully received. 74 // the data is has not been fully received.
75 SkData* refEncodedData(); 75 SkData* refEncodedData();
76 76
77 // Decodes and scales the specified frame at |index|. The dimensions and out put 77 // Decodes and scales the specified frame at |index|. The dimensions and out put
78 // format are given in SkImageInfo. Decoded pixels are written into |pixels| with 78 // format are given in SkImageInfo. Decoded pixels are written into |pixels| with
79 // a stride of |rowBytes|. Returns true if decoding was successful. 79 // a stride of |rowBytes|. Returns true if decoding was successful.
80 bool decodeAndScale(size_t index, const SkImageInfo&, void* pixels, size_t r owBytes); 80 bool decodeAndScale(size_t index, const SkImageInfo&, void* pixels, size_t r owBytes, SkPMColor ctable[] = nullptr, int* ctableCount = nullptr);
81 81
82 // Decodes YUV components directly into the provided memory planes. 82 // Decodes YUV components directly into the provided memory planes.
83 bool decodeToYUV(size_t index, SkISize componentSizes[3], void* planes[3], s ize_t rowBytes[3]); 83 bool decodeToYUV(size_t index, SkISize componentSizes[3], void* planes[3], s ize_t rowBytes[3]);
84 84
85 const SkISize& getFullSize() const { return m_fullSize; } 85 const SkISize& getFullSize() const { return m_fullSize; }
86 86
87 bool isMultiFrame() const { return m_isMultiFrame; } 87 bool isMultiFrame() const { return m_isMultiFrame; }
88 bool decodeFailed() const { return m_decodeFailed; } 88 bool decodeFailed() const { return m_decodeFailed; }
89 89
90 bool hasAlpha(size_t index); 90 bool hasAlpha(size_t index);
91 91
92 bool getYUVComponentSizes(SkISize componentSizes[3]); 92 bool getYUVComponentSizes(SkISize componentSizes[3]);
93 93
94 // Specifies that there is decoder support, to optimize when to call canDeco deTo().
95 void setDecoderCanDecodeToIndex8(bool canIt) { m_decoderCanDecodeToIndex8 = canIt; }
96 bool canDecodeTo(size_t index, SkColorType outputType);
97
94 private: 98 private:
95 ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived, bool isMultiFrame); 99 ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived, bool isMultiFrame);
96 100
97 friend class ImageFrameGeneratorTest; 101 friend class ImageFrameGeneratorTest;
98 friend class DeferredImageDecoderTest; 102 friend class DeferredImageDecoderTest;
99 // For testing. |factory| will overwrite the default ImageDecoder creation l ogic if |factory->create()| returns non-zero. 103 // For testing. |factory| will overwrite the default ImageDecoder creation l ogic if |factory->create()| returns non-zero.
100 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima geDecoderFactory = std::move(factory); } 104 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima geDecoderFactory = std::move(factory); }
101 105
102 void setHasAlpha(size_t index, bool hasAlpha); 106 void setHasAlpha(size_t index, bool hasAlpha);
103 107
(...skipping 24 matching lines...) Expand all
128 132
129 // Protect concurrent access to m_hasAlpha. 133 // Protect concurrent access to m_hasAlpha.
130 Mutex m_alphaMutex; 134 Mutex m_alphaMutex;
131 135
132 // Our encoded image data returned in refEncodedData. 136 // Our encoded image data returned in refEncodedData.
133 SkData* m_encodedData; 137 SkData* m_encodedData;
134 138
135 #if COMPILER(MSVC) 139 #if COMPILER(MSVC)
136 friend struct ::WTF::OwnedPtrDeleter<ExternalMemoryAllocator>; 140 friend struct ::WTF::OwnedPtrDeleter<ExternalMemoryAllocator>;
137 #endif 141 #endif
142 bool m_decoderCanDecodeToIndex8;
138 }; 143 };
139 144
140 } // namespace blink 145 } // namespace blink
141 146
142 #endif 147 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698