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

Method onDraw

snap_drawing/src/snap_drawing/cpp/Layers/ExternalLayer.cpp:65–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64 return Image::makeFromBitmap(bitmap.value(), false);
65}
66
67void ExternalLayer::onDraw(DrawingContext& drawingContext) {
68 if (_externalSurface != nullptr) {
69 auto frameSize = getFrame().size();
70 _externalSurface->setRelativeSize(frameSize);
71
72 if (shouldRasterizeExternalSurface()) {
73 // Rasterize at min(frameSize, outputSize): a layer pinched/zoomed larger than the
74 // final output has no need for a raster buffer bigger than what will ever be shown.
75 // drawImage below stretches the (possibly smaller) result back to frameSize, which is
76 // information-equivalent for image content -- unlike vector content, there's no
77 // absolute-unit geometry (border width, radius, text) that a uniform scale would distort.
78 auto* root = getRoot();
79 auto outputSize = root != nullptr ? root->getOutputSize() : OutputSize{};
80 auto rasterWidth = (outputSize.width > 0) ? std::min(frameSize.width, outputSize.width) : frameSize.width;
81 auto rasterHeight =
82 (outputSize.height > 0) ? std::min(frameSize.height, outputSize.height) : frameSize.height;
83
84 // A degenerate (empty or sub-pixel) layer truncates to a zero-sized raster target,
85 // which createBitmap rejects. Nothing to draw here, so skip it rather than take the
86 // error path on every frame.
87 if (static_cast<int>(rasterWidth) <= 0 || static_cast<int>(rasterHeight) <= 0) {
88 return;
89 }

Callers

nothing calls this directly

Calls 7

setRelativeSizeMethod · 0.80
drawImageMethod · 0.80
drawExternalSurfaceMethod · 0.80
errorMethod · 0.65
sizeMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected