Jump to content

PMPaintThread: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
==Description==
Paint thread class: Allows to dump lenghty paint operations on a secondary thread.
Paint thread class: Allows to dump lengthy paint operations on a secondary thread.


===What to do to use the class:===
===What to do to use the class:===
# Create the class (you'll want to derive another class and redefine the paint function).
# Create the class (you'll want to derive another class and redefine the paint function).
# when creating the window that uses the class (in the create() func.) open a DC of the window, get a PS, create the paint thread, and if you want, you may produce a segment on the PS. (openSegment with drawing mode set to DM_RETAIN).
# when creating the window that uses the class (in the create() func.) open a DC of the window, get a PS, create the paint thread, and if you want, you may produce a segment on the PS. (openSegment with drawing mode set to DM_RETAIN).
# When WM_PAINT is sent to the window, do default processing (ie erasing the window, then stop drawing in the paint thread, wait for ready flag (readySem posted), and post the triggerSem to trigger drawing.
# When WM_PAINT is sent to the window, do default processing (i.e. erasing the window, then stop drawing in the paint thread, wait for ready flag (readySem posted), and post the triggerSem to trigger drawing.
# When exiting the window, kill the thread, (optionally calling stop and waiting for ready flag).
# When exiting the window, kill the thread, (optionally calling stop and waiting for ready flag).


'''Note:''' it is not necessary to wait for the ready flag.
'''Note:''' it is not necessary to wait for the ready flag.


[[Category:The OS/2 API Project]]
[[Category:PM++]]

Latest revision as of 21:57, 7 October 2022

Description

Paint thread class: Allows to dump lengthy paint operations on a secondary thread.

What to do to use the class:

  1. Create the class (you'll want to derive another class and redefine the paint function).
  2. when creating the window that uses the class (in the create() func.) open a DC of the window, get a PS, create the paint thread, and if you want, you may produce a segment on the PS. (openSegment with drawing mode set to DM_RETAIN).
  3. When WM_PAINT is sent to the window, do default processing (i.e. erasing the window, then stop drawing in the paint thread, wait for ready flag (readySem posted), and post the triggerSem to trigger drawing.
  4. When exiting the window, kill the thread, (optionally calling stop and waiting for ready flag).

Note: it is not necessary to wait for the ready flag.