Recent

Author Topic: BGRAVirtualScreen redraws twice  (Read 3353 times)

mark.chambers

  • New member
  • *
  • Posts: 9
BGRAVirtualScreen redraws twice
« on: May 06, 2016, 03:58:31 pm »
Hi,

If I modify my back-buffer and call TBGRAVirtualScreen.RedrawBitmap() then TForm1.VirtualScreenRedraw(...) gets called twice - once for my call then once as the result of a paint message. Since I am scaling the image from the back-buffer to the front buffer and this takes a while, doing it twice is bad.

If there is no modification to the back buffer image, it only gets called once because paint is, quite rightly, not called.

I assume that I need to tell something that the back-buffer is unchanged after the first call - but how and where?

I have tried to distill the problem as much as possible. If any more detail is needed let me know.

Any help would be much appreciated.

Regards,
Mark.

The stack traces follow:

#0 VIRTUALSCREENREDRAW(0x5d801c0, 0x5d877a0, 0x15754c0) at FMains.pas:932
#1 REDRAWBITMAPCONTENT(0x5d877a0) at source\bgravirtualscreen.pas:234
#2 REDRAWBITMAP(0x5d877a0) at :0
#3 DOEXECUTELINE(0x5d801c0, 0x5dcb1f8 'Redraw', 0x151ffc0) at FMains.pas:1141
#4 DORUNSCRIPT(0x1502ec0, 0x5dc5478 'Redraw()'#13#10) at psScriptButtons.pas:529
#5 DOBUTTONCLICK(0x1502ec0, 0x5d9a7c0) at psScriptButtons.pas:469
#6 CONTROLS$_$TCONTROL_$__$$_CLICK at :0
#7 STDCTRLS$_$TBUTTONCONTROL_$__$$_CLICK at :0
#8 STDCTRLS$_$TCUSTOMBUTTON_$__$$_CLICK at :0
#9 STDCTRLS$_$TBUTTONCONTROL_$__$$_WMDEFAULTCLICKED$TMESSAGE at :0
#10 SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal at :0
#11 CONTROLS$_$TCONTROL_$__$$_WNDPROC$TMESSAGE at :0
#12 CONTROLS$_$TWINCONTROL_$__$$_WNDPROC$TMESSAGE at :0
#13 LCLMESSAGEGLUE_$$_DELIVERMESSAGE$TOBJECT$formal$$INT64 at :0
#14 WIN32INT$_$TWINDOWPROCHELPER_$__$$_DOWINDOWPROC$$INT64 at :0
#15 WIN32INT_$$_WINDOWPROC$QWORD$LONGWORD$INT64$INT64$$INT64 at :0
#16 USER32!DispatchMessageW at :0
#17 USER32!SendMessageW at :0
#18 USER32!SendMessageW at :0
#19 ImageList_GetImageCount at :0
#20 Str_SetPtrW at :0
#21 USER32!DispatchMessageW at :0
#22 USER32!CallWindowProcW at :0
#23 WIN32INT_$$_CALLDEFAULTWINDOWPROC$QWORD$LONGWORD$INT64$INT64$$INT64 at :0


