wined3d: Generalize GetSurfaceLevel() / GetVolumeLevel() to GetSubResource().
[wine] / dlls / wined3d / surface_base.c
index b9dd634..f8b6a63 100644 (file)
@@ -10,7 +10,7 @@
  * Copyright 2006-2008 Stefan Dösinger for CodeWeavers
  * Copyright 2007 Henri Verbeet
  * Copyright 2006-2007 Roderick Colenbrander
- * Copyright 2009 Henri Verbeet for CodeWeavers
+ * Copyright 2009-2010 Henri Verbeet for CodeWeavers
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -111,32 +111,36 @@ ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) {
     return ref;
 }
 
-/* ****************************************************
-   IWineD3DSurface IWineD3DResource parts follow
-   **************************************************** */
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface,
+        REFGUID riid, const void *data, DWORD data_size, DWORD flags)
+{
+    return resource_set_private_data(&((IWineD3DSurfaceImpl *)iface)->resource, riid, data, data_size, flags);
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
-    return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface,
+        REFGUID guid, void *data, DWORD *data_size)
+{
+    return resource_get_private_data(&((IWineD3DSurfaceImpl *)iface)->resource, guid, data, data_size);
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) {
-    return resource_free_private_data((IWineD3DResource *)iface, refguid);
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid)
+{
+    return resource_free_private_data(&((IWineD3DSurfaceImpl *)iface)->resource, refguid);
 }
 
-DWORD   WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) {
-    return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
+DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD priority)
+{
+    return resource_set_priority(&((IWineD3DSurfaceImpl *)iface)->resource, priority);
 }
 
-DWORD   WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) {
-    return resource_get_priority((IWineD3DResource *)iface);
+DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface)
+{
+    return resource_get_priority(&((IWineD3DSurfaceImpl *)iface)->resource);
 }
 
-WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) {
-    TRACE("(%p) : calling resourceimpl_GetType\n", iface);
-    return resource_get_type((IWineD3DResource *)iface);
+WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface)
+{
+    return resource_get_type(&((IWineD3DSurfaceImpl *)iface)->resource);
 }
 
 void * WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface)
@@ -146,28 +150,27 @@ void * WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface)
     return ((IWineD3DSurfaceImpl *)iface)->resource.parent;
 }
 
-void WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *desc)
+struct wined3d_resource * WINAPI IWineD3DBaseSurfaceImpl_GetResource(IWineD3DSurface *iface)
+{
+    TRACE("iface %p.\n", iface);
+
+    return &((IWineD3DSurfaceImpl *)iface)->resource;
+}
+
+void WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, struct wined3d_resource_desc *desc)
 {
     IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)iface;
 
     TRACE("iface %p, desc %p.\n", iface, desc);
 
-    desc->format = surface->resource.format->id;
-    desc->resource_type = surface->resource.resourceType;
-    desc->usage = surface->resource.usage;
-    desc->pool = surface->resource.pool;
-    desc->size = surface->resource.size; /* dx8 only */
-    desc->multisample_type = surface->currentDesc.MultiSampleType;
-    desc->multisample_quality = surface->currentDesc.MultiSampleQuality;
-    desc->width = surface->currentDesc.Width;
-    desc->height = surface->currentDesc.Height;
+    wined3d_resource_get_desc(&surface->resource, desc);
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags)
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD flags)
 {
-    TRACE("iface %p, flags %#x.\n", iface, Flags);
+    TRACE("iface %p, flags %#x.\n", iface, flags);
 
-    switch (Flags)
+    switch (flags)
     {
         case WINEDDGBS_CANBLT:
         case WINEDDGBS_ISBLTDONE:
@@ -178,11 +181,14 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWOR
     }
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags) {
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD flags)
+{
     /* XXX: DDERR_INVALIDSURFACETYPE */
 
-    TRACE("(%p)->(%08x)\n",iface,Flags);
-    switch (Flags) {
+    TRACE("iface %p, flags %#x.\n", iface, flags);
+
+    switch (flags)
+    {
         case WINEDDGFS_CANFLIP:
         case WINEDDGFS_ISFLIPDONE:
             return WINED3D_OK;
@@ -197,7 +203,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface) {
     TRACE("(%p)\n", This);
 
     /* D3D8 and 9 loose full devices, ddraw only surfaces */
-    return This->Flags & SFLAG_LOST ? WINED3DERR_DEVICELOST : WINED3D_OK;
+    return This->flags & SFLAG_LOST ? WINED3DERR_DEVICELOST : WINED3D_OK;
 }
 
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface) {
@@ -205,50 +211,56 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface) {
     TRACE("(%p)\n", This);
 
     /* So far we don't lose anything :) */
-    This->Flags &= ~SFLAG_LOST;
+    This->flags &= ~SFLAG_LOST;
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal) {
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, struct wined3d_palette *palette)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
-    IWineD3DPaletteImpl *PalImpl = (IWineD3DPaletteImpl *) Pal;
-    TRACE("(%p)->(%p)\n", This, Pal);
 
-    if(This->palette == PalImpl) {
+    TRACE("iface %p, palette %p.\n", iface, palette);
+
+    if (This->palette == palette)
+    {
         TRACE("Nop palette change\n");
         return WINED3D_OK;
     }
 
     if (This->palette)
         if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
-            This->palette->Flags &= ~WINEDDPCAPS_PRIMARYSURFACE;
+            This->palette->flags &= ~WINEDDPCAPS_PRIMARYSURFACE;
 
-    This->palette = PalImpl;
+    This->palette = palette;
 
-    if (PalImpl)
+    if (palette)
     {
         if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
-            PalImpl->Flags |= WINEDDPCAPS_PRIMARYSURFACE;
+            palette->flags |= WINEDDPCAPS_PRIMARYSURFACE;
 
-        return IWineD3DSurface_RealizePalette(iface);
+        This->surface_ops->surface_realize_palette(This);
     }
-    else return WINED3D_OK;
+
+    return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, const WINEDDCOLORKEY *CKey)
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD flags, const WINEDDCOLORKEY *CKey)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
-    TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
 
