[PATCH 2/2] gdi32: Generate and use a lookup cache when looking up RGB values for a color table.

Huw Davies huw at codeweavers.com
Thu Apr 1 14:10:09 CDT 2021


On Thu, Apr 01, 2021 at 04:07:00PM +0300, Gabriel Ivăncescu wrote:
> On 01/04/2021 10:52, Huw Davies wrote:
> > On Wed, Mar 31, 2021 at 03:35:58PM +0300, Gabriel Ivăncescu wrote:
> > 
> > Did you consider using a lazy initialization of the lookup table instead?
> > 
> > Huw.
> > 
> 
> Lazy initialization meaning build it as we scan the image? That would work
> too.

Yes, build the lookup using rgb_to_pixel_colortable() as needed.

> I also thought of caching the color tables globally.
> 
> Now I don't know if that's acceptable, but here's my idea since it's what is
> good in "practice":
> 
> Hold a small fixed size global cache (4-5 entries) of color tables, with
> synchronization in case of multi-threading (just for correctness, I doubt
> any app will actually multi-thread this). If we go the lazy initialization
> approach, we'll also keep track which of the entries were not filled yet in
> the cache.
> 
> It would be a global table for all color tables, but since I expect all the
> performance problems to be using the same color table over and over again in
> a loop, it would work "in practice".
> 
> When we have to discard/replace one, we choose the oldest one that wasn't
> accessed (we keep some timestamp on each cache). Does that sound feasible?
> 
> Maybe if I end up using this global cache, I can discard the lazy init since
> it complicates things, do you think that's better?

Hooking up the global one is going to be more complicated.  I suggest you try
the (local) lazy init version first.

Huw.



More information about the wine-devel mailing list