[PATCH 3/5] wined3d: Maintain a list of swapchains a palette is attached to.
Stefan Dösinger
stefan at codeweavers.com
Thu May 15 07:33:13 CDT 2014
---
dlls/wined3d/palette.c | 15 ++++-----------
dlls/wined3d/swapchain.c | 9 +++++++++
dlls/wined3d/wined3d_private.h | 3 +++
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/palette.c b/dlls/wined3d/palette.c
index 780f068..89ff7a4 100644
--- a/dlls/wined3d/palette.c
+++ b/dlls/wined3d/palette.c
@@ -92,7 +92,7 @@ void CDECL wined3d_palette_apply_to_dc(const struct wined3d_palette *palette, HD
HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette,
DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries)
{
- struct wined3d_resource *resource;
+ struct wined3d_swapchain *swapchain;
unsigned int i;
TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n",
@@ -130,16 +130,8 @@ HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette,
}
}
- /* If the palette is attached to the render target, update all render targets */
- LIST_FOR_EACH_ENTRY(resource, &palette->device->resources, struct wined3d_resource, resource_list_entry)
- {
- if (resource->type == WINED3D_RTYPE_SURFACE)
- {
- struct wined3d_surface *surface = surface_from_resource(resource);
- if (surface->swapchain && surface->swapchain->palette == palette)
- surface->swapchain->swapchain_ops->swapchain_realize_palette(surface->swapchain);
- }
- }
+ LIST_FOR_EACH_ENTRY(swapchain, &palette->swapchain_list, struct wined3d_swapchain, entry)
+ swapchain->swapchain_ops->swapchain_realize_palette(swapchain);
return WINED3D_OK;
}
@@ -153,6 +145,7 @@ static HRESULT wined3d_palette_init(struct wined3d_palette *palette, struct wine
palette->device = device;
palette->flags = flags;
palette->size = entry_count;
+ list_init(&palette->swapchain_list);
if (FAILED(hr = wined3d_palette_set_entries(palette, 0, 0, entry_count, entries)))
{
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index f2639d9..853b91c 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -36,6 +36,9 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
wined3d_swapchain_set_gamma_ramp(swapchain, 0, &swapchain->orig_gamma);
+ if (swapchain->palette)
+ list_remove(&swapchain->entry);
+
/* Release the swapchain's draw buffers. Make sure swapchain->back_buffers[0]
* is the last buffer to be destroyed, FindContext() depends on that. */
if (swapchain->front_buffer)
@@ -268,9 +271,15 @@ void CDECL wined3d_swapchain_set_palette(struct wined3d_swapchain *swapchain, st
return;
}
+ if (swapchain->palette)
+ list_remove(&swapchain->entry);
+
swapchain->palette = palette;
if (palette)
+ {
+ list_add_head(&palette->swapchain_list, &swapchain->entry);
swapchain->swapchain_ops->swapchain_realize_palette(swapchain);
+ }
}
HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *swapchain,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index eb9d135..c6cf767 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2621,7 +2621,9 @@ struct wined3d_swapchain
struct wined3d_gamma_ramp orig_gamma;
BOOL render_to_fbo;
const struct wined3d_format *ds_format;
+
struct wined3d_palette *palette;
+ struct list entry;
LONG prev_time, frames; /* Performance tracking */
@@ -2954,6 +2956,7 @@ struct wined3d_palette
unsigned int size;
RGBQUAD colors[256];
DWORD flags;
+ struct list swapchain_list;
};
/* DirectDraw utility functions */
--
1.8.5.5
More information about the wine-patches
mailing list