#0 VIRTUALSCREENREDRAW(0x5d801c0, 0x5d877a0, 0x15754c0) at FMains.pas:932
#1 REDRAWBITMAPCONTENT(0x5d877a0) at source\bgravirtualscreen.pas:234
#2 BGRASETSIZE(0x5d877a0, 5039, 3337) at source\bgravirtualscreen.pas:186
#3 PAINT(0x5d877a0) at source\bgravirtualscreen.pas:170
#4 CONTROLS$_$TCUSTOMCONTROL_$__$$_PAINTWINDOW$QWORD at :0
#5 CONTROLS$_$TWINCONTROL_$__$$_PAINTHANDLER$TLMPAINT at :0
#6 CONTROLS$_$TWINCONTROL_$__$$_WMPAINT$TLMPAINT at :0
#7 CONTROLS$_$TCUSTOMCONTROL_$__$$_WMPAINT$TLMPAINT at :0
#8 SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal at :0
#9 CONTROLS$_$TCONTROL_$__$$_WNDPROC$TMESSAGE at :0
#10 CONTROLS$_$TWINCONTROL_$__$$_WNDPROC$TMESSAGE at :0
#11 LCLMESSAGEGLUE_$$_DELIVERMESSAGE$TOBJECT$formal$$INT64 at :0
#12 WIN32INT$_$TWINDOWPROCHELPER_$__$$_SENDPAINTMESSAGE$QWORD at :0
#13 WIN32INT$_$TWINDOWPROCHELPER_$__$$_DOWINDOWPROC$$INT64 at :0
#14 WIN32INT_$$_WINDOWPROC$QWORD$LONGWORD$INT64$INT64$$INT64 at :0
#15 USER32!DispatchMessageW at :0
#16 USER32!DispatchMessageW at :0
#17 USER32!GetMenuItemInfoW at :0
#18 ntdll!KiUserCallbackDispatcher at :0
#19 USER32!HideCaret at :0
#20 WIN32INT$_$TWIN32WIDGETSET_$__$$_UPDATEWINDOW$QWORD$$BOOLEAN at :0
#21 LCLINTF_$$_UPDATEWINDOW$QWORD$$BOOLEAN at :0
#22 CONTROLS$_$TWINCONTROL_$__$$_UPDATE at :0
#23 CONTROLS$_$TWINCONTROL_$__$$_REPAINT at :0
#24 REDRAWBITMAP(0x5d877a0) at source\bgravirtualscreen.pas:272
#25 DOEXECUTELINE(0x5d801c0, 0x5dc6f38 'Redraw', 0x151ffc0) at FMains.pas:1141
#26 DORUNSCRIPT(0x1502ec0, 0x5dc6078 'ZoomIn()'#13#10'Redraw()'#13#10) at psScriptButtons.pas:529
#27 DOBUTTONCLICK(0x1502ec0, 0x5d91760) at psScriptButtons.pas:469
#28 CONTROLS$_$TCONTROL_$__$$_CLICK at :0
#29 STDCTRLS$_$TBUTTONCONTROL_$__$$_CLICK at :0
#30 STDCTRLS$_$TCUSTOMBUTTON_$__$$_CLICK at :0
#31 STDCTRLS$_$TBUTTONCONTROL_$__$$_WMDEFAULTCLICKED$TMESSAGE at :0
#32 SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal at :0
#33 CONTROLS$_$TCONTROL_$__$$_WNDPROC$TMESSAGE at :0
#34 CONTROLS$_$TWINCONTROL_$__$$_WNDPROC$TMESSAGE at :0
#35 LCLMESSAGEGLUE_$$_DELIVERMESSAGE$TOBJECT$formal$$INT64 at :0
#36 WIN32INT$_$TWINDOWPROCHELPER_$__$$_DOWINDOWPROC$$INT64 at :0
#37 WIN32INT_$$_WINDOWPROC$QWORD$LONGWORD$INT64$INT64$$INT64 at :0
#38 USER32!DispatchMessageW at :0
#39 USER32!SendMessageW at :0
#40 USER32!SendMessageW at :0
#41 ImageList_GetImageCount at :0
#42 Str_SetPtrW at :0
#43 USER32!DispatchMessageW at :0
#44 USER32!CallWindowProcW at :0
#45 WIN32INT_$$_CALLDEFAULTWINDOWPROC$QWORD$LONGWORD$INT64$INT64$$INT64 at :0

 

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: BGRAVirtualScreen redraws twice
« Reply #1 on: May 06, 2016, 04:38:16 pm »
You can provide a minimal example with code, so it gets easier to understand how your code actually works and how to solve the problem.

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: BGRAVirtualScreen redraws twice
« Reply #2 on: May 06, 2016, 11:28:53 pm »
Hello mark,

The Redraw event is not called as a result of a paint message unless the image has been discarded. So somewhere in your code, there is maybe a call to DiscardBitmap.

As Lainz said, it would be helpful to see your code to understand what's happening.

Otherwise, you can call DiscardBitmap instead of RedrawBitmap, so that the content of the virtual screen will be redrawn only when the paint message is processed.

Regards
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018