ReactOS  0.4.14-dev-342-gdc047f9
clipper.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "wincodecs_private.h"
#include "wine/debug.h"
Include dependency graph for clipper.c:

Go to the source code of this file.

Classes

struct  BitmapClipper
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct BitmapClipper BitmapClipper
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wincodecs)
 
static BitmapClipperimpl_from_IWICBitmapClipper (IWICBitmapClipper *iface)
 
static HRESULT WINAPI BitmapClipper_QueryInterface (IWICBitmapClipper *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI BitmapClipper_AddRef (IWICBitmapClipper *iface)
 
static ULONG WINAPI BitmapClipper_Release (IWICBitmapClipper *iface)
 
static HRESULT WINAPI BitmapClipper_GetSize (IWICBitmapClipper *iface, UINT *width, UINT *height)
 
static HRESULT WINAPI BitmapClipper_GetPixelFormat (IWICBitmapClipper *iface, WICPixelFormatGUID *format)
 
static HRESULT WINAPI BitmapClipper_GetResolution (IWICBitmapClipper *iface, double *dpiX, double *dpiY)
 
static HRESULT WINAPI BitmapClipper_CopyPalette (IWICBitmapClipper *iface, IWICPalette *palette)
 
static HRESULT WINAPI BitmapClipper_CopyPixels (IWICBitmapClipper *iface, const WICRect *rc, UINT stride, UINT buffer_size, BYTE *buffer)
 
static HRESULT WINAPI BitmapClipper_Initialize (IWICBitmapClipper *iface, IWICBitmapSource *source, const WICRect *rc)
 
HRESULT BitmapClipper_Create (IWICBitmapClipper **clipper)
 

Variables

static const IWICBitmapClipperVtbl BitmapClipper_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file clipper.c.

Typedef Documentation

◆ BitmapClipper

Function Documentation

◆ BitmapClipper_AddRef()

static ULONG WINAPI BitmapClipper_AddRef ( IWICBitmapClipper iface)
static

Definition at line 70 of file clipper.c.

71 {
74 
75  TRACE("(%p) refcount=%u\n", iface, ref);
76 
77  return ref;
78 }
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ BitmapClipper_CopyPalette()

static HRESULT WINAPI BitmapClipper_CopyPalette ( IWICBitmapClipper iface,
IWICPalette palette 
)
static

Definition at line 148 of file clipper.c.

150 {
152 
153  TRACE("(%p,%p)\n", iface, palette);
154 
155  if (!palette)
156  return E_INVALIDARG;
157 
158  if (!This->source)
160 
161  return IWICBitmapSource_CopyPalette(This->source, palette);
162 }
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
static HPALETTE palette
Definition: clipboard.c:1345
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273

◆ BitmapClipper_CopyPixels()

static HRESULT WINAPI BitmapClipper_CopyPixels ( IWICBitmapClipper iface,
const WICRect rc,
UINT  stride,
UINT  buffer_size,
BYTE buffer 
)
static

Definition at line 164 of file clipper.c.

166 {
168  WICRect rect;
169 
170  TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(rc), stride, buffer_size, buffer);
171 
172  if (!This->source)
174 
175  if (rc)
176  {
177  rect = *rc;
178 
179  /* transform to source coordinates */
180  rect.X += This->rect.X;
181  rect.Y += This->rect.Y;
182 
183  if ((rect.X + rect.Width > This->rect.X + This->rect.Width) ||
184  (rect.Y + rect.Height > This->rect.Y + This->rect.Height))
185  return E_INVALIDARG;
186 
187  rc = &rect;
188  }
189  else
190  rc = &This->rect;
191 
192  return IWICBitmapSource_CopyPixels(This->source, rc, stride, buffer_size, buffer);
193 }
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
GLuint buffer
Definition: glext.h:5915
& rect
Definition: startmenu.cpp:1413
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:927
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
GLsizei stride
Definition: glext.h:5848
static const char * debug_wic_rect(const WICRect *rect)
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273

