mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:38:10 +00:00
LibPDF: Move ColorSpace::style() to take ReadonlySpan<float>
All ColorSpace subclasses converted to float anyways, and this allows us to save lots of float->Value->float conversions during image color space processing. A bit faster: ``` N Min Max Median Avg Stddev x 50 0.99054313 1.0412271 0.99933481 1.0052408 0.012931916 + 50 0.97073889 1.0075941 0.97849107 0.98184034 0.0090329046 Difference at 95.0% confidence -0.0234004 +/- 0.00442595 -2.32785% +/- 0.440287% (Student's t, pooled s = 0.0111541) ```
This commit is contained in:
parent
5ff2a824cc
commit
5f85aff036
3 changed files with 58 additions and 56 deletions
|
@ -1129,7 +1129,7 @@ PDFErrorOr<Renderer::LoadedImage> Renderer::load_image(NonnullRefPtr<StreamObjec
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
auto const bytes_per_component = bits_per_component / 8;
|
||||
Vector<Value> component_values;
|
||||
Vector<float> component_values;
|
||||
component_values.resize(n_components);
|
||||
while (!content.is_empty() && y < height) {
|
||||
auto sample = content.slice(0, bytes_per_component * n_components);
|
||||
|
@ -1137,7 +1137,7 @@ PDFErrorOr<Renderer::LoadedImage> Renderer::load_image(NonnullRefPtr<StreamObjec
|
|||
for (int i = 0; i < n_components; ++i) {
|
||||
auto component = sample.slice(0, bytes_per_component);
|
||||
sample = sample.slice(bytes_per_component);
|
||||
component_values[i] = Value { component_value_decoders[i].interpolate(component[0]) };
|
||||
component_values[i] = component_value_decoders[i].interpolate(component[0]);
|
||||
}
|
||||
auto color = TRY(color_space->style(component_values)).get<Color>();
|
||||
bitmap->set_pixel(x, y, color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue