| 35 | } |
| 36 | |
| 37 | void AnimatedImageLayer::onDraw(DrawingContext& drawingContext) { |
| 38 | if (_image == nullptr) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | auto drawBounds = drawingContext.drawBounds(); |
| 43 | |
| 44 | auto imageWidth = static_cast<Scalar>(_image->getSize().width); |
| 45 | auto imageHeight = static_cast<Scalar>(_image->getSize().height); |
| 46 | auto imageRect = Rect::makeLTRB(0, 0, imageWidth, imageHeight); |
| 47 | |
| 48 | auto imageDrawBounds = drawBounds.makeFittingSize(imageRect.size(), _fittingSizeMode); |
| 49 | |
| 50 | // Clip to view bounds. Applied before matrix transform |
| 51 | auto drawRect = imageDrawBounds.intersection(drawBounds); |
| 52 | drawingContext.clipRect(drawRect); |
| 53 | |
| 54 | if (_shouldFlip) { |
| 55 | drawingContext.concat(Matrix::makeScaleTranslate(-1, 1, imageDrawBounds.width(), 0)); |
| 56 | } |
| 57 | |
| 58 | _image->draw(drawingContext.canvas(), imageDrawBounds, _currentTime, _fittingSizeMode); |
| 59 | } |
| 60 | |
| 61 | void AnimatedImageLayer::onLoadedAssetChanged(const Ref<Valdi::LoadedAsset>& loadedAsset, bool shouldDrawFlipped) { |
| 62 | setImage(Valdi::castOrNull<AnimatedImage>(loadedAsset)); |
nothing calls this directly
no test coverage detected