◆ BitmapClipper_Create()

HRESULT BitmapClipper_Create ( IWICBitmapClipper **  clipper)

Definition at line 243 of file clipper.c.

244 {
246 
247  This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapClipper));
248  if (!This) return E_OUTOFMEMORY;
249 
250  This->IWICBitmapClipper_iface.lpVtbl = &BitmapClipper_Vtbl;
251  This->ref = 1;
252  This->source = NULL;
254  This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BitmapClipper.lock");
255 
256  *clipper = &This->IWICBitmapClipper_iface;
257 
258  return S_OK;
259 }
#define DWORD_PTR
Definition: treelist.c:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const IWICBitmapClipperVtbl BitmapClipper_Vtbl
Definition: clipper.c:231
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define S_OK
Definition: intsafe.h:59

Referenced by ImagingFactory_CreateBitmapClipper().

◆ BitmapClipper_GetPixelFormat()

static HRESULT WINAPI BitmapClipper_GetPixelFormat ( IWICBitmapClipper iface,
WICPixelFormatGUID format 
)
static

Definition at line 117 of file clipper.c.

119 {
121  TRACE("(%p,%p)\n", iface, format);
122 
123  if (!format)
124  return E_INVALIDARG;
125 
126  if (!This->source)
128 
129  return IWICBitmapSource_GetPixelFormat(This->source, format);
130 }
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273

◆ BitmapClipper_GetResolution()

static HRESULT WINAPI BitmapClipper_GetResolution ( IWICBitmapClipper iface,
double dpiX,
double dpiY 
)
static

Definition at line 132 of file clipper.c.

134 {
136 
137  TRACE("(%p,%p,%p)\n", iface, dpiX, dpiY);
138 
139  if (!dpiX || !dpiY)
140  return E_INVALIDARG;
141 
142  if (!This->source)
144 
145  return IWICBitmapSource_GetResolution(This->source, dpiX, dpiY);
146 }
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273

◆ BitmapClipper_GetSize()

static HRESULT WINAPI BitmapClipper_GetSize ( IWICBitmapClipper iface,
UINT width,
UINT height 
)
static

Definition at line 98 of file clipper.c.

100 {
102 
103  TRACE("(%p,%p,%p)\n", iface, width, height);
104 
105  if (!width || !height)
106  return E_INVALIDARG;
107 
108  if (!This->source)
110 
111  *width = This->rect.Width;
112  *height = This->rect.Height;
113 
114  return S_OK;
115 }
GLint GLint GLsizei width
Definition: gl.h:1546
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define S_OK
Definition: intsafe.h:59

◆ BitmapClipper_Initialize()

static HRESULT WINAPI BitmapClipper_Initialize ( IWICBitmapClipper iface,
IWICBitmapSource source,
const WICRect rc 
)
static

Definition at line 195 of file clipper.c.

197 {
199  UINT width, height;
200  HRESULT hr = S_OK;
201 
202  TRACE("(%p,%p,%s)\n", iface, source, debug_wic_rect(rc));
203 
204  EnterCriticalSection(&This->lock);
205 
206  if (This->source)
207  {
209  goto end;
210  }
211 
212  hr = IWICBitmapSource_GetSize(source, &width, &height);
213  if (FAILED(hr)) goto end;
214 
215  if ((rc->X + rc->Width > width) || (rc->Y + rc->Height > height))
216  {
217  hr = E_INVALIDARG;
218  goto end;
219  }
220 
221  This->rect = *rc;
222  This->source = source;
223  IWICBitmapSource_AddRef(This->source);
224 
225 end:
226  LeaveCriticalSection(&This->lock);
227 
228  return hr;
229 }
GLint GLint GLsizei width
Definition: gl.h:1546
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint end
Definition: gl.h:1545
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define E_INVALIDARG
Definition: ddrawi.h:101
INT Height
Definition: wincodec.idl:239
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static const char * debug_wic_rect(const WICRect *rect)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3273
#define S_OK
Definition: intsafe.h:59
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
unsigned int UINT
Definition: ndis.h:50
INT Width
Definition: wincodec.idl:238
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ BitmapClipper_QueryInterface()

