2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Try to own the blitter for private usage
9 #include <proto/exec.h>
10 #include <graphics/gfxbase.h>
11 #include <exec/execbase.h>
12 #include <exec/tasks.h>
14 /*****************************************************************************
17 #include <proto/graphics.h>
19 AROS_LH0(void, OwnBlitter
,
25 struct GfxBase
*, GfxBase
, 76, Graphics
)
28 The blitter is allocated for exclusive use by the calling task.
29 This function returns immediately if no other task is using
30 the blitter right now or if no blits are in the queues (QBlit(),
31 QBSBlit()). Otherwise the function will block until the blitter
33 It is good practice to start the blitter immediately after calling
34 this function and then call DisownBlitter() so other tasks can
54 ******************************************************************************/
58 /* prevent other tasks from doing what I am doing */
65 /* test whether a task is using the blitter. Even if the blitter is
66 used by the queued blits now the BlitOwner entry must not be NULL!
69 if (NULL
== GfxBase
->BlitOwner
)
71 /* nobody is using the blitter right now, so I can use it */
72 GfxBase
->BlitOwner
=me
;
77 /* the blitter is used. I have to set this task asleep and queue
78 it into the BlitWaitQ.
81 /* Repeat this as long as there is somebody else using the blitter.
82 This is necessary as when the other task calls DisownBlitter() it
83 might take a while until this task gets to run again and
84 yet another taks might issue QBlit() in the meantime and the blitter
85 might be busy with that. So this task will have to wait again.
86 However at the first call this task is put to the end of the waiting
87 list and after that it is always put at the very front.
89 while (NULL
!= GfxBase
->BlitOwner
)
91 /* force this task to sleep */
93 BYTE old_TDNestCnt
= SysBase
->TDNestCnt
;
94 SysBase
->TDNestCnt
=-1;
97 Move it to the waiting list in the GfxBase structure.
98 It will be moved to the ready list by the blitterinterrupt
103 AddTail(&GfxBase
->BlitWaitQ
, &me
->tc_Node
);
104 /* The next time I will put this task at the beginning
105 of the list, if necessary.
111 AddHead(&GfxBase
->BlitWaitQ
, &me
->tc_Node
);
114 /* Switch to the next ready task. */
117 OK. Somebody awakened me. This means that I the task might now
118 have full control over the blitter. Checking is in the while-loop.
121 /* Restore TDNestCnt. */
122 SysBase
->TDNestCnt
=old_TDNestCnt
;
124 /* I am the owner now !! */
126 GfxBase
-> BlitOwner
= me
;