()
| 139 | } |
| 140 | |
| 141 | private async doRasterize(): Promise<Asset> { |
| 142 | const [componentWidth, componentHeight] = this.getComponentSize(); |
| 143 | const context = createManagedContext({ |
| 144 | embeddedPlatformViewRasterMethod: this.state.rasterMethod, |
| 145 | deltaRasterization: true, |
| 146 | }); |
| 147 | context.render(() => { |
| 148 | <InnerComponent />; |
| 149 | }); |
| 150 | |
| 151 | await context.onAllAssetsLoaded(); |
| 152 | |
| 153 | await context.layout(componentWidth, componentHeight, false); |
| 154 | |
| 155 | const { frame } = await context.draw(); |
| 156 | |
| 157 | const scale = Device.getDisplayScale() / DOWNSCALE_RATIO[this.state.downscaleRatioIndex]; |
| 158 | const rasterWidth = Math.floor(scale * componentWidth); |
| 159 | const rasterHeight = Math.floor(scale * componentHeight); |
| 160 | |
| 161 | const bytesPerPixel = 4; |
| 162 | |
| 163 | const bitmap = createBitmap({ |
| 164 | width: rasterWidth, |
| 165 | height: rasterHeight, |
| 166 | colorType: BitmapColorType.RGBA8888, |
| 167 | alphaType: BitmapAlphaType.OPAQUE, |
| 168 | rowBytes: rasterWidth * bytesPerPixel, |
| 169 | }); |
| 170 | |
| 171 | frame.rasterInto(bitmap, true); |
| 172 | |
| 173 | const buffer = bitmap.encode(ImageEncoding.PNG, 1.0); |
| 174 | |
| 175 | frame.dispose(); |
| 176 | bitmap.dispose(); |
| 177 | context.dispose(); |
| 178 | |
| 179 | return makeAssetFromBytes(buffer); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | const styles = {}; |
no test coverage detected