-    if (Flags & WINEDDCKEY_COLORSPACE)
+    TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, CKey);
+
+    if (flags & WINEDDCKEY_COLORSPACE)
     {
-        FIXME(" colorkey value not supported (%08x) !\n", Flags);
+        FIXME(" colorkey value not supported (%08x) !\n", flags);
         return WINED3DERR_INVALIDCALL;
     }
 
     /* Dirtify the surface, but only if a key was changed */
-    if(CKey) {
-        switch (Flags & ~WINEDDCKEY_COLORSPACE) {
+    if (CKey)
+    {
+        switch (flags & ~WINEDDCKEY_COLORSPACE)
+        {
             case WINEDDCKEY_DESTBLT:
                 This->DestBltCKey = *CKey;
                 This->CKeyFlags |= WINEDDSD_CKDESTBLT;
@@ -270,8 +282,10 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD
                 break;
         }
     }
-    else {
-        switch (Flags & ~WINEDDCKEY_COLORSPACE) {
+    else
+    {
+        switch (flags & ~WINEDDCKEY_COLORSPACE)
+        {
             case WINEDDCKEY_DESTBLT:
                 This->CKeyFlags &= ~WINEDDSD_CKDESTBLT;
                 break;
@@ -293,11 +307,14 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal) {
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, struct wined3d_palette **palette)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
-    TRACE("(%p)->(%p)\n", This, Pal);
 
-    *Pal = (IWineD3DPalette *) This->palette;
+    TRACE("iface %p, palette %p.\n", iface, palette);
+
+    *palette = This->palette;
+
     return WINED3D_OK;
 }
 
@@ -308,17 +325,17 @@ DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface)
     DWORD ret;
     TRACE("(%p)\n", This);
 
-    if ((format->Flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED)
+    if ((format->flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED)
     {
         /* Since compressed formats are block based, pitch means the amount of
          * bytes to the next row of block rather than the next row of pixels. */
-        UINT row_block_count = (This->currentDesc.Width + format->block_width - 1) / format->block_width;
+        UINT row_block_count = (This->resource.width + format->block_width - 1) / format->block_width;
         ret = row_block_count * format->block_byte_count;
     }
     else
     {
         unsigned char alignment = This->resource.device->surface_alignment;
-        ret = This->resource.format->byte_count * This->currentDesc.Width;  /* Bytes / row */
+        ret = This->resource.format->byte_count * This->resource.width;  /* Bytes / row */
         ret = (ret + alignment - 1) & ~(alignment - 1);
     }
     TRACE("(%p) Returning %d\n", This, ret);
@@ -344,7 +361,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface
     This->overlay_destrect.right = X + w;
     This->overlay_destrect.bottom = Y + h;
 
-    IWineD3DSurface_DrawOverlay(iface);
+    This->surface_ops->surface_draw_overlay(This);
 
     return WINED3D_OK;
 }
@@ -375,10 +392,11 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface
     return hr;
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref) {
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD flags, IWineD3DSurface *Ref)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
 
-    FIXME("iface %p, flags %#x, ref %p stub!\n", iface, Flags, Ref);
+    FIXME("iface %p, flags %#x, ref %p stub!\n", iface, flags, Ref);
 
     if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
     {
@@ -390,11 +408,13 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *ifac
 }
 
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
-        IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX)
+        IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD flags, const WINEDDOVERLAYFX *FX)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     IWineD3DSurfaceImpl *Dst = (IWineD3DSurfaceImpl *) DstSurface;
-    TRACE("(%p)->(%p, %p, %p, %08x, %p)\n", This, SrcRect, Dst, DstRect, Flags, FX);
+
+    TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
+            iface, wine_dbgstr_rect(SrcRect), DstSurface, wine_dbgstr_rect(DstRect), flags, FX);
 
     if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
     {
@@ -410,8 +430,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, con
     } else {
         This->overlay_srcrect.left = 0;
         This->overlay_srcrect.top = 0;
-        This->overlay_srcrect.right = This->currentDesc.Width;
-        This->overlay_srcrect.bottom = This->currentDesc.Height;
+        This->overlay_srcrect.right = This->resource.width;
+        This->overlay_srcrect.bottom = This->resource.height;
     }
 
     if(DstRect) {
@@ -419,20 +439,25 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, con
     } else {
         This->overlay_destrect.left = 0;
         This->overlay_destrect.top = 0;
-        This->overlay_destrect.right = Dst ? Dst->currentDesc.Width : 0;
-        This->overlay_destrect.bottom = Dst ? Dst->currentDesc.Height : 0;
+        This->overlay_destrect.right = Dst ? Dst->resource.width : 0;
+        This->overlay_destrect.bottom = Dst ? Dst->resource.height : 0;
     }
 
