| 63 | |
| 64 | return Image::makeFromBitmap(bitmap.value(), false); |
| 65 | } |
| 66 | |
| 67 | void 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 | } |
nothing calls this directly
no test coverage detected