Adam Lesinski | 4452e13 | 2016-10-12 07:47:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROIDFW_ATTRIBUTERESOLUTION_H |
| 18 | #define ANDROIDFW_ATTRIBUTERESOLUTION_H |
| 19 | |
| 20 | #include <androidfw/ResourceTypes.h> |
| 21 | |
| 22 | namespace android { |
| 23 | |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 24 | // Offsets into the outValues array populated by the methods below. outValues is a uint32_t |
| 25 | // array, but each logical element takes up 6 uint32_t-sized physical elements. |
| 26 | enum { |
| 27 | STYLE_NUM_ENTRIES = 6, |
| 28 | STYLE_TYPE = 0, |
| 29 | STYLE_DATA = 1, |
| 30 | STYLE_ASSET_COOKIE = 2, |
| 31 | STYLE_RESOURCE_ID = 3, |
| 32 | STYLE_CHANGING_CONFIGURATIONS = 4, |
| 33 | STYLE_DENSITY = 5 |
| 34 | }; |
| 35 | |
Adam Lesinski | 4452e13 | 2016-10-12 07:47:28 -0700 | [diff] [blame] | 36 | // These are all variations of the same method. They each perform the exact same operation, |
| 37 | // but on various data sources. I *think* they are re-written to avoid an extra branch |
| 38 | // in the inner loop, but after one branch miss (some pointer != null), the branch predictor should |
| 39 | // predict the rest of the iterations' branch correctly. |
| 40 | // TODO(adamlesinski): Run performance tests against these methods and a new, single method |
| 41 | // that uses all the sources and branches to the right ones within the inner loop. |
| 42 | |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 43 | bool ResolveAttrs(ResTable::Theme* theme, uint32_t def_style_attr, uint32_t def_style_res, |
| 44 | uint32_t* src_values, size_t src_values_length, uint32_t* attrs, |
| 45 | size_t attrs_length, uint32_t* out_values, uint32_t* out_indices); |
Adam Lesinski | 4452e13 | 2016-10-12 07:47:28 -0700 | [diff] [blame] | 46 | |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 47 | bool ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr, |
| 48 | uint32_t def_style_res, uint32_t* attrs, size_t attrs_length, uint32_t* out_values, |
| 49 | uint32_t* out_indices); |
Adam Lesinski | 4452e13 | 2016-10-12 07:47:28 -0700 | [diff] [blame] | 50 | |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 51 | bool RetrieveAttributes(const ResTable* res, ResXMLParser* xml_parser, uint32_t* attrs, |
| 52 | size_t attrs_length, uint32_t* out_values, uint32_t* out_indices); |
Adam Lesinski | 4452e13 | 2016-10-12 07:47:28 -0700 | [diff] [blame] | 53 | |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 54 | } // namespace android |
Adam Lesinski | 4452e13 | 2016-10-12 07:47:28 -0700 | [diff] [blame] | 55 | |
| 56 | #endif /* ANDROIDFW_ATTRIBUTERESOLUTION_H */ |