2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 #include <aros/asmcall.h>
9 #include <intuition/intuition.h>
10 #include <intuition/intuitionbase.h>
11 #include <intuition/screens.h>
12 #include <graphics/clip.h>
13 #include <graphics/layers.h>
14 #include <graphics/rastport.h>
15 #include <utility/hooks.h>
16 #include <proto/arossupport.h>
17 #include <proto/exec.h>
18 #include <proto/dos.h>
19 #include <proto/graphics.h>
20 #include <proto/layers.h>
21 #include <proto/alib.h>
26 #define ARG_TEMPLATE "FAST=F/S,NUMBERS=N/S,EXTRA/S,HOOK/S"
34 static struct Screen
*scr
;
35 static struct Window
*win
;
36 static struct Layer
*lay
;
37 static struct RDArgs
*MyArgs
;
38 static IPTR Args
[NUM_ARGS
];
40 static jmp_buf exit_buf
;
42 static void Cleanup(char *msg
)
48 Printf("crlist: %s\n",msg
);
54 if (MyArgs
) FreeArgs(MyArgs
);
57 longjmp(exit_buf
, rc
);
60 static void GetArguments(void)
62 if (!(MyArgs
= ReadArgs(ARG_TEMPLATE
,Args
,0)))
64 Fault(IoErr(),0,s
,255);
69 static void Show(struct RastPort
*rp
, struct ClipRect
*cr
)
71 WORD x
, y
, i
, count
= 0;
75 Printf("#%04ld (%4ld,%4ld) - (%4ld, %4ld) Size: %4ld x %4ld %s%s\n",
81 cr
->bounds
.MaxX
- cr
->bounds
.MinX
+ 1,
82 cr
->bounds
.MaxY
- cr
->bounds
.MinY
+ 1,
83 (cr
->lobs
? "HIDDEN " : ""),
84 (cr
->BitMap
? "BITMAP ": ""));
86 if (cr
->BitMap
&& Args
[ARG_EXTRA
])
88 ULONG w
= GetBitMapAttr(cr
->BitMap
, BMA_WIDTH
);
89 ULONG h
= GetBitMapAttr(cr
->BitMap
, BMA_HEIGHT
);
91 Printf(" -> BitMap 0x%p, size %ld x %ld\n", cr
->BitMap
, w
, h
);
94 for(i
= 0; i
< (Args
[ARG_FAST
] ? 1 : 8);i
++)
96 SetAPen(rp
,1 + (i
& 1));
97 RectFill(rp
,cr
->bounds
.MinX
,cr
->bounds
.MinY
,cr
->bounds
.MaxX
,cr
->bounds
.MinY
);
98 RectFill(rp
,cr
->bounds
.MaxX
,cr
->bounds
.MinY
,cr
->bounds
.MaxX
,cr
->bounds
.MaxY
);
99 RectFill(rp
,cr
->bounds
.MinX
,cr
->bounds
.MaxY
,cr
->bounds
.MaxX
,cr
->bounds
.MaxY
);
100 RectFill(rp
,cr
->bounds
.MinX
,cr
->bounds
.MinY
,cr
->bounds
.MinX
,cr
->bounds
.MaxY
);
102 if (!Args
[ARG_FAST
]) Delay(10);
105 if (Args
[ARG_NUMBERS
])
107 __sprintf(s
,"%d",count
);
108 i
= TextLength(rp
,s
,strlen(s
));
110 x
= (cr
->bounds
.MinX
+ cr
->bounds
.MaxX
- i
) / 2;
111 y
= (cr
->bounds
.MinY
+ cr
->bounds
.MaxY
- rp
->TxHeight
) / 2;
116 } else if (x
>= scr
->Width
- i
)
118 x
= scr
->Width
- i
- 1;
124 } else if (y
>= scr
->Height
- rp
->TxHeight
)
126 y
= scr
->Height
- rp
->TxHeight
- 1;
132 Move(rp
,x
+ 1, y
+ 1 + rp
->TxBaseline
);
136 Move(rp
,x
, y
+ rp
->TxBaseline
);
143 AROS_UFH3(static void, ClipRectHook
,
144 AROS_UFHA(struct Hook
*, h
, A0
),
145 AROS_UFHA(struct RastPort
*, rp
, A2
),
146 AROS_UFHA(struct BackFillMessage
*, msg
, A1
))
150 Printf("# RastPort 0x%p, BitMap 0x%p, Layer 0x%p\n", rp
, rp
->BitMap
, msg
->Layer
);
151 Printf(" -> (%4ld,%4ld) - (%4ld, %4ld), Offset (%4ld, %4ld)\n", msg
->Bounds
.MinX
, msg
->Bounds
.MinY
, msg
->Bounds
.MaxX
, msg
->Bounds
.MaxY
, msg
->OffsetX
, msg
->OffsetY
);
156 static struct Hook crHook
=
158 .h_Entry
= (HOOKFUNC
)ClipRectHook
161 static void Action(void)
163 extern struct IntuitionBase
*IntuitionBase
;
166 PutStr("Activate the window whose cliprects you want to see.\n");
167 PutStr("You have 3 seconds of time!\n\n");
171 win
= IntuitionBase
->ActiveWindow
;
173 if (!win
) Cleanup("No active window!");
177 if (!(rp
= CloneRastPort(&scr
->RastPort
)))
179 Cleanup("Can´t clone screen rastport!");
185 Show(rp
, lay
->ClipRect
);
188 PutStr("This window has ClipRegion installed. Listing hidden cliprects...\n");
189 Show(rp
, lay
->_cliprects
);
194 struct Rectangle rect
= {20, 20, win
->Width
- 40 + 1, win
->Height
- 40 + 1};
196 Printf("Running ClipRectHook on Window's RastPort 0x%p, BitMap 0x%p, Layer 0x%p...\n", win
->RPort
, win
->RPort
->BitMap
, lay
);
197 DoHookClipRects(&crHook
, win
->RPort
, &rect
);
207 if ((rc
= setjmp(exit_buf
)) != 0)