MCPcopy Create free account
hub / github.com/Snapchat/Valdi / doDraw

Method doDraw

snap_drawing/src/snap_drawing/cpp/Utils/SVGAnimatedImage.cpp:44–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void SVGAnimatedImage::doDraw(SkCanvas* canvas,
45 const Rect& drawBounds,
46 const Duration& time,
47 FittingSizeMode fittingSizeMode) {
48 std::lock_guard<Valdi::Mutex> lock(_mutex);
49 _currentTime = time;
50
51 auto svgBounds = drawBounds.makeFittingSize(_size, fittingSizeMode);
52 auto saveCount = canvas->save();
53 canvas->clipRect(drawBounds.getSkValue());
54 canvas->translate(svgBounds.left, svgBounds.top);
55
56 if (_size.width > 0 && _size.height > 0) {
57 canvas->scale(svgBounds.width() / _size.width, svgBounds.height() / _size.height);
58 _dom->setContainerSize(SkSize::Make(_size.width, _size.height));
59 } else {
60 _dom->setContainerSize(SkSize::Make(svgBounds.width(), svgBounds.height()));
61 }
62
63 _dom->render(canvas);
64 canvas->restoreToCount(saveCount);
65}
66
67Valdi::Result<Ref<SVGAnimatedImage>> SVGAnimatedImage::make(const Valdi::Byte* data, size_t length) {
68 const Valdi::BytesView bytesView(nullptr, data, length);

Callers

nothing calls this directly

Calls 10

MakeFunction · 0.85
makeFittingSizeMethod · 0.80
getSkValueMethod · 0.80
scaleMethod · 0.80
saveMethod · 0.65
renderMethod · 0.65
clipRectMethod · 0.45
translateMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected