diff options
author | Chris Craik <ccraik@google.com> | 2013-03-04 10:19:31 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2013-04-15 13:53:02 -0700 |
commit | 527a3aace1dd72432c2e0472a570e030ad04bf16 (patch) | |
tree | 24f8cca71f0377a88b35fbe060a3247040b3de9f /libs/hwui/utils | |
parent | 8d4c23b9c32f8c0328ebca538bb801716fe4478a (diff) | |
download | frameworks_base-527a3aace1dd72432c2e0472a570e030ad04bf16.zip frameworks_base-527a3aace1dd72432c2e0472a570e030ad04bf16.tar.gz frameworks_base-527a3aace1dd72432c2e0472a570e030ad04bf16.tar.bz2 |
Draw Operation merging
Merge simple bitmap draw operations and text operations to avoid
issuing individual gl draws for each operation. Merging other ops to
be done eventually.
The methods are different - the bitmap merging generates a single
mesh for reused, unclipped images (esp. repeated images in a listview)
The text approach queries just defers the normal font rendering until
the last drawText in the sequence that can share the same shader.
Patches are sorted and merged, but don't yet have a multiDraw
implementation. For now, the pretending-to-merge gives better sorting
behavior by keeping similar patches together.
Change-Id: Ic300cdab0a53814cf7b09c58bf54b1bf0f58ccd6
Diffstat (limited to 'libs/hwui/utils')
-rw-r--r-- | libs/hwui/utils/TinyHashMap.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/libs/hwui/utils/TinyHashMap.h b/libs/hwui/utils/TinyHashMap.h new file mode 100644 index 0000000..8855140 --- /dev/null +++ b/libs/hwui/utils/TinyHashMap.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_HWUI_TINYHASHMAP_H +#define ANDROID_HWUI_TINYHASHMAP_H + +#include <utils/BasicHashtable.h> + +namespace android { +namespace uirenderer { + +/** + * A very simple hash map that doesn't allow duplicate keys, overwriting the older entry. + * + * Currently, expects simple keys that are handled by hash_t() + */ +template <typename TKey, typename TValue> +class TinyHashMap { +public: + typedef key_value_pair_t<TKey, TValue> TEntry; + + /** + * Puts an entry in the hash, removing any existing entry with the same key + */ + void put(TKey key, TValue value) { + hash_t hash = hash_t(key); + + ssize_t index = mTable.find(-1, hash, key); + if (index != -1) { + mTable.removeAt(index); + } + + TEntry initEntry(key, value); + mTable.add(hash, initEntry); + } + + /** + * Return true if key is in the map, in which case stores the value in the output ref + */ + bool get(TKey key, TValue& outValue) { + hash_t hash = hash_t(key); + ssize_t index = mTable.find(-1, hash, key); + if (index == -1) { + return false; + } + outValue = mTable.entryAt(index).value; + return true; + } + + void clear() { mTable.clear(); } + +private: + BasicHashtable<TKey, TEntry> mTable; +}; + +}; // namespace uirenderer +}; // namespace android + +#endif // ANDROID_HWUI_TINYHASHMAP_H |