os/graphics/graphicscomposition/openwfcompositionengine/common/include/owfattributes.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicscomposition/openwfcompositionengine/common/include/owfattributes.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,423 @@
1.4 +/* Copyright (c) 2009 The Khronos Group Inc.
1.5 + * Portions copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies)
1.6 + *
1.7 + * Permission is hereby granted, free of charge, to any person obtaining a
1.8 + * copy of this software and/or associated documentation files (the
1.9 + * "Materials"), to deal in the Materials without restriction, including
1.10 + * without limitation the rights to use, copy, modify, merge, publish,
1.11 + * distribute, sublicense, and/or sell copies of the Materials, and to
1.12 + * permit persons to whom the Materials are furnished to do so, subject to
1.13 + * the following conditions:
1.14 + *
1.15 + * The above copyright notice and this permission notice shall be included
1.16 + * in all copies or substantial portions of the Materials.
1.17 + *
1.18 + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1.19 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1.20 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1.21 + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1.22 + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1.23 + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1.24 + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
1.25 + */
1.26 +
1.27 +#ifndef OWFATTRIBUTES_H_
1.28 +#define OWFATTRIBUTES_H_
1.29 +
1.30 +#include "owftypes.h"
1.31 +#include "owfutils.h"
1.32 +
1.33 +
1.34 +#ifdef __cplusplus
1.35 +extern "C"
1.36 +{
1.37 +#endif
1.38 +
1.39 +
1.40 +/*!
1.41 + * \file Attribute interface
1.42 + *
1.43 + * Attribute interface provides mechanism for controlled reading/writing
1.44 + * access of different object properties in WFC and WFD APIs by proxying
1.45 + * object instances' properties.
1.46 + *
1.47 + */
1.48 +#define RANGE_UNDEFINED 0xFFFFFFFF
1.49 +#define ATTR_LENGTH_BITS 20
1.50 +#define MAX_ATTR_LENGTH (1 << ATTR_LENGTH_BITS)-1
1.51 +#define NUM_ATTR_VALUE_COPIES 3
1.52 +#define COMMITTED_ATTR_VALUE_INDEX 0
1.53 +#define WORKING_ATTR_VALUE_INDEX 1
1.54 +#define SNAPSHOT_ATTR_VALUE_INDEX 2
1.55 +#define COMMIT_ATTR_DIRECT_FROM_WORKING -1
1.56 +
1.57 +typedef enum {
1.58 + ATTR_ERROR_NONE = 0,
1.59 + ATTR_ERROR_NOT_FOUND = -1,
1.60 + ATTR_ERROR_ALREADY_IN_USE = -2,
1.61 + ATTR_ERROR_INVALID_ATTRIBUTE= -3,
1.62 + ATTR_ERROR_INVALID_VALUE = -4,
1.63 + ATTR_ERROR_INVALID_ARGUMENT = -5,
1.64 + ATTR_ERROR_INVALID_CONTEXT = -6,
1.65 + ATTR_ERROR_NO_MEMORY = -7,
1.66 + ATTR_ERROR_INSANE = -8,
1.67 + ATTR_ERROR_ACCESS_DENIED = -9,
1.68 + ATTR_ERROR_INVALID_TYPE = -10,
1.69 + ATTR_ERROR_CANT_HANDLE = -11
1.70 +} OWF_ATTRIBUTE_LIST_STATUS;
1.71 +
1.72 +/* Attribute value element types */
1.73 +typedef enum {
1.74 + AT_UNDEFINED = 0,
1.75 + AT_INTEGER = 1,
1.76 + AT_FLOAT = 2,
1.77 + AT_BOOLEAN = 3
1.78 +} OWF_ATTRIBUTE_TYPE;
1.79 +
1.80 +
1.81 +/*
1.82 + * Attribute information (header)
1.83 + *
1.84 + * Dirty field is internal. Do not fiddle with it.
1.85 + *
1.86 + * Comment on use of bitfields:
1.87 + * 1: It stops generic use of split dirty flag
1.88 + * 2: Some compilers will not reorder members to merge length into earier fields.
1.89 + */
1.90 +typedef struct {
1.91 + OWFuint type: 2;
1.92 + OWFuint dirty: 1;
1.93 + OWFuint dirtysnapshot: 1;
1.94 + OWFuint readonly: 1;
1.95 + OWFuint size; /* Size of one primitive */
1.96 + OWFuint length: ATTR_LENGTH_BITS; /* Number of primitives in vector */
1.97 +} OWF_ATTRIBUTE_INFO;
1.98 +
1.99 +/*
1.100 + * Attribute may be a scalar (1-element) or vector (n-element),
1.101 + * containing a reference to either integer, boolean or float value(s).
1.102 + * Attribute type cannot be changed after it has been initialized.
1.103 + *
1.104 + * Attributes don't own the data they refer to; attributes only
1.105 + * control the reading and writing of the data they refer to.
1.106 + */
1.107 +
1.108 +typedef OWFfloat* OWF_FLOAT_REF;
1.109 +typedef OWFint* OWF_INT_REF;
1.110 +typedef OWFboolean* OWF_BOOL_REF;
1.111 +typedef OWFfloat* OWF_FLOAT_VECTOR_REF;
1.112 +typedef OWFint* OWF_INT_VECTOR_REF;
1.113 +
1.114 +typedef struct {
1.115 + OWF_ATTRIBUTE_INFO attr_info;
1.116 + union {
1.117 + OWF_INT_REF int_value;
1.118 + OWF_FLOAT_REF float_value;
1.119 + void* gen_ptr;
1.120 + /*
1.121 + OWF_INT_VECTOR_REF int_vector_value;
1.122 + OWF_FLOAT_VECTOR_REF float_vector_value;
1.123 + */
1.124 + } attr_value[NUM_ATTR_VALUE_COPIES];
1.125 +} OWF_ATTRIBUTE;
1.126 +
1.127 +/*
1.128 + * Attribute list/context. Container for attributes.
1.129 + *
1.130 + * One list/context can contain constant number of
1.131 + * attributes (amount of which is defined at construction
1.132 + * time)
1.133 + */
1.134 +typedef struct {
1.135 + OWFint range_start;
1.136 + OWFint range_end;
1.137 + OWF_ATTRIBUTE* attributes;
1.138 + OWF_ATTRIBUTE_LIST_STATUS last_error;
1.139 +} OWF_ATTRIBUTE_LIST;
1.140 +
1.141 +/*
1.142 + * \brief Initializes attribute context
1.143 + *
1.144 + * \param aContext Attribute context to initialize
1.145 + * \param aStart Attribute range start
1.146 + * \param aEnd Attribute range end. Must be greater than range start.
1.147 + *
1.148 + * \return ERR_INVALID_ARGUMENT
1.149 + * ERR_NO_MEMORY
1.150 + */
1.151 +OWF_API_CALL void
1.152 +OWF_AttributeList_Create(OWF_ATTRIBUTE_LIST* aContext,
1.153 + OWFint aStart,
1.154 + OWFint aEnd);
1.155 +
1.156 +/*
1.157 + * \brief Destroy attribute context and free any resources (memory
1.158 + * blocks) allocated to it. All attributes are destroyed.
1.159 + *
1.160 + * \param aContext Attribute context to destroy
1.161 + *
1.162 + * \return ERR_INVALID_ARGUMENT
1.163 + * ERR_INVALID_CONTEXT
1.164 + */
1.165 +OWF_API_CALL void
1.166 +OWF_AttributeList_Destroy(OWF_ATTRIBUTE_LIST* aContext);
1.167 +
1.168 +/*
1.169 + * \brief Gets the last error from the attribute.
1.170 + * Resets the error state.
1.171 + *
1.172 + * \return Error code.
1.173 + *
1.174 + */
1.175 +OWF_API_CALL OWF_ATTRIBUTE_LIST_STATUS
1.176 +OWF_AttributeList_GetError(OWF_ATTRIBUTE_LIST* aContext);
1.177 +
1.178 +/*
1.179 + * \brief Intialize integer attribute
1.180 + *
1.181 + * \param aContext Attibute context
1.182 + * \param aName Attribute name
1.183 + * \param aValue Attribute initial value
1.184 + * \param aRdOnly Read-only flag
1.185 + *
1.186 + * \return ERR_INVALID_ARGUMENT
1.187 + * ERR_INVALID_ATTRIBUTE
1.188 + * ERR_INVALID_CONTEXT
1.189 + */
1.190 +OWF_API_CALL void
1.191 +OWF_Attribute_Initi(OWF_ATTRIBUTE_LIST* aContext,
1.192 + OWFint aName,
1.193 + OWF_INT_REF aValue,
1.194 + OWFboolean aRdOnly);
1.195 +
1.196 +/*
1.197 + * \brief Initialize float attribute
1.198 + *
1.199 + * \param aContext Attribute context
1.200 + * \param aName Attribute name
1.201 + * \param aValue Initial value for attribute
1.202 + * \param aRdOnly Read-only flag
1.203 + *
1.204 + * \return ERR_INVALID_ARGUMENT
1.205 + * ERR_INVALID_ATTRIBUTE
1.206 + * ERR_INVALID_CONTEXT
1.207 + */
1.208 +OWF_API_CALL void
1.209 +OWF_Attribute_Initf(OWF_ATTRIBUTE_LIST* aContext,
1.210 + OWFint aName,
1.211 + OWF_FLOAT_REF aValue,
1.212 + OWFboolean aRdOnly);
1.213 +
1.214 +/*
1.215 + * \brief Initialize boolean attribute
1.216 + *
1.217 + * \param aContext Attribute context
1.218 + * \param aName Attribute name
1.219 + * \param aValue Initial value for attribute
1.220 + * \param aRdOnly Read-only flag
1.221 + *
1.222 + * \return ERR_INVALID_ARGUMENT
1.223 + * ERR_INVALID_ATTRIBUTE
1.224 + * ERR_INVALID_CONTEXT
1.225 + */
1.226 +OWF_API_CALL void
1.227 +OWF_Attribute_Initb(OWF_ATTRIBUTE_LIST* aContext,
1.228 + OWFint aName,
1.229 + OWF_BOOL_REF aValue,
1.230 + OWFboolean aRdOnly);
1.231 +
1.232 +/*
1.233 + * \brief Initialize vector attribute
1.234 + *
1.235 + * \param aContext Attribute context
1.236 + * \param aName Attribute name
1.237 + * \param aLength Attribute (vector) length
1.238 + * \param aValues Initial value(s) for attribute
1.239 + * \param aRdOnly Read-only flag
1.240 + *
1.241 + * \return ERR_INVALID_ARGUMENT
1.242 + * ERR_INVALID_ATTRIBUTE
1.243 + * ERR_INVALID_CONTEXT
1.244 + * ERR_CANT_HANDLE
1.245 + */
1.246 +OWF_API_CALL void
1.247 +OWF_Attribute_Initiv(OWF_ATTRIBUTE_LIST* aContext,
1.248 + OWFint aName,
1.249 + OWFint aLength,
1.250 + OWF_INT_VECTOR_REF aValues,
1.251 + OWFboolean aRdOnly);
1.252 +
1.253 +/*
1.254 + * \brief Initialize vector attribute
1.255 + *
1.256 + * \param aContext Attribute context
1.257 + * \param aName Attribute name
1.258 + * \param aLength Attribute (vector) length
1.259 + * \param aValues Initial value(s) for attributes
1.260 + * \param aRdOnly Read-only flag
1.261 + *
1.262 + * \return
1.263 + */
1.264 +OWF_API_CALL void
1.265 +OWF_Attribute_Initfv(OWF_ATTRIBUTE_LIST* aContext,
1.266 + OWFint aName,
1.267 + OWFint aLength,
1.268 + OWF_FLOAT_VECTOR_REF aValues,
1.269 + OWFboolean aRdOnly);
1.270 +
1.271 +/*
1.272 + * \brief Get attribute integer value.
1.273 + *
1.274 + * \param aContext Attribute context
1.275 + * \param aName Attribute name
1.276 + *
1.277 + * \return Attribute integer value (floats are floor()ed). For vector
1.278 + * attributes the return value will be error ERR_INVALID_TYPE.
1.279 + * ERR_INVALID_ATTRIBUTE
1.280 + * ERR_INVALID_CONTEXT
1.281 + */
1.282 +OWF_API_CALL OWFint
1.283 +OWF_Attribute_GetValuei(OWF_ATTRIBUTE_LIST* aContext,
1.284 + OWFint aName);
1.285 +
1.286 +/*
1.287 + * \brief Return boolean attribute value
1.288 + *
1.289 + * \param aContext Attribute context
1.290 + * \param aName Attribute name
1.291 + *
1.292 + * \return Attribute value
1.293 + * ERR_INVALID_ATTRIBUTE
1.294 + * ERR_INVALID_TYPE
1.295 + */
1.296 +OWF_API_CALL OWFboolean
1.297 +OWF_Attribute_GetValueb(OWF_ATTRIBUTE_LIST* aContext,
1.298 + OWFint aName);
1.299 +
1.300 +/*
1.301 + * \brief Get attribute float value
1.302 + *
1.303 + * \param aContext
1.304 + * \param aName
1.305 + * \param aValue
1.306 + *
1.307 + * \return Attribute
1.308 + */
1.309 +OWF_API_CALL OWFfloat
1.310 +OWF_Attribute_GetValuef(OWF_ATTRIBUTE_LIST* aContext,
1.311 + OWFint aName);
1.312 +
1.313 +/*
1.314 + * \brief
1.315 + *
1.316 + * \param aContext
1.317 + * \param aName
1.318 + * \param aSize
1.319 + * \param aValue
1.320 + *
1.321 + * \return
1.322 + */
1.323 +OWF_API_CALL OWFint
1.324 +OWF_Attribute_GetValueiv(OWF_ATTRIBUTE_LIST* aContext,
1.325 + OWFint aName,
1.326 + OWFint aLength,
1.327 + OWFint* aValue);
1.328 +
1.329 +/*
1.330 + * \brief
1.331 + *
1.332 + * \param aContext
1.333 + * \param aName
1.334 + * \param aSize
1.335 + * \param aValue
1.336 + *
1.337 + * \return
1.338 + */
1.339 +OWF_API_CALL OWFint
1.340 +OWF_Attribute_GetValuefv(OWF_ATTRIBUTE_LIST* aContext,
1.341 + OWFint aName,
1.342 + OWFint aLength,
1.343 + OWFfloat* aValue);
1.344 +
1.345 +/*
1.346 + * \brief
1.347 + *
1.348 + * \param aContext
1.349 + * \param aName
1.350 + * \param aValue
1.351 + *
1.352 + * \return
1.353 + */
1.354 +OWF_API_CALL void
1.355 +OWF_Attribute_SetValuei(OWF_ATTRIBUTE_LIST* aContext,
1.356 + OWFint aName,
1.357 + OWFint aValue);
1.358 +
1.359 +/*
1.360 + * \brief
1.361 + *
1.362 + * \param aContext
1.363 + * \param aName
1.364 + * \param aValue
1.365 + *
1.366 + * \return
1.367 + */
1.368 +OWF_API_CALL void
1.369 +OWF_Attribute_SetValuef(OWF_ATTRIBUTE_LIST* aContext,
1.370 + OWFint aName,
1.371 + OWFfloat aValue);
1.372 +
1.373 +/*
1.374 + * \brief
1.375 + *
1.376 + * \param
1.377 + * \param
1.378 + * \param
1.379 + *
1.380 + * \return
1.381 + */
1.382 +OWF_API_CALL void
1.383 +OWF_Attribute_SetValueb(OWF_ATTRIBUTE_LIST* aContext,
1.384 + OWFint aName,
1.385 + OWFboolean aValue);
1.386 +
1.387 +/*
1.388 + * \brief
1.389 + *
1.390 + * \param
1.391 + * \param
1.392 + * \param
1.393 + *
1.394 + * \return
1.395 + */
1.396 +OWF_API_CALL void
1.397 +OWF_Attribute_SetValueiv(OWF_ATTRIBUTE_LIST* aContext,
1.398 + OWFint aName,
1.399 + OWFint aLength,
1.400 + const OWFint* aValue);
1.401 +
1.402 +/*
1.403 + * \brief
1.404 + *
1.405 + * \param
1.406 + * \param
1.407 + * \param
1.408 + *
1.409 + * \return
1.410 + */
1.411 +OWF_API_CALL void
1.412 +OWF_Attribute_SetValuefv(OWF_ATTRIBUTE_LIST* aContext,
1.413 + OWFint aName,
1.414 + OWFint aLength,
1.415 + const OWFfloat* aValue);
1.416 +
1.417 +
1.418 +OWF_API_CALL void
1.419 +OWF_AttributeList_Commit(OWF_ATTRIBUTE_LIST* aContext, OWFint aStart, OWFint aEnd, OWFint aCopyTo );
1.420 +
1.421 +
1.422 +#ifdef __cplusplus
1.423 +}
1.424 +#endif
1.425 +
1.426 +#endif /* ATTRIBUTES_H_ */