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

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: cleanup. tableChanged was wrong - do proper check. Created 5 years 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived, bool isMultiFrame); 63 ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived, bool isMultiFrame);
64 ~ImageFrameGenerator(); 64 ~ImageFrameGenerator();
65 65
66 // Decodes and scales the specified frame indicated by |index|. Dimensions 66 // Decodes and scales the specified frame indicated by |index|. Dimensions
67 // and output format are specified in |info|. Decoded pixels are written 67 // and output format are specified in |info|. Decoded pixels are written
68 // into |pixels| with a stride of |rowBytes|. 68 // into |pixels| with a stride of |rowBytes|.
69 // 69 //
70 // Returns true if decoding was successful. 70 // Returns true if decoding was successful.
71 bool decodeAndScale(const SkImageInfo&, size_t index, void* pixels, size_t r owBytes); 71 bool decodeAndScale(const SkImageInfo&, size_t index, void* pixels, size_t r owBytes, SkPMColor ctable[] = nullptr, int* ctableCount = nullptr);
72 72
73 // Decodes YUV components directly into the provided memory planes. 73 // Decodes YUV components directly into the provided memory planes.
74 bool decodeToYUV(SkISize componentSizes[3], void* planes[3], size_t rowBytes [3]); 74 bool decodeToYUV(SkISize componentSizes[3], void* planes[3], size_t rowBytes [3]);
75 75
76 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); 76 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived);
77 77
78 // Creates a new SharedBuffer containing the data received so far. 78 // Creates a new SharedBuffer containing the data received so far.
79 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived); 79 void copyData(RefPtr<SharedBuffer>*, bool* allDataReceived);
80 80
81 SkISize getFullSize() const { return m_fullSize; } 81 SkISize getFullSize() const { return m_fullSize; }
82 82
83 bool isMultiFrame() const { return m_isMultiFrame; } 83 bool isMultiFrame() const { return m_isMultiFrame; }
84 84
85 // FIXME: Return alpha state for each frame. 85 // FIXME: Return alpha state for each frame.
86 bool hasAlpha(size_t); 86 bool hasAlpha(size_t);
87 87
88 bool getYUVComponentSizes(SkISize componentSizes[3]); 88 bool getYUVComponentSizes(SkISize componentSizes[3]);
89 89
90 // Specifies that there is decoder support, to optimize when to call canDeco deTo().
91 void setDecoderCanDecodeToIndex8(bool canIt) { m_decoderCanDecodeToIndex8 = canIt; }
92 bool canDecodeTo(size_t index, SkColorType outputType);
93
90 private: 94 private:
91 class ExternalMemoryAllocator; 95 class ExternalMemoryAllocator;
92 friend class ImageFrameGeneratorTest; 96 friend class ImageFrameGeneratorTest;
93 friend class DeferredImageDecoderTest; 97 friend class DeferredImageDecoderTest;
94 // For testing. |factory| will overwrite the default ImageDecoder creation l ogic if |factory->create()| returns non-zero. 98 // For testing. |factory| will overwrite the default ImageDecoder creation l ogic if |factory->create()| returns non-zero.
95 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima geDecoderFactory = factory; } 99 void setImageDecoderFactory(PassOwnPtr<ImageDecoderFactory> factory) { m_ima geDecoderFactory = factory; }
96 100
97 void setHasAlpha(size_t index, bool hasAlpha); 101 void setHasAlpha(size_t index, bool hasAlpha);
98 102
99 // These methods are called while m_decodeMutex is locked. 103 // These methods are called while m_decodeMutex is locked.
100 SkBitmap tryToResumeDecode(const SkISize& scaledSize, size_t index); 104 SkBitmap tryToResumeDecode(const SkISize& scaledSize, size_t index, SkColorT ype outputColor);
101 105
102 // Use the given decoder to decode. If a decoder is not given then try to cr eate one. 106 // Use the given decoder to decode. If a decoder is not given then try to cr eate one.
103 // Returns true if decoding was complete. 107 // Returns true if decoding was complete.
104 bool decode(size_t index, ImageDecoder**, SkBitmap*); 108 bool decode(size_t index, ImageDecoder**, SkBitmap*, SkColorType);
105 109
106 SkISize m_fullSize; 110 SkISize m_fullSize;
107 ThreadSafeDataTransport m_data; 111 ThreadSafeDataTransport m_data;
108 bool m_isMultiFrame; 112 bool m_isMultiFrame;
109 bool m_decodeFailedAndEmpty; 113 bool m_decodeFailedAndEmpty;
110 Vector<bool> m_hasAlpha; 114 Vector<bool> m_hasAlpha;
111 int m_decodeCount; 115 int m_decodeCount;
112 Vector<bool> m_frameComplete; 116 Vector<bool> m_frameComplete;
113 size_t m_frameCount; 117 size_t m_frameCount;
114 OwnPtr<ExternalMemoryAllocator> m_externalAllocator; 118 OwnPtr<ExternalMemoryAllocator> m_externalAllocator;
115 119
116 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory; 120 OwnPtr<ImageDecoderFactory> m_imageDecoderFactory;
117 121
118 // Prevents multiple decode operations on the same data. 122 // Prevents multiple decode operations on the same data.
119 Mutex m_decodeMutex; 123 Mutex m_decodeMutex;
120 124
121 // Protect concurrent access to m_hasAlpha. 125 // Protect concurrent access to m_hasAlpha.
122 Mutex m_alphaMutex; 126 Mutex m_alphaMutex;
127
128 bool m_decoderCanDecodeToIndex8;
123 }; 129 };
124 130
125 } // namespace blink 131 } // namespace blink
126 132
127 #endif 133 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698