static HRESULT WINAPI BitmapClipper_QueryInterface ( IWICBitmapClipper iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 46 of file clipper.c.

48 {
50  TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
51 
52  if (!ppv) return E_INVALIDARG;
53 
54  if (IsEqualIID(&IID_IUnknown, iid) ||
55  IsEqualIID(&IID_IWICBitmapSource, iid) ||
56  IsEqualIID(&IID_IWICBitmapClipper, iid))
57  {
58  *ppv = &This->IWICBitmapClipper_iface;
59  }
60  else
61  {
62  *ppv = NULL;
63  return E_NOINTERFACE;
64  }
65 
66  IUnknown_AddRef((IUnknown*)*ppv);
67  return S_OK;
68 }
#define E_NOINTERFACE
Definition: winerror.h:2364
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ BitmapClipper_Release()

static ULONG WINAPI BitmapClipper_Release ( IWICBitmapClipper iface)
static

Definition at line 80 of file clipper.c.

81 {
84 
85  TRACE("(%p) refcount=%u\n", iface, ref);
86 
87  if (ref == 0)
88  {
89  This->lock.DebugInfo->Spare[0] = 0;
91  if (This->source) IWICBitmapSource_Release(This->source);
93  }
94 
95  return ref;
96 }
static BitmapClipper * impl_from_IWICBitmapClipper(IWICBitmapClipper *iface)
Definition: clipper.c:41
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ impl_from_IWICBitmapClipper()

static BitmapClipper* impl_from_IWICBitmapClipper ( IWICBitmapClipper iface)
inlinestatic

Definition at line 41 of file clipper.c.

42 {
43  return CONTAINING_RECORD(iface, BitmapClipper, IWICBitmapClipper_iface);
44 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by BitmapClipper_AddRef(), BitmapClipper_CopyPalette(), BitmapClipper_CopyPixels(), BitmapClipper_GetPixelFormat(), BitmapClipper_GetResolution(), BitmapClipper_GetSize(), BitmapClipper_Initialize(), BitmapClipper_QueryInterface(), and BitmapClipper_Release().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wincodecs  )

Variable Documentation

◆ BitmapClipper_Vtbl

const IWICBitmapClipperVtbl BitmapClipper_Vtbl
static
Initial value:
= {
}
static ULONG WINAPI BitmapClipper_AddRef(IWICBitmapClipper *iface)
Definition: clipper.c:70
static HRESULT WINAPI BitmapClipper_GetPixelFormat(IWICBitmapClipper *iface, WICPixelFormatGUID *format)
Definition: clipper.c:117
static HRESULT WINAPI BitmapClipper_Initialize(IWICBitmapClipper *iface, IWICBitmapSource *source, const WICRect *rc)
Definition: clipper.c:195
static HRESULT WINAPI BitmapClipper_GetResolution(IWICBitmapClipper *iface, double *dpiX, double *dpiY)
Definition: clipper.c:132
static HRESULT WINAPI BitmapClipper_GetSize(IWICBitmapClipper *iface, UINT *width, UINT *height)
Definition: clipper.c:98
static ULONG WINAPI BitmapClipper_Release(IWICBitmapClipper *iface)
Definition: clipper.c:80
static HRESULT WINAPI BitmapClipper_CopyPixels(IWICBitmapClipper *iface, const WICRect *rc, UINT stride, UINT buffer_size, BYTE *buffer)
Definition: clipper.c:164
static HRESULT WINAPI BitmapClipper_CopyPalette(IWICBitmapClipper *iface, IWICPalette *palette)
Definition: clipper.c:148
static HRESULT WINAPI BitmapClipper_QueryInterface(IWICBitmapClipper *iface, REFIID iid, void **ppv)
Definition: clipper.c:46

Definition at line 231 of file clipper.c.

Referenced by BitmapClipper_Create().