-    if(This->overlay_dest && (This->overlay_dest != Dst || Flags & WINEDDOVER_HIDE)) {
+    if (This->overlay_dest && (This->overlay_dest != Dst || flags & WINEDDOVER_HIDE))
+    {
         list_remove(&This->overlay_entry);
     }
 
-    if(Flags & WINEDDOVER_SHOW) {
-        if(This->overlay_dest != Dst) {
+    if (flags & WINEDDOVER_SHOW)
+    {
+        if (This->overlay_dest != Dst)
+        {
             This->overlay_dest = Dst;
             list_add_tail(&Dst->overlays, &This->overlay_entry);
         }
-    } else if(Flags & WINEDDOVER_HIDE) {
+    }
+    else if (flags & WINEDDOVER_HIDE)
+    {
         /* tests show that the rectangles are erased on hide */
         This->overlay_srcrect.left   = 0; This->overlay_srcrect.top     = 0;
         This->overlay_srcrect.right  = 0; This->overlay_srcrect.bottom  = 0;
@@ -441,29 +466,32 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, con
         This->overlay_dest = NULL;
     }
 
-    IWineD3DSurface_DrawOverlay(iface);
+    This->surface_ops->surface_draw_overlay(This);
 
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper)
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, struct wined3d_clipper *clipper)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
-    TRACE("(%p)->(%p)\n", This, clipper);
+
+    TRACE("iface %p, clipper %p.\n", iface, clipper);
 
     This->clipper = clipper;
+
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper)
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, struct wined3d_clipper **clipper)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
-    TRACE("(%p)->(%p)\n", This, clipper);
+
+    TRACE("iface %p, clipper %p.\n", iface, clipper);
 
     *clipper = This->clipper;
-    if(*clipper) {
-        IWineD3DClipper_AddRef(*clipper);
-    }
+    if (*clipper)
+        wined3d_clipper_incref(*clipper);
+
     return WINED3D_OK;
 }
 
@@ -483,7 +511,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, enum wi
     This->resource.size = wined3d_format_calculate_size(format, This->resource.device->surface_alignment,
             This->pow2Width, This->pow2Height);
 
-    This->Flags |= (WINED3DFMT_D16_LOCKABLE == format_id) ? SFLAG_LOCKABLE : 0;
+    This->flags |= (WINED3DFMT_D16_LOCKABLE == format_id) ? SFLAG_LOCKABLE : 0;
 
     This->resource.format = format;
 
@@ -503,7 +531,7 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface)
     DWORD *masks;
     UINT usage;
 
-    if (!(format->Flags & WINED3DFMT_FLAG_GETDC))
+    if (!(format->flags & WINED3DFMT_FLAG_GETDC))
     {
         WARN("Cannot use GetDC on a %s surface\n", debug_d3dformat(format->id));
         return WINED3DERR_INVALIDCALL;
@@ -545,8 +573,8 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface)
     b_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
     /* TODO: Is there a nicer way to force a specific alignment? (8 byte for ddraw) */
     b_info->bmiHeader.biWidth = IWineD3DSurface_GetPitch(iface) / format->byte_count;
-    b_info->bmiHeader.biHeight = -This->currentDesc.Height -extraline;
-    b_info->bmiHeader.biSizeImage = ( This->currentDesc.Height + extraline) * IWineD3DSurface_GetPitch(iface);
+    b_info->bmiHeader.biHeight = -This->resource.height - extraline;
+    b_info->bmiHeader.biSizeImage = (This->resource.height + extraline) * IWineD3DSurface_GetPitch(iface);
     b_info->bmiHeader.biPlanes = 1;
     b_info->bmiHeader.biBitCount = format->byte_count * 8;
 
@@ -608,11 +636,15 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface)
 
     TRACE("DIBSection at : %p\n", This->dib.bitmap_data);
     /* copy the existing surface to the dib section */
