| 171 | } |
| 172 | |
| 173 | bool PAGDecoder::readFrameInternal(int index, std::shared_ptr<BitmapBuffer> bitmap) { |
| 174 | if (bitmap == nullptr) { |
| 175 | LOGE("PAGDecoder::readFrame() The specified bitmap buffer is invalid!"); |
| 176 | return false; |
| 177 | } |
| 178 | auto composition = getComposition(); |
| 179 | checkCompositionChange(composition); |
| 180 | if (index < 0 || index >= _numFrames) { |
| 181 | LOGE("PAGDecoder::readFrame() The index is out of range!"); |
| 182 | return false; |
| 183 | } |
| 184 | if (!checkSequenceFile(composition, bitmap->info())) { |
| 185 | return false; |
| 186 | } |
| 187 | auto success = sequenceFile->readFrame(index, bitmap); |
| 188 | if (!success) { |
| 189 | success = renderFrame(composition, index, bitmap); |
| 190 | if (success) { |
| 191 | success = sequenceFile->writeFrame(index, bitmap); |
| 192 | if (!success) { |
| 193 | LOGE("PAGDecoder::readFrame() Failed to write frame to SequenceFile!"); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | if (sequenceFile->isComplete() && composition != nullptr) { |
| 198 | if (reader != nullptr) { |
| 199 | reader = nullptr; |
| 200 | if (composition.use_count() != 1) { |
| 201 | container->addLayer(composition); |
| 202 | } |
| 203 | } else if (composition.use_count() <= 2) { |
| 204 | container->removeAllLayers(); |
| 205 | } |
| 206 | } |
| 207 | if (success) { |
| 208 | lastReadIndex = index; |
| 209 | } |
| 210 | return success; |
| 211 | } |
| 212 | |
| 213 | bool PAGDecoder::renderFrame(std::shared_ptr<PAGComposition> composition, int index, |
| 214 | std::shared_ptr<BitmapBuffer> bitmap) { |
nothing calls this directly
no test coverage detected