os/graphics/graphicscomposition/openwfcompositionengine/common/include/owfattributes.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/* Copyright (c) 2009 The Khronos Group Inc.
sl@0
     2
 * Portions copyright (c) 2009-2010  Nokia Corporation and/or its subsidiary(-ies)
sl@0
     3
 *
sl@0
     4
 * Permission is hereby granted, free of charge, to any person obtaining a
sl@0
     5
 * copy of this software and/or associated documentation files (the
sl@0
     6
 * "Materials"), to deal in the Materials without restriction, including
sl@0
     7
 * without limitation the rights to use, copy, modify, merge, publish,
sl@0
     8
 * distribute, sublicense, and/or sell copies of the Materials, and to
sl@0
     9
 * permit persons to whom the Materials are furnished to do so, subject to
sl@0
    10
 * the following conditions:
sl@0
    11
 *
sl@0
    12
 * The above copyright notice and this permission notice shall be included
sl@0
    13
 * in all copies or substantial portions of the Materials.
sl@0
    14
 *
sl@0
    15
 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
sl@0
    16
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
sl@0
    17
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
sl@0
    18
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
sl@0
    19
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
sl@0
    20
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
sl@0
    21
 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
sl@0
    22
 */
sl@0
    23
sl@0
    24
#ifndef OWFATTRIBUTES_H_
sl@0
    25
#define OWFATTRIBUTES_H_
sl@0
    26
sl@0
    27
#include "owftypes.h"
sl@0
    28
#include "owfutils.h"
sl@0
    29
sl@0
    30
sl@0
    31
#ifdef __cplusplus
sl@0
    32