-    if(This->resource.allocatedMemory) {
-        memcpy(This->dib.bitmap_data, This->resource.allocatedMemory,  This->currentDesc.Height * IWineD3DSurface_GetPitch(iface));
-    } else {
+    if (This->resource.allocatedMemory)
+    {
+        memcpy(This->dib.bitmap_data, This->resource.allocatedMemory,
+                This->resource.height * IWineD3DSurface_GetPitch(iface));
+    }
+    else
+    {
         /* This is to make LockRect read the gl Texture although memory is allocated */
-        This->Flags &= ~SFLAG_INSYSMEM;
+        This->flags &= ~SFLAG_INSYSMEM;
     }
     This->dib.bitmap_size = b_info->bmiHeader.biSizeImage;
 
@@ -626,7 +658,7 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface)
                   This->palette ? This->palette->hpal : 0,
                   FALSE);
 
-    This->Flags |= SFLAG_DIBSECTION;
+    This->flags |= SFLAG_DIBSECTION;
 
     HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
     This->resource.heapMemory = NULL;
@@ -810,8 +842,8 @@ static IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source,
         return NULL;
     }
 
-    IWineD3DDevice_CreateSurface((IWineD3DDevice *)source->resource.device, source->currentDesc.Width,
-            source->currentDesc.Height, to_fmt, TRUE /* lockable */, TRUE /* discard  */, 0 /* level */,
+    IWineD3DDevice_CreateSurface((IWineD3DDevice *)source->resource.device, source->resource.width,
+            source->resource.height, to_fmt, TRUE /* lockable */, TRUE /* discard  */, 0 /* level */,
             0 /* usage */, WINED3DPOOL_SCRATCH, WINED3DMULTISAMPLE_NONE /* TODO: Multisampled conversion */,
             0 /* MultiSampleQuality */, IWineD3DSurface_GetImplType((IWineD3DSurface *) source),
             NULL /* parent */, &wined3d_null_parent_ops, &ret);
@@ -840,7 +872,7 @@ static IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source,
     }
 
     conv->convert(lock_src.pBits, lock_dst.pBits, lock_src.Pitch, lock_dst.Pitch,
-                  source->currentDesc.Width, source->currentDesc.Height);
+            source->resource.width, source->resource.height);
 
     IWineD3DSurface_Unmap(ret);
     IWineD3DSurface_Unmap((IWineD3DSurface *)source);
@@ -924,7 +956,7 @@ static HRESULT
  *  SrcRect: Source rectangle
  *****************************************************************************/
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *src_surface,
-        const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter)
+        const RECT *SrcRect, DWORD flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     IWineD3DSurfaceImpl *src = (IWineD3DSurfaceImpl *)src_surface;
@@ -939,9 +971,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
 
     TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
             iface, wine_dbgstr_rect(DestRect), src_surface, wine_dbgstr_rect(SrcRect),
-            Flags, DDBltFx, debug_d3dtexturefiltertype(Filter));
+            flags, DDBltFx, debug_d3dtexturefiltertype(Filter));
 
-    if ((This->Flags & SFLAG_LOCKED) || (src && (src->Flags & SFLAG_LOCKED)))
+    if ((This->flags & SFLAG_LOCKED) || (src && (src->flags & SFLAG_LOCKED)))
     {
         WARN(" Surface is busy, returning DDERR_SURFACEBUSY\n");
         return WINEDDERR_SURFACEBUSY;
@@ -955,18 +987,18 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
         if (src)
         {
             if (SrcRect->right < SrcRect->left || SrcRect->bottom < SrcRect->top
-                    || SrcRect->left > src->currentDesc.Width || SrcRect->left < 0
-                    || SrcRect->top > src->currentDesc.Height || SrcRect->top < 0
-                    || SrcRect->right > src->currentDesc.Width || SrcRect->right < 0
-                    || SrcRect->bottom > src->currentDesc.Height || SrcRect->bottom < 0)
+                    || SrcRect->left > src->resource.width || SrcRect->left < 0
+                    || SrcRect->top > src->resource.height || SrcRect->top < 0
+                    || SrcRect->right > src->resource.width || SrcRect->right < 0
+                    || SrcRect->bottom > src->resource.height || SrcRect->bottom < 0)
             {
                 WARN("Application gave us bad source rectangle for Blt.\n");
                 return WINEDDERR_INVALIDRECT;
             }
 
             if (!SrcRect->right || !SrcRect->bottom
-                    || SrcRect->left == (int)src->currentDesc.Width
-                    || SrcRect->top == (int)src->currentDesc.Height)
+                    || SrcRect->left == (int)src->resource.width
+                    || SrcRect->top == (int)src->resource.height)
             {
                 TRACE("Nothing to be done.\n");
                 return WINED3D_OK;
@@ -979,8 +1011,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
     {
         xsrc.left = 0;
         xsrc.top = 0;
-        xsrc.right = src->currentDesc.Width;
-        xsrc.bottom = src->currentDesc.Height;
+        xsrc.right = src->resource.width;
+        xsrc.bottom = src->resource.height;
     }
     else
     {
@@ -992,18 +1024,18 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
         /* For the Destination rect, it can be out of bounds on the condition
          * that a clipper is set for the given surface. */
         if (!This->clipper && (DestRect->right < DestRect->left || DestRect->bottom < DestRect->top
-                || DestRect->left > This->currentDesc.Width || DestRect->left < 0
-                || DestRect->top > This->currentDesc.Height || DestRect->top < 0
-                || DestRect->right > This->currentDesc.Width || DestRect->right < 0
-                || DestRect->bottom > This->currentDesc.Height || DestRect->bottom < 0))
+                || DestRect->left > This->resource.width || DestRect->left < 0
+                || DestRect->top > This->resource.height || DestRect->top < 0
+                || DestRect->right > This->resource.width || DestRect->right < 0
+                || DestRect->bottom > This->resource.height || DestRect->bottom < 0))
         {
             WARN("Application gave us bad destination rectangle for Blt without a clipper set.\n");
             return WINEDDERR_INVALIDRECT;
         }
 
         if (DestRect->right <= 0 || DestRect->bottom <= 0
-                || DestRect->left >= (int)This->currentDesc.Width
-                || DestRect->top >= (int)This->currentDesc.Height)
+                || DestRect->left >= (int)This->resource.width
+                || DestRect->top >= (int)This->resource.height)
         {
             TRACE("Nothing to be done.\n");
             return WINED3D_OK;
@@ -1015,8 +1047,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
 
             full_rect.left = 0;
             full_rect.top = 0;
-            full_rect.right = This->currentDesc.Width;
-            full_rect.bottom = This->currentDesc.Height;
+            full_rect.right = This->resource.width;
+            full_rect.bottom = This->resource.height;
             IntersectRect(&xdst, &full_rect, DestRect);
         }
         else
