IOLink IOL_v1.8.0_release
|
View extensions are a way to add new functionnalities for views without breaking the current ABI. If a view support a kind of extension, you can get it to access more information or services. You can get an extension this way:
This may seem a little complicated at first, but the nature of extensions make them this way. Usually shortcuts will be defined in the View
class or its descendants, which will make them transparent for the user.
All classes that inherit from Extension
must define a constant named EXTENSION_ID
that is unique for each extension type, and is used when retrieving an extension from a view.
When choosing the identifier to use with your class, you must look at other defined identifiers to avoid collision. In addition, some ranges are reserved for specific usage:
Currently defined extension identifiers are:
TilingInfoExtension
: 0x1ParallelAccessExtension
: 0x2ViewOriginExtension
: 0x3There is an extension for tiling-related informations called TilingInfoExtension
. It defines multiple services to know the number of tiles, their location, and their topology. You can get this extension using this code:
There is a shortcut in ImageView
that does all the conversion work:
The extension provides the following services:
tile count
- 1, all indices outside this range are undefined and will throw an exception if given as an argument to this method.READ
capability. Indexation rules are the same as tile region
.WRITE
capability. Indexation rules are the same as tile region
.The ParallelAccessExtension
extension provides information about parallelism capabilities of an ImageView. You can get this extension using this code:
There is a shortcut in ImageView
that does all the conversion work:
In order to accelerate processing when handling an ImageView
, you may have to use multi-threading to access your data. However, a given ImageView
instance can have various support for parallel multithreaded operations, and may, or may not be performant when doing so.
In some cases, it can be more efficient to read multiple regions of the ImageView
instance in parallel.
For all these cases, the ParallelAccessExtension
extension provides a set of capabilities:
Warning: In any case a same region of an ImageView should be read and written at the same time, or even written by separated threads. In addition to the risk of race conditions, the result of such operation would be totally unpredictable.
If an ImageView has PARALLEL_READ capability, you can execute parallel reads on separated regions with a likely performance boost.
If an ImageView has PARALLEL_WRITE capability, you can execute parallel writes on separated regions with a likely performance boost.
If a tiled ImageView has PARALLEL_TILE_READ capability, you can execute parallel reads on separated tiles with a likely performance boost.
If a tiled ImageView has PARALLEL_TILE_WRITE capability, you can execute parallel writes on separated tiles with a likely performance boost.
The ViewOriginExtension
extension provides information about the data origin of a view. You can get this extension using this code:
There is a shortcut in View
that does all the conversion work:
Views allow to access data, but they don't give any information about where it comes from. For example, if a view A was "adapted" to create two distinct views B and C. And C is used with another view D to create E, it is not possible to know the connection between these 4 views from the actual interface.
B, and C are created from the same view A.
A, B, C and E share the same data.
D shares data with E only.
With this extension, from any view it is possible to navigate through parents (adapters, proxy...) til the original view(s).
A -> B
A -> C -> E
D -> E
Each view can give information about the origin of its data:
Data origin may also be COMPOSITE
if the view is composed of data from multiple sources, or simply UNKNOWN
when IOLink has no information about the source of the data.
The extension also provides an uid
which allows to identify a view. Sometimes this UID has a value equal to UidGenerator::UNDEFINED_UID
, meaning that the origin of the view is actually unknown and we cannot know if this view is actually related with any other view.
Thanks to this extension, when parsing the parents of different views, it is possible to determine if these views share the same data source. This can be decisive, for example, to allow parallel access on these views.
LIMITATION: As of now, view origin only takes into account 'view' instances as sources of data. Different views created from the same resource, i.e. a file, won't be identified as the same data source, and will have different UIDs