-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
render,core: Improve EditText's border and background rendering #16619
Conversation
2d04a8d
to
7861875
Compare
156ede0
to
ad0f23b
Compare
4d8fc81
to
07490dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the "draw lines or emulate lines" the responsibility of core, and not the backend itself?
Originally I thought about making that the responsibility of the backend, but wgpu required quite a refactor to implement that cleanly, and I was frustrated by DirectX at that time 😅 So anyway, I did the refactor now. The whole "drawing lines" thing came out bigger than expected, so if you wish I could split this PR into multiple ones (so that this one does not include the necessary refactors). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Moving draw_rect to draw_quad prevents code duplication when methods related to drawing lines are added.
This patch changes the mode of drawing quads to Gl::TRIANGLE_FAN. This makes the buffers smaller, as we need only 4 vertices instead of 6, and allows them to be reused for rendering lines.
Twips::HALF represents 10 twips, i.e. 0.5 pixels. This constant is useful when calculating exact positions of lines to be drawn, as they are often drawn on whole pixels.
This method is used to instantiate ColorTransform with its multiplicative component equal to the given color.
This patch splits the current method of create_box into 1. create_box -- without rotation, and 2. create_box_with_rotation -- with rotation. The reason for that refactor is that create_box was often used without rotation, and always passing 0.0 as rotation and having a dedicated condition for 0.0 was superfluous.
This refactor simplifies code, gets rid of the large number of parameters, and allows calling other rendering methods from themselves. The latter is useful for emulating lines on Dx12.
This patch adds draw_line and draw_line_rect methods to CommandHandler, providing empty impls to be overridden by corresponding backends. The ability to draw lines is described using a new bitflags struct RenderBackendFeatures, which contains a set of features supported by the given render backend. Currently, it contains a DRAW_LINES flag, which informs whether the backend supports drawing lines as primitives.
This patch provides an efficient implementation of draw_line and draw_line_rect for wgpu using PrimitiveTopology::LineStrip.
This patch provides an efficient implementation of draw_line and draw_line_rect for WebGL using Gl::LINE_STRIP.
This patch provides an efficient implementation of draw_line and draw_line_rect for canvas using strokes.
This patch removes the drawing used for rendering the border and the background and renders them using primitives instead. It provides two methods for drawing the border and the background: * draw_device_text_box -- when device fonts are used, * draw_text_box -- when fonts are embedded. Updated expected images in tests as they are closer to FP now: * text/auto_size/height, * text/auto_size/return, * text/auto_size/width, * visual/shumway_acid_tests/acid_color_0. For the test avm2/stage3d_texture it's hard to say whether the current output is closer to FP or not, as FP renders it with a different scale. However, I have confirmed that there exists a scale at which FP renders the text fields exactly as Ruffle after this patch.
This test checks whether text field borders are rendered properly.
This test checks whether text field borders are rendered properly at zoom 200%.
This test checks whether text fields with filters are rendered correctly.
This test verifies the basic rendering of text field's backgrounds.
This test verifies the basic rendering of text field's backgrounds at zoom 200%.
This test produces vastly different results compared to FP.
This PR removes the drawing used for rendering the border and
the background and renders them using primitives instead.
It provides two methods for drawing the border and the background:
draw_device_text_box
-- when device fonts are used,draw_text_box
-- when fonts are embedded.In order to draw the border properly new methods have been added:
draw_line
-- for drawing a single line (always 1px thick),draw_line_rect
-- for drawing a rectangle using lines (always 1px thick).These primitives have been implemented for wgpu, WebGL, and canvas.
Additional notes:
draw_line
added in this PR may also be used for rendering the selection caret in the future.Related to #15003, #1881 (the border is not being transformed anymore).