@@ -1024,13 +1056,13 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
             BOOL clip_horiz, clip_vert;
 
             xdst = *DestRect;
-            clip_horiz = xdst.left < 0 || xdst.right > (int)This->currentDesc.Width;
-            clip_vert = xdst.top < 0 || xdst.bottom > (int)This->currentDesc.Height;
+            clip_horiz = xdst.left < 0 || xdst.right > (int)This->resource.width;
+            clip_vert = xdst.top < 0 || xdst.bottom > (int)This->resource.height;
 
             if (clip_vert || clip_horiz)
             {
                 /* Now check if this is a special case or not... */
-                if ((Flags & WINEDDBLT_DDFX)
+                if ((flags & WINEDDBLT_DDFX)
                         || (clip_horiz && xdst.right - xdst.left != xsrc.right - xsrc.left)
                         || (clip_vert && xdst.bottom - xdst.top != xsrc.bottom - xsrc.top))
                 {
@@ -1045,10 +1077,10 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                         xsrc.left -= xdst.left;
                         xdst.left = 0;
                     }
-                    if (xdst.right > This->currentDesc.Width)
+                    if (xdst.right > This->resource.width)
                     {
-                        xsrc.right -= (xdst.right - (int)This->currentDesc.Width);
-                        xdst.right = (int)This->currentDesc.Width;
+                        xsrc.right -= (xdst.right - (int)This->resource.width);
+                        xdst.right = (int)This->resource.width;
                     }
                 }
 
@@ -1059,20 +1091,20 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                         xsrc.top -= xdst.top;
                         xdst.top = 0;
                     }
-                    if (xdst.bottom > This->currentDesc.Height)
+                    if (xdst.bottom > This->resource.height)
                     {
-                        xsrc.bottom -= (xdst.bottom - (int)This->currentDesc.Height);
-                        xdst.bottom = (int)This->currentDesc.Height;
+                        xsrc.bottom -= (xdst.bottom - (int)This->resource.height);
+                        xdst.bottom = (int)This->resource.height;
                     }
                 }
 
                 /* And check if after clipping something is still to be done... */
                 if ((xdst.right <= 0) || (xdst.bottom <= 0)
-                        || (xdst.left >= (int)This->currentDesc.Width)
-                        || (xdst.top >= (int)This->currentDesc.Height)
+                        || (xdst.left >= (int)This->resource.width)
+                        || (xdst.top >= (int)This->resource.height)
                         || (xsrc.right <= 0) || (xsrc.bottom <= 0)
-                        || (xsrc.left >= (int)src->currentDesc.Width)
-                        || (xsrc.top >= (int)src->currentDesc.Height))
+                        || (xsrc.left >= (int)src->resource.width)
+                        || (xsrc.top >= (int)src->resource.height))
                 {
                     TRACE("Nothing to be done after clipping.\n");
                     return WINED3D_OK;
@@ -1084,8 +1116,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
     {
         xdst.left = 0;
         xdst.top = 0;
-        xdst.right = This->currentDesc.Width;
-        xdst.bottom = This->currentDesc.Height;
+        xdst.right = This->resource.width;
+        xdst.bottom = This->resource.height;
     }
 
     if (src == This)
@@ -1123,9 +1155,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
             IWineD3DSurface_Map(iface, &dlock, NULL, 0);
     }
 
-    if (!DDBltFx || !(DDBltFx->dwDDFX)) Flags &= ~WINEDDBLT_DDFX;
+    if (!DDBltFx || !(DDBltFx->dwDDFX)) flags &= ~WINEDDBLT_DDFX;
 
