Closed lainz closed 7 months ago
Instructions: open the demo, and resize the window, the bottom virtual screen is resized and repainted correctly, but the static bgravirtualscreen at the top left are not repainted.
I noticed the bug is here:
procedure TCustomBGRAVirtualScreen.BGRASetSize(AWidth, AHeight: integer);
begin
if (FBGRA <> nil) {and ((AWidth <> FBGRA.Width) or (AHeight <> FBGRA.Height))} then
begin
FBGRA.SetSize(AWidth, AHeight);
RedrawBitmapContent;
FDiscardedRect := EmptyRect;
end;
end;
and ((AWidth <> FBGRA.Width) or (AHeight <> FBGRA.Height))
Commenting that code works. Still waiting for your input.
Hi, seems that BGRAVirtualScreen don't discard bitmap if the width of the control doesn't change... even if I want it to discard.
Check \bgracontrols\test\test_bgravirtualscreen_blur
Hi. I don't see this example in the repository.
Hi, seems that BGRAVirtualScreen don't discard bitmap if the width of the control doesn't change... even if I want it to discard. Check \bgracontrols\test\test_bgravirtualscreen_blur
Hi. I don't see this example in the repository.
In dev-bgracontrols branch.
Hi Leandro,
It is on purpose that BGRASetSize
function doesn't change the content if the size is the same. Consider a button, unless it is resized, most of the time, we don't want to redraw it.
So please don't change BGRASetSize
function this way. Are there any other approach, like calling DiscardBitmap
function in the OnResize
event of the form?
Regards
Hi, but you've tested the demo? It has DiscardBitmap on resize.
procedure TForm1.FormResize(Sender: TObject);
var
i: integer;
vs: TBGRAVirtualScreen;
begin
for i:=0 to Self.ControlCount-1 do
begin
if (Self.Controls[i] is TBGRAVirtualScreen) then
begin
vs := (Self.Controls[i] as TBGRAVirtualScreen);
vs.DiscardBitmap;
end;
end;
end;
Ah ok, there was a misunderstanding. I thought you expected it to discard automatically on resize.
I haven't tested the project yet. From the code you've cited, it seems there is a call to DiscardBitmap that normally would redraw the content.
I will dig deeper into it.
The discard code on resize was wrong. I've fixed it, still buggy... now the bug is when resizing it don't update the bitmap, only when the resize is done..
Hi Leandro,
Indeed, I came to the same conclusion, that it was cycling the main controls of the form, whereas the panels you're considering are inside the first virtual screen.
After that, I don't notice the problem of delayed update you're mentionning.
Regards
Maybe because I'm using Windows. Or because I'm using Lazarus 2.2.6
This is a video showing the problem, notice that the top left virtual screen are not updated until I release the mouse: https://github.com/bgrabitmap/bgracontrols/assets/4131395/146aac96-1d5d-41c2-9c86-309574dd206b
Indeed, I can see the fixed panels are not update.
I tried it on Windows 11 and Lazarus 3.0. It is laggy but updates all panels.
Maybe we can add a boolean that triggers the update without checking width and height like I showed in previous comments.
Something like "optimized Discard" if set to true is like
If fbgra <> nil and optimized Discard and width and height...
By default is true. And if set to false it will discard anyways no matter the width and height.
That makes it run smoothly.
Oh I see, I will try on latest lazarus first.
Thanks, it works fine on latest Lazarus.
Glad it is all well for you
Hi, seems that BGRAVirtualScreen don't discard bitmap if the width of the control doesn't change... even if I want it to discard.
Check \bgracontrols\test\test_bgravirtualscreen_blur
@circular17 can you fix it?