extern "C"
sl@0
    33
{
sl@0
    34
#endif
sl@0
    35
sl@0
    36
sl@0
    37
/*!
sl@0
    38
 *  \file Attribute interface
sl@0
    39
 *
sl@0
    40
 *  Attribute interface provides mechanism for controlled reading/writing
sl@0
    41
 *  access of different object properties in WFC and WFD APIs by proxying
sl@0
    42
 *  object instances' properties.
sl@0
    43
 *
sl@0
    44
 */
sl@0
    45
#define RANGE_UNDEFINED     0xFFFFFFFF
sl@0
    46
#define ATTR_LENGTH_BITS    20
sl@0
    47
#define MAX_ATTR_LENGTH     (1 << ATTR_LENGTH_BITS)-1
sl@0
    48
#define NUM_ATTR_VALUE_COPIES 3
sl@0
    49
#define COMMITTED_ATTR_VALUE_INDEX 0
sl@0
    50
#define WORKING_ATTR_VALUE_INDEX 1
sl@0
    51
#define SNAPSHOT_ATTR_VALUE_INDEX 2
sl@0
    52
#define COMMIT_ATTR_DIRECT_FROM_WORKING -1
sl@0
    53
sl@0
    54
typedef enum {
sl@0
    55
    ATTR_ERROR_NONE             = 0,
sl@0
    56
    ATTR_ERROR_NOT_FOUND        = -1,
sl@0
    57
    ATTR_ERROR_ALREADY_IN_USE   = -2,
sl@0
    58
    ATTR_ERROR_INVALID_ATTRIBUTE= -3,
sl@0
    59
    ATTR_ERROR_INVALID_VALUE    = -4,
sl@0
    60
    ATTR_ERROR_INVALID_ARGUMENT = -5,
sl@0
    61
    ATTR_ERROR_INVALID_CONTEXT  = -6,
sl@0
    62
    ATTR_ERROR_NO_MEMORY        = -7,
sl@0
    63
    ATTR_ERROR_INSANE           = -8,
sl@0
    64
    ATTR_ERROR_ACCESS_DENIED    = -9,
sl@0
    65
    ATTR_ERROR_INVALID_TYPE     = -10,
sl@0
    66
    ATTR_ERROR_CANT_HANDLE      = -11
sl@0
    67
} OWF_ATTRIBUTE_LIST_STATUS;
sl@0
    68
sl@0
    69
/* Attribute value element types */
sl@0
    70
typedef enum {
sl@0
    71
    AT_UNDEFINED = 0,
sl@0
    72
    AT_INTEGER = 1,
sl@0
    73
    AT_FLOAT = 2,
sl@0
    74
    AT_BOOLEAN = 3
sl@0
    75
} OWF_ATTRIBUTE_TYPE;
sl@0
    76
sl@0
    77
sl@0
    78
/*
sl@0
    79
 * Attribute information (header)
sl@0
    80
 *
sl@0
    81
 * Dirty field is internal. Do not fiddle with it.
sl@0
    82
 * 
sl@0
    83
 * Comment on use of bitfields: 
sl@0
    84
 * 1: It stops generic use of split dirty flag
sl@0
    85
 * 2: Some compilers will not reorder members to merge length into earier fields.
sl@0
    86
 */
sl@0
    87
typedef struct {
sl@0
    88
    OWFuint                 type: 2;
sl@0
    89
    OWFuint                 dirty: 1;
sl@0
    90
    OWFuint                 dirtysnapshot: 1;
sl@0
    91
    OWFuint                 readonly: 1;
sl@0
    92
    OWFuint                 size;                       /* Size of one primitive */
sl@0
    93
    OWFuint                 length: ATTR_LENGTH_BITS;   /* Number of primitives in vector */
sl@0
    94
} OWF_ATTRIBUTE_INFO;
sl@0
    95
sl@0
    96
/*
sl@0
    97
 * Attribute may be a scalar (1-element) or vector (n-element),
sl@0
    98
 * containing a reference to either integer, boolean or float value(s).
sl@0
    99
 * Attribute type cannot be changed after it has been initialized.
sl@0
   100
 *
sl@0
   101
 * Attributes don't own the data they refer to; attributes only
sl@0
   102
 * control the reading and writing of the data they refer to.
sl@0
   103
 */
sl@0
   104
sl@0
   105
typedef OWFfloat*           OWF_FLOAT_REF;
sl@0
   106
typedef OWFint*             OWF_INT_REF;
sl@0
   107
typedef OWFboolean*         OWF_BOOL_REF;
sl@0
   108
typedef OWFfloat*           OWF_FLOAT_VECTOR_REF;
sl@0
   109
typedef OWFint*             OWF_INT_VECTOR_REF;
sl@0
   110
sl@0
   111
typedef struct {
sl@0
   112
    OWF_ATTRIBUTE_INFO      attr_info;
sl@0
   113
    union {
sl@0
   114
        OWF_INT_REF             int_value;
sl@0
   115
        OWF_FLOAT_REF           float_value;
sl@0
   116
        void*                   gen_ptr;
sl@0
   117
        /*
sl@0
   118
        OWF_INT_VECTOR_REF      int_vector_value;
sl@0
   119
        OWF_FLOAT_VECTOR_REF    float_vector_value;
sl@0
   120
        */
sl@0
   121
    } attr_value[NUM_ATTR_VALUE_COPIES];
sl@0
   122
} OWF_ATTRIBUTE;
sl@0
   123
sl@0
   124
/*
sl@0
   125
 * Attribute list/context. Container for attributes.
sl@0
   126
 *
sl@0
   127
 * One list/context can contain constant number of
sl@0
   128
 * attributes (amount of which is defined at construction
sl@0
   129
 * time)
sl@0
   130
 */
sl@0
   131
typedef struct {
sl@0
   132
    OWFint                  range_start;
sl@0
   133
    OWFint                  range_end;
sl@0
   134
    OWF_ATTRIBUTE*          attributes;
sl@0
   135
    OWF_ATTRIBUTE_LIST_STATUS  last_error;
sl@0
   136
} OWF_ATTRIBUTE_LIST;
sl@0
   137
sl@0
   138
/*
sl@0
   139
 * \brief Initializes attribute context
sl@0
   140
 *
sl@0
   141
 * \param aContext Attribute context to initialize
sl@0
   142
 * \param aStart Attribute range start
sl@0
   143
 * \param aEnd Attribute range end. Must be greater than range start.
sl@0
   144
 *
sl@0
   145
 * \return ERR_INVALID_ARGUMENT
sl@0
   146
 * ERR_NO_MEMORY
sl@0
   147
 */
sl@0
   148
OWF_API_CALL void
sl@0
   149
OWF_AttributeList_Create(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   150
                         OWFint aStart,
sl@0
   151
                         OWFint aEnd);
sl@0
   152
sl@0
   153
/*
sl@0
   154
 * \brief Destroy attribute context and free any resources (memory
sl@0
   155
 * blocks) allocated to it. All attributes are destroyed.
sl@0
   156
 *
sl@0
   157
 * \param aContext Attribute context to destroy
sl@0
   158
 *
sl@0
   159
 * \return ERR_INVALID_ARGUMENT
sl@0
   160
 * ERR_INVALID_CONTEXT
sl@0
   161
 */
sl@0
   162
OWF_API_CALL void
sl@0
   163
OWF_AttributeList_Destroy(OWF_ATTRIBUTE_LIST* aContext);
sl@0
   164
sl@0
   165
/*
sl@0
   166
 * \brief Gets the last error from the attribute.
sl@0
   167
 * Resets the error state.
sl@0
   168
 *
sl@0
   169
 * \return	Error code.
sl@0
   170
 *
sl@0
   171
 */
sl@0
   172
OWF_API_CALL OWF_ATTRIBUTE_LIST_STATUS
sl@0
   173
OWF_AttributeList_GetError(OWF_ATTRIBUTE_LIST* aContext);
sl@0
   174
sl@0
   175
/*
sl@0
   176
 * \brief Intialize integer attribute
sl@0
   177
 *
sl@0
   178
 * \param aContext Attibute context
sl@0
   179
 * \param aName Attribute name
sl@0
   180
 * \param aValue Attribute initial value
sl@0
   181
 * \param aRdOnly Read-only flag
sl@0
   182
 *
sl@0
   183
 * \return ERR_INVALID_ARGUMENT
sl@0
   184
 * ERR_INVALID_ATTRIBUTE
sl@0
   185
 * ERR_INVALID_CONTEXT
sl@0
   186
 */
sl@0
   187
OWF_API_CALL void
sl@0
   188
OWF_Attribute_Initi(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   189
                    OWFint aName,
sl@0
   190
                    OWF_INT_REF aValue,
sl@0
   191
                    OWFboolean aRdOnly);
sl@0
   192
sl@0
   193
/*
sl@0
   194
 * \brief Initialize float attribute
sl@0
   195
 *
sl@0
   196
 * \param aContext Attribute context
sl@0
   197
 * \param aName Attribute name
sl@0
   198
 * \param aValue Initial value for attribute
sl@0
   199
 * \param aRdOnly Read-only flag
sl@0
   200
 *
sl@0
   201
 * \return ERR_INVALID_ARGUMENT
sl@0
   202
 * ERR_INVALID_ATTRIBUTE
sl@0
   203
 * ERR_INVALID_CONTEXT
sl@0
   204
 */
sl@0
   205
OWF_API_CALL void
sl@0
   206
OWF_Attribute_Initf(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   207
                    OWFint aName,
sl@0
   208
                    OWF_FLOAT_REF aValue,
sl@0
   209
                    OWFboolean aRdOnly);
sl@0
   210
sl@0
   211
/*
sl@0
   212
 * \brief Initialize boolean attribute
sl@0
   213
 *
sl@0
   214
 * \param aContext Attribute context
sl@0
   215
 * \param aName Attribute name
sl@0
   216
 * \param aValue Initial value for attribute
sl@0
   217
 * \param aRdOnly Read-only flag
sl@0
   218
 *
sl@0
   219
 * \return ERR_INVALID_ARGUMENT
sl@0
   220
 * ERR_INVALID_ATTRIBUTE
sl@0
   221
 * ERR_INVALID_CONTEXT
sl@0
   222
 */
sl@0
   223
OWF_API_CALL void
sl@0
   224
OWF_Attribute_Initb(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   225
                    OWFint aName,
sl@0
   226
                    OWF_BOOL_REF aValue,
sl@0
   227
                    OWFboolean aRdOnly);
sl@0
   228
sl@0
   229
/*
sl@0
   230
 * \brief Initialize vector attribute
sl@0
   231
 *
sl@0
   232
 * \param aContext Attribute context
sl@0
   233
 * \param aName Attribute name
sl@0
   234
 * \param aLength Attribute (vector) length
sl@0
   235
 * \param aValues Initial value(s) for attribute
sl@0
   236
 * \param aRdOnly Read-only flag
sl@0
   237
 *
sl@0
   238
 * \return ERR_INVALID_ARGUMENT
sl@0
   239
 * ERR_INVALID_ATTRIBUTE
sl@0
   240
 * ERR_INVALID_CONTEXT
sl@0
   241
 * ERR_CANT_HANDLE
sl@0
   242
 */
sl@0
   243
OWF_API_CALL void
sl@0
   244
OWF_Attribute_Initiv(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   245
                     OWFint aName,
sl@0
   246
                     OWFint aLength,
sl@0
   247
                     OWF_INT_VECTOR_REF aValues,
sl@0
   248
                     OWFboolean aRdOnly);
sl@0
   249
sl@0
   250
/*
sl@0
   251
 * \brief Initialize vector attribute
sl@0
   252
 *
sl@0
   253
 * \param aContext Attribute context
sl@0
   254
 * \param aName Attribute name
sl@0
   255
 * \param aLength Attribute (vector) length
sl@0
   256
 * \param aValues Initial value(s) for attributes
sl@0
   257
 * \param aRdOnly Read-only flag
sl@0
   258
 *
sl@0
   259
 * \return
sl@0
   260
 */
sl@0
   261
OWF_API_CALL void
sl@0
   262
OWF_Attribute_Initfv(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   263
                     OWFint aName,
sl@0
   264
                     OWFint aLength,
sl@0
   265
                     OWF_FLOAT_VECTOR_REF aValues,
sl@0
   266
                     OWFboolean aRdOnly);
sl@0
   267
sl@0
   268
/*
sl@0
   269
 * \brief Get attribute integer value.
sl@0
   270
 *
sl@0
   271
 * \param aContext Attribute context
sl@0
   272
 * \param aName Attribute name
sl@0
   273
 *
sl@0
   274
 * \return Attribute integer value (floats are floor()ed). For vector
sl@0
   275
 * attributes the return value will be error ERR_INVALID_TYPE.
sl@0
   276
 * ERR_INVALID_ATTRIBUTE
sl@0
   277
 * ERR_INVALID_CONTEXT
sl@0
   278
 */
sl@0
   279
OWF_API_CALL OWFint
sl@0
   280
OWF_Attribute_GetValuei(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   281
                        OWFint aName);
sl@0
   282
sl@0
   283
/*
sl@0
   284
 * \brief Return boolean attribute value
sl@0
   285
 *
sl@0
   286
 * \param aContext Attribute context
sl@0
   287
 * \param aName Attribute name
sl@0
   288
 *
sl@0
   289
 * \return Attribute value
sl@0
   290
 * ERR_INVALID_ATTRIBUTE
sl@0
   291
 * ERR_INVALID_TYPE
sl@0
   292
 */
sl@0
   293
OWF_API_CALL OWFboolean
sl@0
   294
OWF_Attribute_GetValueb(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   295
                        OWFint aName);
sl@0
   296
sl@0
   297
/*
sl@0
   298
 * \brief Get attribute float value
sl@0
   299
 *
sl@0
   300
 * \param aContext
sl@0
   301
 * \param aName
sl@0
   302
 * \param aValue
sl@0
   303
 *
sl@0
   304
 * \return Attribute
sl@0
   305
 */
sl@0
   306
OWF_API_CALL OWFfloat
sl@0
   307
OWF_Attribute_GetValuef(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   308
                        OWFint aName);
sl@0
   309
sl@0
   310
/*
sl@0
   311
 * \brief
sl@0
   312
 *
sl@0
   313
 * \param aContext
sl@0
   314
 * \param aName
sl@0
   315
 * \param aSize
sl@0
   316
 * \param aValue
sl@0
   317
 *
sl@0
   318
 * \return
sl@0
   319
 */
sl@0
   320
OWF_API_CALL OWFint
sl@0
   321
OWF_Attribute_GetValueiv(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   322
                         OWFint aName,
sl@0
   323
                         OWFint aLength,
sl@0
   324
                         OWFint* aValue);
sl@0
   325
sl@0
   326
/*
sl@0
   327
 * \brief
sl@0
   328
 *
sl@0
   329
 * \param aContext
sl@0
   330
 * \param aName
sl@0
   331
 * \param aSize
sl@0
   332
 * \param aValue
sl@0
   333
 *
sl@0
   334
 * \return
sl@0
   335
 */
sl@0
   336
OWF_API_CALL OWFint
sl@0
   337
OWF_Attribute_GetValuefv(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   338
                         OWFint aName,
sl@0
   339
                         OWFint aLength,
sl@0
   340
                         OWFfloat* aValue);
sl@0
   341
sl@0
   342
/*
sl@0
   343
 * \brief
sl@0
   344
 *
sl@0
   345
 * \param aContext
sl@0
   346
 * \param aName
sl@0
   347
 * \param aValue
sl@0
   348
 *
sl@0
   349
 * \return
sl@0
   350
 */
sl@0
   351
OWF_API_CALL void
sl@0
   352
OWF_Attribute_SetValuei(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   353
                        OWFint aName,
sl@0
   354
                        OWFint aValue);
sl@0
   355
sl@0
   356
/*
sl@0
   357
 * \brief
sl@0
   358
 *
sl@0
   359
 * \param aContext
sl@0
   360
 * \param aName
sl@0
   361
 * \param aValue
sl@0
   362
 *
sl@0
   363
 * \return
sl@0
   364
 */
sl@0
   365
OWF_API_CALL void
sl@0
   366
OWF_Attribute_SetValuef(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   367
                        OWFint aName,
sl@0
   368
                        OWFfloat aValue);
sl@0
   369
sl@0
   370
/*
sl@0
   371
 * \brief
sl@0
   372
 *
sl@0
   373
 * \param
sl@0
   374
 * \param
sl@0
   375
 * \param
sl@0
   376
 *
sl@0
   377
 * \return
sl@0
   378
 */
sl@0
   379
OWF_API_CALL void
sl@0
   380
OWF_Attribute_SetValueb(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   381
                        OWFint aName,
sl@0
   382
                        OWFboolean aValue);
sl@0
   383
sl@0
   384
/*
sl@0
   385
 * \brief
sl@0
   386
 *
sl@0
   387
 * \param
sl@0
   388
 * \param
sl@0
   389
 * \param
sl@0
   390
 *
sl@0
   391
 * \return
sl@0
   392
 */
sl@0
   393
OWF_API_CALL void
sl@0
   394
OWF_Attribute_SetValueiv(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   395
                         OWFint aName,
sl@0
   396
                         OWFint aLength,
sl@0
   397
                         const OWFint* aValue);
sl@0
   398
sl@0
   399
/*
sl@0
   400
 * \brief
sl@0
   401
 *
sl@0
   402
 * \param
sl@0
   403
 * \param
sl@0
   404
 * \param
sl@0
   405
 *
sl@0
   406
 * \return
sl@0
   407
 */
sl@0
   408
OWF_API_CALL void
sl@0
   409
OWF_Attribute_SetValuefv(OWF_ATTRIBUTE_LIST* aContext,
sl@0
   410
                         OWFint aName,
sl@0
   411
                         OWFint aLength,
sl@0
   412
                         const OWFfloat* aValue);
sl@0
   413
sl@0
   414
sl@0
   415
OWF_API_CALL void
sl@0
   416
OWF_AttributeList_Commit(OWF_ATTRIBUTE_LIST* aContext, OWFint aStart, OWFint aEnd, OWFint aCopyTo );
sl@0
   417
sl@0
   418
sl@0
   419
#ifdef __cplusplus
sl@0
   420
}
sl@0
   421
#endif
sl@0
   422
sl@0
   423
#endif /* ATTRIBUTES_H_ */