-    if (sEntry->Flags & dEntry->Flags & WINED3DFMT_FLAG_FOURCC)
+    if (sEntry->flags & dEntry->flags & WINED3DFMT_FLAG_FOURCC)
     {
         if (!DestRect || src == This)
         {
@@ -1146,41 +1178,41 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
     else
         dbuf = (BYTE*)dlock.pBits+(xdst.top*dlock.Pitch)+(xdst.left*bpp);
 
-    if (Flags & WINEDDBLT_WAIT)
+    if (flags & WINEDDBLT_WAIT)
     {
-        Flags &= ~WINEDDBLT_WAIT;
+        flags &= ~WINEDDBLT_WAIT;
     }
-    if (Flags & WINEDDBLT_ASYNC)
+    if (flags & WINEDDBLT_ASYNC)
     {
         static BOOL displayed = FALSE;
         if (!displayed)
             FIXME("Can't handle WINEDDBLT_ASYNC flag right now.\n");
         displayed = TRUE;
-        Flags &= ~WINEDDBLT_ASYNC;
+        flags &= ~WINEDDBLT_ASYNC;
     }
-    if (Flags & WINEDDBLT_DONOTWAIT)
+    if (flags & WINEDDBLT_DONOTWAIT)
     {
         /* WINEDDBLT_DONOTWAIT appeared in DX7 */
         static BOOL displayed = FALSE;
         if (!displayed)
             FIXME("Can't handle WINEDDBLT_DONOTWAIT flag right now.\n");
         displayed = TRUE;
-        Flags &= ~WINEDDBLT_DONOTWAIT;
+        flags &= ~WINEDDBLT_DONOTWAIT;
     }
 
     /* First, all the 'source-less' blits */
-    if (Flags & WINEDDBLT_COLORFILL)
+    if (flags & WINEDDBLT_COLORFILL)
     {
         ret = _Blt_ColorFill(dbuf, dstwidth, dstheight, bpp,
                              dlock.Pitch, DDBltFx->u5.dwFillColor);
-        Flags &= ~WINEDDBLT_COLORFILL;
+        flags &= ~WINEDDBLT_COLORFILL;
     }
 
-    if (Flags & WINEDDBLT_DEPTHFILL)
+    if (flags & WINEDDBLT_DEPTHFILL)
     {
         FIXME("DDBLT_DEPTHFILL needs to be implemented!\n");
     }
-    if (Flags & WINEDDBLT_ROP)
+    if (flags & WINEDDBLT_ROP)
     {
         /* Catch some degenerate cases here */
         switch(DDBltFx->dwROP)
@@ -1199,9 +1231,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                 FIXME("Unsupported raster op: %08x  Pattern: %p\n", DDBltFx->dwROP, DDBltFx->u5.lpDDSPattern);
                 goto error;
         }
-        Flags &= ~WINEDDBLT_ROP;
+        flags &= ~WINEDDBLT_ROP;
     }
-    if (Flags & WINEDDBLT_DDROPS)
+    if (flags & WINEDDBLT_DDROPS)
     {
         FIXME("\tDdraw Raster Ops: %08x  Pattern: %p\n", DDBltFx->dwDDROP, DDBltFx->u5.lpDDSPattern);
     }
@@ -1225,7 +1257,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
         xinc = (srcwidth << 16) / dstwidth;
         yinc = (srcheight << 16) / dstheight;
 
-        if (!Flags)
+        if (!flags)
         {
             /* No effects, we can cheat here */
             if (dstwidth == srcwidth)
@@ -1340,27 +1372,27 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
             LONG dstyinc = dlock.Pitch, dstxinc = bpp;
             DWORD keylow = 0xFFFFFFFF, keyhigh = 0, keymask = 0xFFFFFFFF;
             DWORD destkeylow = 0x0, destkeyhigh = 0xFFFFFFFF, destkeymask = 0xFFFFFFFF;
-            if (Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE))
+            if (flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE))
             {
                 /* The color keying flags are checked for correctness in ddraw */
-                if (Flags & WINEDDBLT_KEYSRC)
+                if (flags & WINEDDBLT_KEYSRC)
                 {
                     keylow  = src->SrcBltCKey.dwColorSpaceLowValue;
                     keyhigh = src->SrcBltCKey.dwColorSpaceHighValue;
                 }
-                else  if (Flags & WINEDDBLT_KEYSRCOVERRIDE)
+                else  if (flags & WINEDDBLT_KEYSRCOVERRIDE)
                 {
                     keylow  = DDBltFx->ddckSrcColorkey.dwColorSpaceLowValue;
                     keyhigh = DDBltFx->ddckSrcColorkey.dwColorSpaceHighValue;
                 }
 
-                if (Flags & WINEDDBLT_KEYDEST)
+                if (flags & WINEDDBLT_KEYDEST)
                 {
                     /* Destination color keys are taken from the source surface ! */
                     destkeylow  = src->DestBltCKey.dwColorSpaceLowValue;
                     destkeyhigh = src->DestBltCKey.dwColorSpaceHighValue;
                 }
-                else if (Flags & WINEDDBLT_KEYDESTOVERRIDE)
+                else if (flags & WINEDDBLT_KEYDESTOVERRIDE)
                 {
                     destkeylow  = DDBltFx->ddckDestColorkey.dwColorSpaceLowValue;
                     destkeyhigh = DDBltFx->ddckDestColorkey.dwColorSpaceHighValue;
@@ -1376,10 +1408,10 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                             | sEntry->green_mask
                             | sEntry->blue_mask;
                 }
-                Flags &= ~(WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE);
+                flags &= ~(WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE);
             }
 
