We can use the information from format_desc instead.
object->Flags |= (WINED3DFMT_D16_LOCKABLE == Format) ? SFLAG_LOCKABLE : 0;
object->Flags |= Lockable ? SFLAG_LOCKABLE : 0;
-
- if (WINED3DFMT_UNKNOWN != Format) {
- object->bytesPerPixel = glDesc->byte_count;
- } else {
- object->bytesPerPixel = 0;
- }
-
- /** TODO: change this into a texture transform matrix so that it's processed in hardware **/
-
TRACE("Pool %d %d %d %d\n",Pool, WINED3DPOOL_DEFAULT, WINED3DPOOL_MANAGED, WINED3DPOOL_SYSTEMMEM);
/** Quick lockable sanity check TODO: remove this after surfaces, usage and lockability have been debugged properly
object->currentDesc.Width = Width;
object->currentDesc.Height = Height;
object->currentDesc.Depth = Depth;
- object->bytesPerPixel = format_desc->byte_count;
/** Note: Volume textures cannot be dxtn, hence no need to check here **/
object->lockable = TRUE;
int offset = 0;
int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the beginning of the next */
glDescriptor *glDescription = NULL;
- const struct GlPixelFormatDesc *dst_format_desc;
+ const struct GlPixelFormatDesc *src_format_desc, *dst_format_desc;
GLenum dummy;
int sampler;
int bpp;
IWineD3DSurface_GetGlDesc(pDestinationSurface, &glDescription);
+ src_format_desc = ((IWineD3DSurfaceImpl *)pSrcSurface)->resource.format_desc;
dst_format_desc = ((IWineD3DSurfaceImpl *)pDestinationSurface)->resource.format_desc;
/* this needs to be done in lines if the sourceRect != the sourceWidth */
/* This function doesn't support compressed textures
the pitch is just bytesPerPixel * width */
if(srcWidth != srcSurfaceWidth || srcLeft ){
- rowoffset = srcSurfaceWidth * pSrcSurface->bytesPerPixel;
- offset += srcLeft * pSrcSurface->bytesPerPixel;
+ rowoffset = srcSurfaceWidth * src_format_desc->byte_count;
+ offset += srcLeft * src_format_desc->byte_count;
/* TODO: do we ever get 3bpp?, would a shift and an add be quicker than a mul (well maybe a cycle or two) */
}
/* TODO DXT formats */
if(pSourceRect != NULL && pSourceRect->top != 0){
- offset += pSourceRect->top * srcSurfaceWidth * pSrcSurface->bytesPerPixel;
+ offset += pSourceRect->top * srcSurfaceWidth * src_format_desc->byte_count;
}
TRACE("(%p) glTexSubImage2D, level %d, left %d, top %d, width %d, height %d, fmt %#x, type %#x, memory %p+%#x\n",
This, glDescription->level, destLeft, destTop, srcWidth, srcHeight, dst_format_desc->glFormat,
if (This->Flags & SFLAG_NONPOW2) {
unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
- src_pitch = This->bytesPerPixel * This->pow2Width;
+ src_pitch = format_desc->byte_count * This->pow2Width;
dst_pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This);
src_pitch = (src_pitch + alignment - 1) & ~(alignment - 1);
mem = HeapAlloc(GetProcessHeap(), 0, src_pitch * This->pow2Height);
fmt = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
mem = dest;
- bpp = This->bytesPerPixel;
+ bpp = This->resource.format_desc->byte_count;
} else {
/* GL can't return palettized data, so read ARGB pixels into a
* separate block of memory and convert them into palettized format
LEAVE_GL();
return;
}
- bpp = This->bytesPerPixel * 3;
+ bpp = This->resource.format_desc->byte_count * 3;
}
}
break;
mem = dest;
fmt = This->resource.format_desc->glFormat;
type = This->resource.format_desc->glType;
- bpp = This->bytesPerPixel;
+ bpp = This->resource.format_desc->byte_count;
}
if(This->Flags & SFLAG_PBO) {
*format = glDesc->glFormat;
*type = glDesc->glType;
*convert = NO_CONVERSION;
- *target_bpp = This->bytesPerPixel;
+ *target_bpp = glDesc->byte_count;
if(srgb_mode) {
*internal = glDesc->glGammaInternal;
ret = ((This->currentDesc.Width + 3) >> 2) << 4;
else {
unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
- ret = This->bytesPerPixel * This->currentDesc.Width; /* Bytes / row */
+ ret = This->resource.format_desc->byte_count * This->currentDesc.Width; /* Bytes / row */
ret = (ret + alignment - 1) & ~(alignment - 1);
}
TRACE("(%p) Returning %d\n", This, ret);
This->resource.size *= This->pow2Height;
}
- if (format != WINED3DFMT_UNKNOWN) {
- This->bytesPerPixel = format_desc->byte_count;
- } else {
- This->bytesPerPixel = 0;
- }
-
This->Flags |= (WINED3DFMT_D16_LOCKABLE == format) ? SFLAG_LOCKABLE : 0;
This->resource.format_desc = format_desc;
- TRACE("(%p) : Size %d, bytesPerPixel %d\n", This, This->resource.size, This->bytesPerPixel);
+ TRACE("(%p) : Size %d, bytesPerPixel %d\n", This, This->resource.size, format_desc->byte_count);
return WINED3D_OK;
}
DWORD *masks;
UINT usage;
- switch (This->bytesPerPixel) {
+ switch (format_desc->byte_count)
+ {
case 2:
case 4:
/* Allocate extra space to store the RGB bit masks. */
default:
/* Allocate extra space for a palette. */
b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(BITMAPINFOHEADER)
- + sizeof(RGBQUAD)
- * (1 << (This->bytesPerPixel * 8)));
+ sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1 << (format_desc->byte_count * 8)));
break;
}
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) / This->bytesPerPixel;
+ b_info->bmiHeader.biWidth = IWineD3DSurface_GetPitch(iface) / format_desc->byte_count;
b_info->bmiHeader.biHeight = -This->currentDesc.Height -extraline;
b_info->bmiHeader.biSizeImage = ( This->currentDesc.Height + extraline) * IWineD3DSurface_GetPitch(iface);
b_info->bmiHeader.biPlanes = 1;
- b_info->bmiHeader.biBitCount = This->bytesPerPixel * 8;
+ b_info->bmiHeader.biBitCount = format_desc->byte_count * 8;
b_info->bmiHeader.biXPelsPerMeter = 0;
b_info->bmiHeader.biYPelsPerMeter = 0;
}
}
- bpp = This->bytesPerPixel;
+ bpp = This->resource.format_desc->byte_count;
srcheight = xsrc.bottom - xsrc.top;
srcwidth = xsrc.right - xsrc.left;
dstheight = xdst.bottom - xdst.top;
lock_dst.right = dstx + w;
lock_dst.bottom = dsty + h;
- bpp = This->bytesPerPixel;
+ bpp = This->resource.format_desc->byte_count;
/* We need to lock the surfaces, or we won't get refreshes when done. */
if (Src == This)
{
pLockedRect->pBits = This->resource.allocatedMemory +
(pLockedRect->Pitch * pRect->top) +
- (pRect->left * This->bytesPerPixel);
+ (pRect->left * This->resource.format_desc->byte_count);
}
This->lockedRect.left = pRect->left;
This->lockedRect.top = pRect->top;
} else {
int red_shift, green_shift, blue_shift, pix_width, alpha_shift;
- pix_width = This->bytesPerPixel;
+ pix_width = format_desc->byte_count;
red_shift = get_shift(format_desc->red_mask);
green_shift = get_shift(format_desc->green_mask);
/* fixme: should we really lock as such? */
TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->resource.allocatedMemory);
- pLockedVolume->RowPitch = This->bytesPerPixel * This->currentDesc.Width; /* Bytes / row */
- pLockedVolume->SlicePitch = This->bytesPerPixel * This->currentDesc.Width * This->currentDesc.Height; /* Bytes / slice */
+ pLockedVolume->RowPitch = This->resource.format_desc->byte_count * This->currentDesc.Width; /* Bytes / row */
+ pLockedVolume->SlicePitch = This->resource.format_desc->byte_count
+ * This->currentDesc.Width * This->currentDesc.Height; /* Bytes / slice */
if (!pBox) {
TRACE("No box supplied - all is ok\n");
pLockedVolume->pBits = This->resource.allocatedMemory;
This->lockedBox.Back = This->currentDesc.Depth;
} else {
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
- pLockedVolume->pBits = This->resource.allocatedMemory +
- (pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
- (pLockedVolume->RowPitch * pBox->Top) +
- (pBox->Left * This->bytesPerPixel);
+ pLockedVolume->pBits = This->resource.allocatedMemory
+ + (pLockedVolume->SlicePitch * pBox->Front) /* FIXME: is front < back or vica versa? */
+ + (pLockedVolume->RowPitch * pBox->Top)
+ + (pBox->Left * This->resource.format_desc->byte_count);
This->lockedBox.Left = pBox->Left;
This->lockedBox.Top = pBox->Top;
This->lockedBox.Front = pBox->Front;
/* WineD3DVolume Information */
WINED3DVOLUMET_DESC currentDesc;
IWineD3DBase *container;
- UINT bytesPerPixel;
-
BOOL lockable;
BOOL locked;
WINED3DBOX lockedBox;
WINED3DBOX dirtyBox;
BOOL dirty;
-
-
} IWineD3DVolumeImpl;
extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
IWineD3DPaletteImpl *palette; /* D3D7 style palette handling */
PALETTEENTRY *palette9; /* D3D8/9 style palette handling */
- UINT bytesPerPixel;
-
/* TODO: move this off into a management class(maybe!) */
DWORD Flags;