main.c
来自「Wine-20031016」· C语言 代码 · 共 1,349 行 · 第 1/3 页
C
1,349 行
HRESULT WINAPIMain_DirectDrawSurface_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE7 iface, LPVOID context, LPDDENUMSURFACESCALLBACK7 cb){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); IDirectDrawSurfaceImpl* surf; TRACE("(%p)->(%p,%p)\n",This,context,cb); for (surf = This->attached; surf != NULL; surf = surf->next_attached) { /* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */ if (cb(ICOM_INTERFACE(surf, IDirectDrawSurface7), &surf->surface_desc, context) == DDENUMRET_CANCEL) break; } return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_EnumOverlayZOrders(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags, LPVOID context, LPDDENUMSURFACESCALLBACK7 cb){ TRACE("(%p)->(%08lx,%p,%p)\n",iface,dwFlags,context,cb); return DD_OK;}BOOL Main_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front, IDirectDrawSurfaceImpl* back, DWORD dwFlags){ /* uniqueness_value? */ /* This is necessary. But is it safe? */ { HDC tmp = front->hDC; front->hDC = back->hDC; back->hDC = tmp; } { BOOL tmp = front->dc_in_use; front->dc_in_use = back->dc_in_use; back->dc_in_use = tmp; } { FLATPTR tmp = front->global.fpVidMem; front->global.fpVidMem = back->global.fpVidMem; back->global.fpVidMem = tmp; } { ULONG_PTR tmp = front->global_more.hKernelSurface; front->global_more.hKernelSurface = back->global_more.hKernelSurface; back->global_more.hKernelSurface = tmp; } return TRUE;}HRESULT WINAPIMain_DirectDrawSurface_Flip(LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAWSURFACE7 override, DWORD dwFlags){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); IDirectDrawSurfaceImpl* target; HRESULT hr; TRACE("(%p)->(%p,%08lx)\n",This,override,dwFlags); /* MSDN: "This method can be called only for a surface that has the * DDSCAPS_FLIP and DDSCAPS_FRONTBUFFER capabilities." */ if ((This->surface_desc.ddsCaps.dwCaps&(DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER)) != (DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER)) return DDERR_NOTFLIPPABLE; if (This->aux_flip) if (This->aux_flip(This->aux_ctx, This->aux_data)) return DD_OK; /* 1. find the flip target */ /* XXX I don't think this algorithm works for more than 1 backbuffer. */ if (override == NULL) { static DDSCAPS2 back_caps = { DDSCAPS_BACKBUFFER }; LPDIRECTDRAWSURFACE7 tgt; hr = IDirectDrawSurface7_GetAttachedSurface(iface, &back_caps, &tgt); if (FAILED(hr)) return DDERR_NOTFLIPPABLE; /* unchecked */ target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, tgt); IDirectDrawSurface7_Release(tgt); } else { BOOL on_chain = FALSE; IDirectDrawSurfaceImpl* surf; /* MSDN: "The method fails if the specified [override] surface is not * a member of the flipping chain." */ /* Verify that override is on this flip chain. We assume that * surf is the head of the flipping chain, because it's the front * buffer. */ target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, override); /* Either target is (indirectly) attached to This or This is * (indirectly) attached to target. */ for (surf = target; surf != NULL; surf = surf->surface_owner) { if (surf == This) { on_chain = TRUE; break; } } if (!on_chain) return DDERR_INVALIDPARAMS; /* unchecked */ } TRACE("flip to backbuffer: %p\n",target); if (This->flip_data(This, target, dwFlags)) This->flip_update(This, dwFlags); return DD_OK;}static PrivateData* find_private_data(IDirectDrawSurfaceImpl *This, REFGUID tag){ PrivateData* data; for (data = This->private_data; data != NULL; data = data->next) { if (IsEqualGUID(&data->tag, tag)) break; } return data;}HRESULT WINAPIMain_DirectDrawSurface_FreePrivateData(LPDIRECTDRAWSURFACE7 iface, REFGUID tag){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); PrivateData *data; data = find_private_data(This, tag); if (data == NULL) return DDERR_NOTFOUND; if (data->prev) data->prev->next = data->next; if (data->next) data->next->prev = data->prev; if (data->flags & DDSPD_IUNKNOWNPTR) { if (data->ptr.object != NULL) IUnknown_Release(data->ptr.object); } else HeapFree(GetProcessHeap(), 0, data->ptr.data); HeapFree(GetProcessHeap(), 0, data); return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_GetAttachedSurface(LPDIRECTDRAWSURFACE7 iface, LPDDSCAPS2 pCaps, LPDIRECTDRAWSURFACE7* ppSurface){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); IDirectDrawSurfaceImpl* surf; IDirectDrawSurfaceImpl* found = NULL; DDSCAPS2 our_caps; if (TRACE_ON(ddraw)) { TRACE("(%p)->Looking for caps: %lx,%lx,%lx,%lx output: %p\n",This,pCaps->dwCaps, pCaps->dwCaps2, pCaps->dwCaps3, pCaps->dwCaps4, ppSurface); TRACE(" Caps are : "); DDRAW_dump_DDSCAPS2(pCaps); TRACE("\n"); } our_caps = *pCaps; if ((This->ddraw_owner->local.dwLocalFlags & DDRAWILCL_DIRECTDRAW7) == 0) { /* As this is not a DirectDraw7 application, remove the garbage that some games put in the new fields of the DDSCAPS2 structure. */ our_caps.dwCaps2 = 0; our_caps.dwCaps3 = 0; our_caps.dwCaps4 = 0; if (TRACE_ON(ddraw)) { TRACE(" Real caps are : "); DDRAW_dump_DDSCAPS2(&our_caps); TRACE("\n"); } } for (surf = This->attached; surf != NULL; surf = surf->next_attached) { if (TRACE_ON(ddraw)) { TRACE("Surface: (%p) caps: %lx,%lx,%lx,%lx \n",surf , surf->surface_desc.ddsCaps.dwCaps, surf->surface_desc.ddsCaps.dwCaps2, surf->surface_desc.ddsCaps.dwCaps3, surf->surface_desc.ddsCaps.dwCaps4); TRACE(" Surface caps are : "); DDRAW_dump_DDSCAPS2(&(surf->surface_desc.ddsCaps)); TRACE("\n"); } if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) && ((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) { /* MSDN: "This method fails if more than one surface is attached * that matches the capabilities requested." */ if (found != NULL) { FIXME("More than one attached surface matches requested caps. What should we do here?\n"); /* Previous code returned 'DDERR_NOTFOUND'. That appears not to be correct, given what 3DMark expects from MipMapped surfaces. We shall just continue instead. */ } found = surf; } } if (found == NULL) { TRACE("Did not find any valid surface\n"); return DDERR_NOTFOUND; } *ppSurface = ICOM_INTERFACE(found, IDirectDrawSurface7); if (TRACE_ON(ddraw)) { TRACE("Returning surface %p with description : \n", *ppSurface); DDRAW_dump_surface_desc(&(found->surface_desc)); } /* XXX d3dframe.cpp sometimes AddRefs things that it gets from us. */ IDirectDrawSurface7_AddRef(ICOM_INTERFACE(found, IDirectDrawSurface7)); return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_GetBltStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags){ TRACE("(%p)->(%08lx)\n",iface,dwFlags); switch (dwFlags) { case DDGBS_CANBLT: case DDGBS_ISBLTDONE: return DD_OK; default: return DDERR_INVALIDPARAMS; }}HRESULT WINAPIMain_DirectDrawSurface_GetCaps(LPDIRECTDRAWSURFACE7 iface, LPDDSCAPS2 pCaps){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); TRACE("(%p)->(%p)\n",This,pCaps); *pCaps = This->surface_desc.ddsCaps; return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_GetClipper(LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAWCLIPPER* ppClipper){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); TRACE("(%p)->(%p)\n",This,ppClipper); if (This->clipper == NULL) return DDERR_NOCLIPPERATTACHED; *ppClipper = ICOM_INTERFACE(This->clipper, IDirectDrawClipper); IDirectDrawClipper_AddRef(ICOM_INTERFACE(This->clipper, IDirectDrawClipper)); return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_GetColorKey(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags, LPDDCOLORKEY pCKey){ /* There is a DDERR_NOCOLORKEY error, but how do we know if a color key * isn't there? That's like saying that an int isn't there. (Which MS * has done in other docs.) */ ICOM_THIS(IDirectDrawSurfaceImpl, iface); TRACE("(%p)->(%08lx,%p)\n",This,dwFlags,pCKey); if (TRACE_ON(ddraw)) { TRACE(" - colorkey flags : "); DDRAW_dump_colorkeyflag(dwFlags); } switch (dwFlags) { case DDCKEY_DESTBLT: *pCKey = This->surface_desc.ddckCKDestBlt; break; case DDCKEY_DESTOVERLAY: *pCKey = This->surface_desc.u3.ddckCKDestOverlay; break; case DDCKEY_SRCBLT: *pCKey = This->surface_desc.ddckCKSrcBlt; break; case DDCKEY_SRCOVERLAY: *pCKey = This->surface_desc.ddckCKSrcOverlay; break; default: return DDERR_INVALIDPARAMS; } return DD_OK;}/* XXX We need to do something with the DC if the surface gets lost. */HRESULT WINAPIMain_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC){ DDSURFACEDESC2 ddsd; HRESULT hr; ICOM_THIS(IDirectDrawSurfaceImpl, iface); TRACE("(%p)->(%p)\n",This,phDC); CHECK_LOST(This); LOCK_OBJECT(This); if (This->dc_in_use) { UNLOCK_OBJECT(This); return DDERR_DCALREADYCREATED; } /* Lock as per MSDN. * Strange: Lock lists DDERR_SURFACEBUSY as an error, meaning that another * thread has it locked, but GetDC does not. */ ddsd.dwSize = sizeof(ddsd); hr = IDirectDrawSurface7_Lock(iface, NULL, &ddsd, 0, 0); if (FAILED(hr)) { UNLOCK_OBJECT(This); return hr; } hr = This->get_dc(This, &This->hDC); if (SUCCEEDED(hr)) { TRACE("returning %p\n",This->hDC); *phDC = This->hDC; This->dc_in_use = TRUE; } else WARN("No DC! Prepare for trouble\n"); UNLOCK_OBJECT(This); return hr;}HRESULT WINAPIMain_DirectDrawSurface_GetDDInterface(LPDIRECTDRAWSURFACE7 iface, LPVOID* pDD){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); TRACE("(%p)->(%p)\n",This,pDD); *pDD = ICOM_INTERFACE(This->ddraw_owner, IDirectDraw7); IDirectDraw7_AddRef(ICOM_INTERFACE(This->ddraw_owner, IDirectDraw7)); return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_GetFlipStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags){ /* XXX: DDERR_INVALIDSURFACETYPE */ TRACE("(%p)->(%08lx)\n",iface,dwFlags); switch (dwFlags) { case DDGFS_CANFLIP: case DDGFS_ISFLIPDONE: return DD_OK; default: return DDERR_INVALIDPARAMS; }}HRESULT WINAPIMain_DirectDrawSurface_GetLOD(LPDIRECTDRAWSURFACE7 iface, LPDWORD pdwMaxLOD){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); TRACE("(%p)->(%p)\n",This,pdwMaxLOD); CHECK_TEXTURE(This); *pdwMaxLOD = This->max_lod; return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_GetOverlayPosition(LPDIRECTDRAWSURFACE7 iface, LPLONG pX, LPLONG pY){ return DDERR_NOTAOVERLAYSURFACE;}HRESULT WINAPIMain_DirectDrawSurface_GetPalette(LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAWPALETTE* ppPalette){ ICOM_THIS(IDirectDrawSurfaceImpl, iface); TRACE("(%p)->(%p)\n",This,ppPalette); if (This->palette == NULL) return DDERR_NOPALETTEATTACHED; *ppPalette = ICOM_INTERFACE(This->palette, IDirectDrawPalette); IDirectDrawPalette_AddRef(ICOM_INTERFACE(This->palette, IDirectDrawPalette)); return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_GetPixelFormat(LPDIRECTDRAWSURFACE7 iface, LPDDPIXELFORMAT pDDPixelFormat){ /* What is DDERR_INVALIDSURFACETYPE for here? */ ICOM_THIS(IDirectDrawSurfaceImpl, iface); TRACE("(%p)->(%p)\n",This,pDDPixelFormat); DD_STRUCT_COPY_BYSIZE(pDDPixelFormat,&This->surface_desc.u4.ddpfPixelFormat); return DD_OK;}HRESULT WINAPIMain_DirectDrawSurface_GetPriority(LPDIRECTDRAWSURFACE7 iface, LPDWORD pdwPriority){
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?