-            if (Flags & WINEDDBLT_DDFX)
+            if (flags & WINEDDBLT_DDFX)
             {
                 LPBYTE dTopLeft, dTopRight, dBottomLeft, dBottomRight, tmp;
                 LONG tmpxy;
@@ -1391,7 +1423,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                 if (DDBltFx->dwDDFX & WINEDDBLTFX_ARITHSTRETCHY)
                 {
                     /* I don't think we need to do anything about this flag */
-                    WARN("Flags=DDBLT_DDFX nothing done for WINEDDBLTFX_ARITHSTRETCHY\n");
+                    WARN("flags=DDBLT_DDFX nothing done for WINEDDBLTFX_ARITHSTRETCHY\n");
                 }
                 if (DDBltFx->dwDDFX & WINEDDBLTFX_MIRRORLEFTRIGHT)
                 {
@@ -1416,7 +1448,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                 if (DDBltFx->dwDDFX & WINEDDBLTFX_NOTEARING)
                 {
                     /* I don't think we need to do anything about this flag */
-                    WARN("Flags=DDBLT_DDFX nothing done for WINEDDBLTFX_NOTEARING\n");
+                    WARN("flags=DDBLT_DDFX nothing done for WINEDDBLTFX_NOTEARING\n");
                 }
                 if (DDBltFx->dwDDFX & WINEDDBLTFX_ROTATE180)
                 {
@@ -1456,10 +1488,10 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                 if (DDBltFx->dwDDFX & WINEDDBLTFX_ZBUFFERBASEDEST)
                 {
                     /* I don't think we need to do anything about this flag */
-                    WARN("Flags=WINEDDBLT_DDFX nothing done for WINEDDBLTFX_ZBUFFERBASEDEST\n");
+                    WARN("flags=WINEDDBLT_DDFX nothing done for WINEDDBLTFX_ZBUFFERBASEDEST\n");
                 }
                 dbuf = dTopLeft;
-                Flags &= ~(WINEDDBLT_DDFX);
+                flags &= ~(WINEDDBLT_DDFX);
             }
 
 #define COPY_COLORKEY_FX(type) { \
@@ -1513,7 +1545,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                 }
                 default:
                     FIXME("%s color-keyed blit not implemented for bpp %d!\n",
-                          (Flags & WINEDDBLT_KEYSRC) ? "Source" : "Destination", bpp*8);
+                          (flags & WINEDDBLT_KEYSRC) ? "Source" : "Destination", bpp*8);
                     ret = WINED3DERR_NOTAVAILABLE;
                     goto error;
 #undef COPY_COLORKEY_FX
@@ -1522,9 +1554,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
     }
 
 error:
-    if (Flags && FIXME_ON(d3d_surface))
+    if (flags && FIXME_ON(d3d_surface))
     {
-        FIXME("\tUnsupported flags: %08x\n", Flags);
+        FIXME("\tUnsupported flags: %#x.\n", flags);
     }
 
 release:
@@ -1547,7 +1579,7 @@ release:
  *  dsty:
  *  src_surface: Source surface to copy from
  *  rsrc: Source rectangle
- *  trans: Some Flags
+ *  trans: Some flags
  *
  * Returns:
  *  WINED3D_OK on success
@@ -1571,7 +1603,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
     TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
             iface, dstx, dsty, src_surface, wine_dbgstr_rect(rsrc), trans);
 
-    if ((This->Flags & SFLAG_LOCKED) || (src->Flags & SFLAG_LOCKED))
+    if ((This->flags & SFLAG_LOCKED) || (src->flags & SFLAG_LOCKED))
     {
         WARN(" Surface is busy, returning DDERR_SURFACEBUSY\n");
         return WINEDDERR_SURFACEBUSY;
@@ -1582,16 +1614,16 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
         WARN("rsrc is NULL!\n");
         rsrc2.left = 0;
         rsrc2.top = 0;
-        rsrc2.right = src->currentDesc.Width;
-        rsrc2.bottom = src->currentDesc.Height;
+        rsrc2.right = src->resource.width;
+        rsrc2.bottom = src->resource.height;
         rsrc = &rsrc2;
     }
 
     /* Check source rect for validity. Copied from normal Blt. Fixes Baldur's Gate.*/
