source: trunk/src/ddraw/OS2CLIPPER.CPP@ 4146

Last change on this file since 4146 was 4146, checked in by sandervl, 25 years ago

more logging + implemented GetClipList

File size: 6.3 KB
Line 
1/* $Id: OS2CLIPPER.CPP,v 1.10 2000-09-02 08:27:05 sandervl Exp $ */
2
3/*
4 * DX clipper class routines
5 *
6 * Copyright 1998 Sander van Leeuwen
7 * Copyright 1999 Markus Montkowski
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12
13#include <memory.h>
14
15#define INITGUID
16#include "os2ddraw.h"
17#include "os2clipper.h"
18#define _OS2WIN_H
19#define FAR
20#include <misc.h>
21#include <winerror.h>
22#include <winuser.h>
23
24//******************************************************************************
25//******************************************************************************
26OS2IDirectDrawClipper::OS2IDirectDrawClipper(OS2IDirectDraw *lpDirectDraw) :
27 Referenced(0), lastError(DD_OK),
28 clipWindow(0)
29{
30 lpVtbl = &Vtbl;
31 Vtbl.AddRef = ClipAddRef;
32 Vtbl.Release = ClipRelease;
33 Vtbl.QueryInterface = ClipQueryInterface;
34 Vtbl.GetClipList = ClipGetClipList;
35 Vtbl.GetHWnd = ClipGetHWnd;
36 Vtbl.Initialize = ClipInitialize;
37 Vtbl.IsClipListChanged = ClipIsClipListChanged;
38 Vtbl.SetClipList = ClipSetClipList;
39 Vtbl.SetHWnd = ClipSetHWnd;
40
41 lpDraw = lpDirectDraw;
42 lpDraw->Vtbl.AddRef(lpDraw);
43 hDive = lpDirectDraw->GetDiveInstance();
44 windowRect.left = windowRect.right = windowRect.top = windowRect.bottom = 0;
45}
46//******************************************************************************
47//******************************************************************************
48OS2IDirectDrawClipper::~OS2IDirectDrawClipper()
49{
50 lpDraw->Vtbl.Release(lpDraw);
51}
52//******************************************************************************
53//******************************************************************************
54HRESULT WIN32API ClipQueryInterface(THIS This, REFIID riid, LPVOID FAR * ppvObj)
55{
56 dprintf(("DDRAW: ClipQueryInterface\n"));
57
58 *ppvObj = NULL;
59
60 if(!IsEqualGUID(riid, IID_IDirectDrawClipper) &&
61 !IsEqualGUID(riid, CLSID_DirectDrawClipper))
62//&& !IsEqualGUID(riid, IID_IUnknown))
63 return E_NOINTERFACE;
64
65 *ppvObj = This;
66
67 ClipAddRef(This);
68 return(DD_OK);
69}
70//******************************************************************************
71//******************************************************************************
72ULONG WIN32API ClipAddRef(THIS This)
73{
74 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
75
76 dprintf(("DDRAW: OS2IDirectDrawClipper::AddRef %d\n", me->Referenced+1));
77
78 return ++me->Referenced;
79}
80//******************************************************************************
81//******************************************************************************
82ULONG WIN32API ClipRelease(THIS This)
83{
84 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
85
86 dprintf(("DDRAW: OS2IDirectDrawClipper::Release %d", me->Referenced-1));
87
88 if(me->Referenced)
89 {
90 me->Referenced--;
91 if(me->Referenced == 0)
92 {
93 delete( me);
94 return(0);
95 }
96 else
97 return me->Referenced;
98 }
99 else
100 return(0);
101}
102//******************************************************************************
103//******************************************************************************
104HRESULT WIN32API ClipGetClipList(THIS This, LPRECT lpRect, LPRGNDATA lpClipList,
105 LPDWORD lpdwSize)
106{
107 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
108 HRESULT rc = DD_OK;
109
110 dprintf(("DDRAW: ClipGetClipList %x %x %x %x", This, lpRect, lpClipList, lpdwSize));
111
112 if(!lpdwSize) {
113 return DDERR_INVALIDPARAMS;
114 }
115 if(me->clipWindow)
116 {
117 HRGN hRgn, hRgn1;
118 HDC hdc;
119 int bufneeded;
120
121 hRgn = CreateRectRgn(0, 0, 1, 1);
122 hdc = GetDC(me->clipWindow);
123 if(GetClipRgn(hdc, hRgn)) {
124 if(lpRect) {
125 hRgn1 = CreateRectRgnIndirect(lpRect);
126 CombineRgn(hRgn, hRgn, hRgn1, RGN_AND);
127 DeleteObject(hRgn1);
128 }
129 bufneeded = GetRegionData(hRgn, *lpdwSize, lpClipList);
130 if(bufneeded > *lpdwSize) {
131 rc = DDERR_REGIONTOOSMALL;
132 }
133 }
134 else rc = DDERR_NOCLIPLIST;
135 DeleteObject(hRgn);
136 ReleaseDC(me->clipWindow, hdc);
137 }
138 else { //todo!!
139 dprintf(("ClipGetClipList not complete if not associated with window!"));
140 rc = DDERR_NOCLIPLIST;
141 }
142 return rc;
143}
144//******************************************************************************
145//******************************************************************************
146HRESULT WIN32API ClipGetHWnd(THIS This, HWND FAR *pHwnd)
147{
148 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
149
150 dprintf(("DDRAW: ClipGetHWnd %x %x", This, me->clipWindow));
151
152 *pHwnd = me->clipWindow;
153 return(DD_OK);
154}
155//******************************************************************************
156//******************************************************************************
157HRESULT WIN32API ClipInitialize(THIS This, LPDIRECTDRAW lpDD, DWORD dwFlags)
158{
159 dprintf(("DDRAW: ClipInitialize %x %x %x", This, lpDD, dwFlags));
160
161 return(DDERR_ALREADYINITIALIZED); // Init is done during creation see M$ Doc
162}
163//******************************************************************************
164//******************************************************************************
165HRESULT WIN32API ClipIsClipListChanged(THIS This, BOOL *lpbChanged)
166{
167 dprintf(("DDRAW: ClipIsClipListChanged %x %x", This, lpbChanged));
168
169 return(DD_OK);
170}
171//******************************************************************************
172//******************************************************************************
173HRESULT WIN32API ClipSetClipList(THIS This, LPRGNDATA lpClipList, DWORD lpdwSize)
174{
175 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
176
177 dprintf(("DDRAW: ClipSetClipList %x %x %x", This, lpClipList, lpdwSize));
178
179 if(me->clipWindow) {
180 return DDERR_CLIPPERISUSINGHWND;
181 }
182 return(DD_OK);
183}
184//******************************************************************************
185//DWORD param not used in DirectX 3
186//******************************************************************************
187HRESULT WIN32API ClipSetHWnd(THIS This, DWORD reserved, HWND hwnd)
188{
189 OS2IDirectDrawClipper *me = (OS2IDirectDrawClipper *)This;
190
191 dprintf(("DDRAW: ClipSetHWnd %x %x %x", This, reserved, hwnd));
192
193 me->clipWindow = hwnd;
194 GetClientRect(hwnd, &me->windowRect);
195
196 return(DD_OK);
197}
198//******************************************************************************
199//******************************************************************************
Note: See TracBrowser for help on using the repository browser.