wined3d: Simply pass an IWineD3DSurfaceImpl pointer to surface_is_offscreen().

This commit is contained in:
Henri Verbeet 2010-04-18 22:50:45 +02:00 committed by Alexandre Julliard
parent efb3993a3a
commit 03dc612c9c
4 changed files with 30 additions and 31 deletions

View File

@ -1353,7 +1353,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3
ret->current_rt = (IWineD3DSurface *)target;
ret->tid = GetCurrentThreadId();
ret->render_offscreen = surface_is_offscreen((IWineD3DSurface *) target);
ret->render_offscreen = surface_is_offscreen(target);
ret->draw_buffer_dirty = TRUE;
ret->valid = 1;
@ -1881,7 +1881,7 @@ static void context_apply_draw_buffer(struct wined3d_context *context, BOOL blit
IWineD3DDeviceImpl *device;
device = ((IWineD3DSurfaceImpl *)rt)->resource.device;
if (!surface_is_offscreen(rt))
if (!surface_is_offscreen((IWineD3DSurfaceImpl *)rt))
{
ENTER_GL();
glDrawBuffer(surface_get_gl_buffer(rt));
@ -2099,7 +2099,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device, struct wined3d_cont
if (!target) return;
else if (context->current_rt == target) return;
render_offscreen = surface_is_offscreen(target);
render_offscreen = surface_is_offscreen((IWineD3DSurfaceImpl *)target);
context_set_render_offscreen(context, StateTable, render_offscreen);

View File

@ -4378,7 +4378,7 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfac
context = context_acquire(This, (IWineD3DSurface *)target, CTXUSAGE_CLEAR);
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
if (!surface_is_offscreen((IWineD3DSurface *)target))
if (!surface_is_offscreen(target))
{
TRACE("Surface %p is onscreen\n", target);
@ -5441,7 +5441,7 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface,
if (rect) IWineD3DSurface_LoadLocation(surface, SFLAG_INDRAWABLE, NULL);
IWineD3DSurface_ModifyLocation(surface, SFLAG_INDRAWABLE, TRUE);
if (!surface_is_offscreen(surface))
if (!surface_is_offscreen((IWineD3DSurfaceImpl *)surface))
{
TRACE("Surface %p is onscreen\n", surface);
@ -5463,12 +5463,11 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface,
if (rect) {
glEnable(GL_SCISSOR_TEST);
if(surface_is_offscreen(surface)) {
if (surface_is_offscreen((IWineD3DSurfaceImpl *)surface))
glScissor(rect->x1, rect->y1, rect->x2 - rect->x1, rect->y2 - rect->y1);
} else {
else
glScissor(rect->x1, ((IWineD3DSurfaceImpl *)surface)->currentDesc.Height - rect->y2,
rect->x2 - rect->x1, rect->y2 - rect->y1);
}
checkGLcall("glScissor");
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SCISSORRECT);
} else {
@ -5742,8 +5741,8 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
IWineD3DSurface_LoadLocation(src_surface, SFLAG_INDRAWABLE, NULL);
IWineD3DSurface_LoadLocation(dst_surface, SFLAG_INDRAWABLE, NULL);
if (!surface_is_offscreen(src_surface)) context = context_acquire(This, src_surface, CTXUSAGE_RESOURCELOAD);
else if (!surface_is_offscreen(dst_surface)) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
if (!surface_is_offscreen((IWineD3DSurfaceImpl *)src_surface)) context = context_acquire(This, src_surface, CTXUSAGE_RESOURCELOAD);
else if (!surface_is_offscreen((IWineD3DSurfaceImpl *)dst_surface)) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
else context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
if (!context->valid)
@ -5755,7 +5754,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
gl_info = context->gl_info;
if (!surface_is_offscreen(src_surface))
if (!surface_is_offscreen((IWineD3DSurfaceImpl *)src_surface))
{
GLenum buffer = surface_get_gl_buffer(src_surface);
@ -5791,7 +5790,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
LEAVE_GL();
/* Attach dst surface to dst fbo */
if (!surface_is_offscreen(dst_surface))
if (!surface_is_offscreen((IWineD3DSurfaceImpl *)dst_surface))
{
GLenum buffer = surface_get_gl_buffer(dst_surface);

View File

@ -730,8 +730,7 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, const struct wined3d_
{
internal = format_desc->glGammaInternal;
}
else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET
&& surface_is_offscreen((IWineD3DSurface *)This))
else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET && surface_is_offscreen(This))
{
internal = format_desc->rtInternal;
}
@ -811,8 +810,7 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct win
{
internal = format_desc->glGammaInternal;
}
else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET
&& surface_is_offscreen((IWineD3DSurface *)This))
else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET && surface_is_offscreen(This))
{
internal = format_desc->rtInternal;
}
@ -1280,7 +1278,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
* There is no need to keep track of the current read buffer or reset it, every part of the code
* that reads sets the read buffer as desired.
*/
if (surface_is_offscreen((IWineD3DSurface *) This))
if (surface_is_offscreen(This))
{
/* Locking the primary render target which is not on a swapchain(=offscreen render target).
* Read from the back buffer
@ -1512,7 +1510,7 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb)
* There is no need to keep track of the current read buffer or reset it, every part of the code
* that reads sets the read buffer as desired.
*/
if (!surface_is_offscreen((IWineD3DSurface *)This))
if (!surface_is_offscreen(This))
{
GLenum buffer = surface_get_gl_buffer((IWineD3DSurface *)This);
TRACE("Locking %#x buffer\n", buffer);
@ -1771,7 +1769,7 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
ENTER_GL();
if (!surface_is_offscreen((IWineD3DSurface *)This))
if (!surface_is_offscreen(This))
{
GLenum buffer = surface_get_gl_buffer((IWineD3DSurface *)This);
TRACE("Unlocking %#x buffer.\n", buffer);
@ -2989,7 +2987,8 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
/* Bind the target texture */
glBindTexture(This->texture_target, This->texture_name);
checkGLcall("glBindTexture");
if(surface_is_offscreen(SrcSurface)) {
if (surface_is_offscreen(Src))
{
TRACE("Reading from an offscreen target\n");
upsidedown = !upsidedown;
glReadBuffer(device->offscreenBuffer);
@ -3090,7 +3089,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
context = context_acquire(device, SrcSurface, CTXUSAGE_BLIT);
surface_internal_preload((IWineD3DSurface *) This, SRGB_RGB);
src_offscreen = surface_is_offscreen(SrcSurface);
src_offscreen = surface_is_offscreen(Src);
noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO;
if (!noBackBufferBackup && !Src->texture_name)
{
@ -4205,8 +4204,9 @@ static void WINAPI IWineD3DSurfaceImpl_ModifyLocation(IWineD3DSurface *iface, DW
TRACE("(%p)->(%s, %s)\n", iface, debug_surflocation(flag),
persistent ? "TRUE" : "FALSE");
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
if (surface_is_offscreen(iface))
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
if (surface_is_offscreen(This))
{
/* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. */
if (flag & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE)) flag |= (SFLAG_INTEXTURE | SFLAG_INDRAWABLE);
@ -4322,8 +4322,9 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D
BOOL drawable_read_ok = TRUE;
BOOL in_fbo = FALSE;
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
if (surface_is_offscreen(iface))
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
if (surface_is_offscreen(This))
{
/* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets.
* Prefer SFLAG_INTEXTURE. */
@ -4605,16 +4606,15 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_DrawOverlay(IWineD3DSurface *iface) {
return hr;
}
BOOL surface_is_offscreen(IWineD3DSurface *iface)
BOOL surface_is_offscreen(IWineD3DSurfaceImpl *surface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *) This->container;
IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)surface->container;
/* Not on a swapchain - must be offscreen */
if (!(This->Flags & SFLAG_SWAPCHAIN)) return TRUE;
if (!(surface->Flags & SFLAG_SWAPCHAIN)) return TRUE;
/* The front buffer is always onscreen */
if(iface == swapchain->frontBuffer) return FALSE;
if (surface == (IWineD3DSurfaceImpl *)swapchain->frontBuffer) return FALSE;
/* If the swapchain is rendered to an FBO, the backbuffer is
* offscreen, otherwise onscreen */

View File

@ -1872,7 +1872,7 @@ typedef struct IWineD3DBaseTextureClass
void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
BOOL surface_init_sysmem(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
BOOL surface_is_offscreen(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
BOOL surface_is_offscreen(IWineD3DSurfaceImpl *iface) DECLSPEC_HIDDEN;
void surface_prepare_texture(IWineD3DSurfaceImpl *surface,
const struct wined3d_gl_info *gl_info, BOOL srgb) DECLSPEC_HIDDEN;