-    if ((rsrc->bottom > src->currentDesc.Height) || (rsrc->bottom < 0)
-            || (rsrc->top   > src->currentDesc.Height) || (rsrc->top    < 0)
-            || (rsrc->left  > src->currentDesc.Width)  || (rsrc->left   < 0)
-            || (rsrc->right > src->currentDesc.Width)  || (rsrc->right  < 0)
+    if ((rsrc->bottom > src->resource.height) || (rsrc->bottom < 0)
+            || (rsrc->top   > src->resource.height) || (rsrc->top    < 0)
+            || (rsrc->left  > src->resource.width)  || (rsrc->left   < 0)
+            || (rsrc->right > src->resource.width)  || (rsrc->right  < 0)
             || (rsrc->right < rsrc->left)              || (rsrc->bottom < rsrc->top))
     {
         WARN("Application gave us bad source rectangle for BltFast.\n");
@@ -1599,14 +1631,20 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
     }
 
     h = rsrc->bottom - rsrc->top;
-    if (h > This->currentDesc.Height-dsty) h = This->currentDesc.Height-dsty;
-    if (h > src->currentDesc.Height-rsrc->top) h = src->currentDesc.Height-rsrc->top;
-    if (h <= 0) return WINEDDERR_INVALIDRECT;
+    if (h > This->resource.height-dsty)
+        h = This->resource.height-dsty;
+    if (h > src->resource.height-rsrc->top)
+        h = src->resource.height-rsrc->top;
+    if (h <= 0)
+        return WINEDDERR_INVALIDRECT;
 
     w = rsrc->right - rsrc->left;
-    if (w > This->currentDesc.Width-dstx) w = This->currentDesc.Width-dstx;
-    if (w > src->currentDesc.Width-rsrc->left) w = src->currentDesc.Width-rsrc->left;
-    if (w <= 0) return WINEDDERR_INVALIDRECT;
+    if (w > This->resource.width-dstx)
+        w = This->resource.width-dstx;
+    if (w > src->resource.width-rsrc->left)
+        w = src->resource.width-rsrc->left;
+    if (w <= 0)
+        return WINEDDERR_INVALIDRECT;
 
     /* Now compute the locking rectangle... */
     lock_src.left = rsrc->left;
@@ -1657,7 +1695,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
     }
 
     /* Handle compressed surfaces first... */
-    if (sEntry->Flags & dEntry->Flags & WINED3DFMT_FLAG_COMPRESSED)
+    if (sEntry->flags & dEntry->flags & WINED3DFMT_FLAG_COMPRESSED)
     {
         UINT row_block_count;
 
@@ -1683,7 +1721,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
 
         goto error;
     }
-    if ((sEntry->Flags & WINED3DFMT_FLAG_COMPRESSED) && !(dEntry->Flags & WINED3DFMT_FLAG_COMPRESSED))
+    if ((sEntry->flags & WINED3DFMT_FLAG_COMPRESSED) && !(dEntry->flags & WINED3DFMT_FLAG_COMPRESSED))
     {
         /* TODO: Use the libtxc_dxtn.so shared library to do
          * software decompression
@@ -1812,12 +1850,12 @@ error:
 }
 
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_Map(IWineD3DSurface *iface,
-        WINED3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD Flags)
+        WINED3DLOCKED_RECT *pLockedRect, const RECT *pRect, DWORD flags)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
 
-    TRACE("(%p) : rect@%p flags(%08x), output lockedRect@%p, memory@%p\n",
-          This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
+    TRACE("iface %p, locked_rect %p, rect %s, flags %#x.\n",
+            iface, pLockedRect, wine_dbgstr_rect(pRect), flags);
 
     pLockedRect->Pitch = IWineD3DSurface_GetPitch(iface);
 
@@ -1826,8 +1864,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Map(IWineD3DSurface *iface,
         pLockedRect->pBits = This->resource.allocatedMemory;
         This->lockedRect.left   = 0;
         This->lockedRect.top    = 0;
-        This->lockedRect.right  = This->currentDesc.Width;
-        This->lockedRect.bottom = This->currentDesc.Height;
+        This->lockedRect.right  = This->resource.width;
+        This->lockedRect.bottom = This->resource.height;
 
         TRACE("Locked Rect (%p) = l %d, t %d, r %d, b %d\n",
               &This->lockedRect, This->lockedRect.left, This->lockedRect.top,
@@ -1840,7 +1878,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Map(IWineD3DSurface *iface,
         TRACE("Lock Rect (%p) = l %d, t %d, r %d, b %d\n",
               pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
 
-        if ((format->Flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED)
+        if ((format->flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED)
         {
             /* Compressed textures are block based, so calculate the offset of
              * the block that contains the top-left pixel of the locked rectangle. */
@@ -1865,17 +1903,3 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Map(IWineD3DSurface *iface,
 
     return WINED3D_OK;
 }
-
-/* TODO: think about moving this down to resource? */
-const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface)
-{
-    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-
-    /* This should only be called for sysmem textures, it may be a good idea
-     * to extend this to all pools at some point in the future  */
-    if (This->resource.pool != WINED3DPOOL_SYSTEMMEM)
-    {
-        FIXME("(%p) Attempting to get system memory for a non-system memory texture\n", iface);
-    }
-    return This->resource.allocatedMemory;
-}