1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibPDF: Communicate resources to ColorSpace, not Page

Resources can come from other sources (e.g., XObjects), and since the
only attribute we are reading from Page are its resources it makes sense
to receive resources instead. That way we'll be able to pass down
arbitrary resources that are not necessarily declared at the page level.
This commit is contained in:
Rodrigo Tobar 2022-11-21 13:13:58 +08:00 committed by Andreas Kling
parent 164422f8d8
commit fe5c823989
4 changed files with 12 additions and 12 deletions

View file

@ -496,14 +496,14 @@ RENDERER_TODO(type3_font_set_glyph_width_and_bbox)
RENDERER_HANDLER(set_stroking_space)
{
state().stroke_color_space = TRY(get_color_space(args[0]));
state().stroke_color_space = TRY(get_color_space(args[0], m_page.resources));
VERIFY(state().stroke_color_space);
return {};
}
RENDERER_HANDLER(set_painting_space)
{
state().paint_color_space = TRY(get_color_space(args[0]));
state().paint_color_space = TRY(get_color_space(args[0], m_page.resources));
VERIFY(state().paint_color_space);
return {};
}
@ -701,10 +701,10 @@ void Renderer::show_text(String const& string)
m_text_matrix.translate(delta_x / text_rendering_matrix.x_scale(), 0.0f);
}
PDFErrorOr<NonnullRefPtr<ColorSpace>> Renderer::get_color_space(Value const& value)
PDFErrorOr<NonnullRefPtr<ColorSpace>> Renderer::get_color_space(Value const& value, NonnullRefPtr<DictObject> resources)
{
auto name = value.get<NonnullRefPtr<Object>>()->cast<NameObject>()->name();
return TRY(ColorSpace::create(m_document, name, m_page));
return TRY(ColorSpace::create(m_document, name, resources));
}
Gfx::AffineTransform const& Renderer::calculate_text_rendering_matrix()