Replace the id<-->key hashmap in SkImageFilter by a SkTArray
authorxidachen <xidachen@chromium.org>
Mon, 1 Feb 2016 13:27:16 +0000 (05:27 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 1 Feb 2016 13:27:16 +0000 (05:27 -0800)
commit23526963135bd15737505bd560d41b0d5a41439e
treef924eb922f2add21a8560bf01461ef179182d63d
parent188d44c5496c64fe06e02ba00a3e983200fa6c88
Replace the id<-->key hashmap in SkImageFilter by a SkTArray

In the current implementation, SkImageFilter::Cache maintains a hash map
that maps SkImageFilter's uniqueID to an array of keys, and its purpose
is to remove the values in Cache that are associated with this array of
keys that are indexed by uniqueID. However, maintaining this hash map
causes perf regression to smoothness.tough_filters_cases.

This CL removes the id<-->key hashmap. Instead, we maintain an array of
keys in SkImageFilter. Whenever there is a new key, we push it into the
array. In ~SkImageFilter(), we call Cache::purgeByKeys to remove all the
values that are associated with the keys that are maintained by SkImageFilter.

BUG=571655
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1651433002

Review URL: https://codereview.chromium.org/1651433002
include/core/SkImageFilter.h
src/core/SkImageFilter.cpp