OnPaint rendering with incorrect dimensions

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

OnPaint rendering with incorrect dimensions

Postby monodop » Sun Apr 19, 2020 2:58 am

Hey guys, I'm getting some weird behavior with OnPaint and WasResized in 79.1.36+g90301bd+chromium-79.0.3945.130

It seems to me that when I call WasResized with a larger screen size, OnPaint gets called with the correct width and height. However, if I make the size smaller, it paints with the previous size.

The relevant parts of CefRenderHandler implementation looks like this:
Code: Select all
        protected override void GetViewRect(CefBrowser browser, out CefRectangle rect)
        {
            rect = new CefRectangle()
            {
                X = 0,
                Y = 0,
                Width = this.width,
                Height = this.height,
            };
            Console.WriteLine($"GetViewRect {rect.Width}, {rect.Height}");
        }

        protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height)
        {
            // this.width and this.height are the expected dimensions that we set before calling WasResized()
            Console.WriteLine($"Paint expected {this.width}, {this.height}, got {width}, {height}.");
        }


The code to resize:
Code: Select all
        public void Resize(int width, int height)
        {
            Console.WriteLine($"Attempt to resize to {width}, {height}");
            RenderHandler.width = width;
            RenderHandler.height = height;
            Host.WasResized();
        }


This produces the following log output:
Code: Select all
GetViewRect 998, 626
Paint expected 998, 626, got 998, 626.
GetViewRect 998, 626
Paint expected 998, 626, got 998, 626.
GetViewRect 998, 626
Paint expected 998, 626, got 998, 626.
GetViewRect 998, 626
GetViewRect 998, 626
Paint expected 998, 626, got 998, 626.
Attempt to resize to 997, 626
GetViewRect 997, 626
GetViewRect 997, 626
GetViewRect 997, 626
GetViewRect 997, 626
GetViewRect 997, 626
GetViewRect 997, 626
GetViewRect 997, 626
GetViewRect 997, 626
Paint expected 997, 626, got 998, 626.
Attempt to resize to 993, 626
GetViewRect 993, 626
GetViewRect 993, 626
GetViewRect 993, 626
GetViewRect 993, 626
GetViewRect 993, 626
GetViewRect 993, 626
GetViewRect 993, 626
GetViewRect 993, 626
Paint expected 993, 626, got 998, 626.
Attempt to resize to 990, 626
GetViewRect 990, 626
GetViewRect 990, 626
GetViewRect 990, 626
GetViewRect 990, 626
GetViewRect 990, 626
GetViewRect 990, 626
GetViewRect 990, 626
GetViewRect 990, 626
Paint expected 990, 626, got 998, 626.
Attempt to resize to 978, 626
GetViewRect 978, 626
GetViewRect 978, 626
GetViewRect 978, 626
GetViewRect 978, 626
GetViewRect 978, 626
GetViewRect 978, 626
GetViewRect 978, 626
GetViewRect 978, 626
Paint expected 978, 626, got 998, 626.
Attempt to resize to 972, 626
GetViewRect 972, 626
GetViewRect 972, 626
GetViewRect 972, 626
GetViewRect 972, 626
GetViewRect 972, 626
GetViewRect 972, 626
GetViewRect 972, 626
GetViewRect 972, 626
Paint expected 972, 626, got 998, 626.
Attempt to resize to 1031, 626
GetViewRect 1031, 626
GetViewRect 1031, 626
GetViewRect 1031, 626
GetViewRect 1031, 626
GetViewRect 1031, 626
GetViewRect 1031, 626
GetViewRect 1031, 626
GetViewRect 1031, 626
GetViewRect 1031, 626
Paint expected 1031, 626, got 1031, 626.


As you can see, the GetViewRect dimensions appear to be the correct dimensions, but OnPaint is not using those same dimensions in the resulting width/height and the resulting buffer also has the same incorrect dimensions. Am I doing something wrong?
monodop
Newbie
 
Posts: 1
Joined: Sun Apr 19, 2020 2:42 am

Re: OnPaint rendering with incorrect dimensions

Postby magreenblatt » Sun Apr 19, 2020 2:50 pm

Try a newer build that includes the fix for issue #2733.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 24 guests