OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 * | 7 * |
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 bool WEBPImageDecoder::decode(bool onlySize) | 73 bool WEBPImageDecoder::decode(bool onlySize) |
74 { | 74 { |
75 // Minimum number of bytes needed to ensure one can parse size information. | 75 // Minimum number of bytes needed to ensure one can parse size information. |
76 static const size_t sizeOfHeader = 30; | 76 static const size_t sizeOfHeader = 30; |
77 // Number of bytes per pixel. | 77 // Number of bytes per pixel. |
78 static const int bytesPerPixel = 3; | 78 static const int bytesPerPixel = 3; |
79 | 79 |
80 if (failed()) | 80 if (failed()) |
81 return false; | 81 return false; |
82 const size_t dataSize = m_data->buffer().size(); | 82 const size_t dataSize = m_data->size(); |
83 const uint8_t* dataBytes = | 83 const uint8_t* dataBytes = |
84 reinterpret_cast<const uint8_t*>(m_data->buffer().data()); | 84 reinterpret_cast<const uint8_t*>(m_data->data()); |
85 int width, height; | 85 int width, height; |
86 if (dataSize < sizeOfHeader) | 86 if (dataSize < sizeOfHeader) |
87 return true; | 87 return true; |
88 if (!WebPGetInfo(dataBytes, dataSize, &width, &height)) | 88 if (!WebPGetInfo(dataBytes, dataSize, &width, &height)) |
89 return setFailed(); | 89 return setFailed(); |
90 if (!ImageDecoder::isSizeAvailable() && !setSize(width, height)) | 90 if (!ImageDecoder::isSizeAvailable() && !setSize(width, height)) |
91 return setFailed(); | 91 return setFailed(); |
92 if (onlySize) | 92 if (onlySize) |
93 return true; | 93 return true; |
94 | 94 |
(...skipping 21 matching lines...) Expand all Loading... |
116 } | 116 } |
117 buffer.setStatus(ImageFrame::FrameComplete); | 117 buffer.setStatus(ImageFrame::FrameComplete); |
118 buffer.setHasAlpha(false); | 118 buffer.setHasAlpha(false); |
119 buffer.setRect(IntRect(IntPoint(), size())); | 119 buffer.setRect(IntRect(IntPoint(), size())); |
120 return true; | 120 return true; |
121 } | 121 } |
122 | 122 |
123 } | 123 } |
124 | 124 |
125 #endif | 125 #endif |
OLD | NEW |