graphicscomposition/openwfcompositionengine/common/src/owfattributes.c
branchRCL_3
changeset 164 25ffed67c7ef
parent 163 bbf46f59e123
equal deleted inserted replaced
163:bbf46f59e123 164:25ffed67c7ef
     1 /* Copyright (c) 2009-2010 The Khronos Group Inc.
     1 /* Copyright (c) 2009 The Khronos Group Inc.
     2  * Portions copyright (c) 2009-2010  Nokia Corporation and/or its subsidiary(-ies)
       
     3  *
     2  *
     4  * Permission is hereby granted, free of charge, to any person obtaining a
     3  * Permission is hereby granted, free of charge, to any person obtaining a
     5  * copy of this software and/or associated documentation files (the
     4  * copy of this software and/or associated documentation files (the
     6  * "Materials"), to deal in the Materials without restriction, including
     5  * "Materials"), to deal in the Materials without restriction, including
     7  * without limitation the rights to use, copy, modify, merge, publish,
     6  * without limitation the rights to use, copy, modify, merge, publish,
    33 #include <string.h>
    32 #include <string.h>
    34 #include <math.h>
    33 #include <math.h>
    35 
    34 
    36 #include "owfattributes.h"
    35 #include "owfattributes.h"
    37 #include "owfmemory.h"
    36 #include "owfmemory.h"
    38 #include "owfdebug.h"
       
    39 
    37 
    40 #define OWF_ATTRIB_RANGE_START            (0)
    38 #define OWF_ATTRIB_RANGE_START            (0)
    41 #define OWF_ATTRIB_RANGE_UNINITIALIZED    (-1)
    39 #define OWF_ATTRIB_RANGE_UNINITIALIZED    (-1)
    42 
    40 
    43 static OWFint OWF_Attribute_Commit(OWF_ATTRIBUTE* aAttr, OWFint aDirtyFlag, OWFint aCopyTo,OWFint aCopyFrom);
    41 static OWFint OWF_Attribute_Commit(OWF_ATTRIBUTE* aAttr, OWFint aDirtyFlag, OWFint aCopyTo,OWFint aCopyFrom);
    44  
    42 
    45   /*
    43 /*
    46   This attribute class is not used for WFC element attributes because elements are 
    44  This attribute class is currently only used for context attributes.
    47   completely cloned in the committed scene.
    45  Why isn't it used for element attributes? 
    48   [This class could be replaced with 3 copies of a much simpler writable attributes raw 
    46      - Because elements are completely cloned in the committed scene.
    49   structure with simple data members, and the whole structure copied each commit.] 
    47  [This class could be replaced with 3 copies of a much simpler writable attributes raw 
    50   Normal attribute values have three pointers indexed via an array:
    48  structure with simple data members, and the whole structure copied each commit.] 
    51      COMMITTED_ATTR_VALUE_INDEX:
    49  Normal attribute values have three pointers indexed via an array:
    52          Attribute values used by the scene 
    50     COMMITTED_ATTR_VALUE_INDEX:
    53              - points to named variables directly used by the compositor
    51         Attribute values used by the scene 
    54      WORKING_ATTR_VALUE_INDEX:
    52             - points to named variables directly used by the compositor
    55          Attribute values that may be set by the client, if they are not read-only.
    53     WORKING_ATTR_VALUE_INDEX:
    56      SNAPSHOT_ATTR_VALUE_INDEX
    54         Attribute values that may be set by the client, if they are not read-only.
    57          A copy of the client-set attribute values following a client call to wfcCommit
    55     SNAPSHOT_ATTR_VALUE_INDEX
    58          The copy is then protected against further modification by the client until 
    56         A copy of the client-set attribute values following a client call to wfcCommit
    59          the committed scene is updated and displayed.
    57         The copy is then protected against further modification by the client until 
    60   The Working and Snapshot writable attributes require additional cache storage, 
    58         the committed scene is updated and displayed.
    61   which is managed by the lifetime of the attribute list.
    59  The Working and Snapshot writable attributes require additional cache storage, 
    62   Read-only attributes point all three pointers at the named compositor variables.
    60  which is managed by the lifetime of the attribute list.
    63   Currently, there are relatively few writable attributes so it is reasonable 
    61  Read-only attributes point all three pointers at the named compositor variables.
    64   to individually dynamically allocate each cache. It would be better to allocate 
    62  Currently, there are relatively few writable attributes so it is reasonable 
    65   a single block sized after the attributes have been registered.  
    63  to individually dynamically allocate each cache. It would be better to allocate 
    66   
    64  a single block sized after the attributes have been registered.  
    67   Internal code is expected to read or write to member variables that are abstracted 
       
    68   by read-only attributes. However they must not write directly to member variables 
       
    69   masked by writable attributes after the initial "commit" to working. The code does 
       
    70   not currently use const instances to enforce this behavior.
       
    71  */
    65  */
    72 #define COND_FAIL_NR(ctx, condition, error) \
    66 #define COND_FAIL_NR(ctx, condition, error) \
    73     if (!(condition)) { \
    67     if (!(condition)) { \
    74         if (ctx) { \
    68         if (ctx) { \
    75             (ctx)->last_error = error; \
    69             (ctx)->last_error = error; \
    82         if (ctx) { \
    76         if (ctx) { \
    83             (ctx)->last_error = error; \
    77             (ctx)->last_error = error; \
    84         } \
    78         } \
    85         return r; \
    79         return r; \
    86     }
    80     }
    87 	
       
    88 // NS here means No Set as we are not setting the last_error member of the context.
       
    89 // These are used when we are testing the context itself so setting the last_error
       
    90 // member is itself is an error
       
    91 #define COND_FAIL_NR_NS(condition) \
       
    92     if (!(condition)) { \
       
    93         return; \
       
    94     }
       
    95 
       
    96 #define COND_FAIL_NS(condition, r) \
       
    97     if (!(condition)) { \
       
    98         return r; \
       
    99     }
       
   100 
    81 
   101 #define CHECK_INDEX_NR(ctx, index, error) \
    82 #define CHECK_INDEX_NR(ctx, index, error) \
   102     if (index < (ctx)->range_start || index > (ctx)->range_end) { \
    83     if (index < (ctx)->range_start || index > (ctx)->range_end) { \
   103         (ctx)->last_error = error; \
    84         (ctx)->last_error = error; \
   104         return; \
    85         return; \
   151                          OWFint aStart,
   132                          OWFint aStart,
   152                          OWFint aEnd)
   133                          OWFint aEnd)
   153 {
   134 {
   154     OWF_ATTRIBUTE*          temp = NULL;
   135     OWF_ATTRIBUTE*          temp = NULL;
   155 
   136 
   156     COND_FAIL_NR_NS(aContext);
   137     COND_FAIL_NR(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT);
   157     COND_FAIL_NR(aContext, aEnd >= 0, ATTR_ERROR_INVALID_ARGUMENT);
   138     COND_FAIL_NR(aContext, aEnd >= 0, ATTR_ERROR_INVALID_ARGUMENT);
   158     COND_FAIL_NR(aContext, aEnd >= aStart, ATTR_ERROR_INVALID_ARGUMENT);
   139     COND_FAIL_NR(aContext, aEnd >= aStart, ATTR_ERROR_INVALID_ARGUMENT);
   159 
   140 
   160     aContext->range_start = OWF_ATTRIB_RANGE_START;
   141     aContext->range_start = OWF_ATTRIB_RANGE_START;
   161     aContext->range_end = OWF_ATTRIB_RANGE_UNINITIALIZED;
   142     aContext->range_end = OWF_ATTRIB_RANGE_UNINITIALIZED;
   187 {
   168 {
   188     OWFint                 count = 0;
   169     OWFint                 count = 0;
   189     OWFint                 at = 0;
   170     OWFint                 at = 0;
   190     OWFint                 cache = 0;
   171     OWFint                 cache = 0;
   191 
   172 
   192     COND_FAIL_NR_NS(aContext);
   173     COND_FAIL_NR(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT);
   193     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   174     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   194 
   175 
   195     count = aContext->range_end - aContext->range_start;
   176     count = aContext->range_end - aContext->range_start;
   196     for (at = 0; at <= count; at++) {
   177     for (at = 0; at <= count; at++) {
   197 
       
   198         OWF_ATTRIBUTE* attr = &aContext->attributes[at];
   178         OWF_ATTRIBUTE* attr = &aContext->attributes[at];
   199         if (!attr->attr_info.readonly)
   179         if (!attr->attr_info.readonly)
   200             {
   180             {
   201             for (cache=0;cache<NUM_ATTR_VALUE_COPIES;cache++)
   181             for (cache=0;cache<NUM_ATTR_VALUE_COPIES;cache++)
   202                 {
   182                 {
   247     OWF_ATTRIBUTE*          attr = NULL;
   227     OWF_ATTRIBUTE*          attr = NULL;
   248     void*                   cache = NULL;
   228     void*                   cache = NULL;
   249     OWFint                  itemSize;
   229     OWFint                  itemSize;
   250     OWFint                  arraySize;
   230     OWFint                  arraySize;
   251     OWFint                  copy;
   231     OWFint                  copy;
   252     OWFint                  index;
   232     OWFint                  index = aName - aContext->range_start;
   253 	
   233 
   254 	COND_FAIL_NR_NS(aContext);
   234     COND_FAIL_NR(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT);
   255 	CHECK_INDEX_NR(aContext, aName, ATTR_ERROR_INVALID_ATTRIBUTE);
   235     CHECK_INDEX_NR(aContext, aName, ATTR_ERROR_INVALID_ATTRIBUTE);
   256     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   236     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   257     COND_FAIL_NR(aContext, aLength < MAX_ATTR_LENGTH, ATTR_ERROR_CANT_HANDLE);
   237     COND_FAIL_NR(aContext, aLength < MAX_ATTR_LENGTH, ATTR_ERROR_CANT_HANDLE);
   258     COND_FAIL_NR(aContext, aType != AT_UNDEFINED, ATTR_ERROR_INVALID_ARGUMENT);
   238     COND_FAIL_NR(aContext, aType != AT_UNDEFINED, ATTR_ERROR_INVALID_ARGUMENT);
   259 	
       
   260 	index = aName - aContext->range_start;
       
   261 
   239 
   262     attr = &aContext->attributes[index];
   240     attr = &aContext->attributes[index];
   263     
   241     
   264     memset(attr, 0, sizeof(OWF_ATTRIBUTE));
   242     memset(attr, 0, sizeof(OWF_ATTRIBUTE));
   265 
   243     
   266     /* when allocin', size DOES matter */
   244     /* when allocin', size DOES matter */
       
   245     
   267     if (aType == AT_INTEGER || aType == AT_BOOLEAN) {
   246     if (aType == AT_INTEGER || aType == AT_BOOLEAN) {
   268         itemSize = sizeof(OWFint);
   247         itemSize = sizeof(OWFint);
   269     } else {
   248     } else {
   270         itemSize = sizeof(OWFfloat);
   249         itemSize = sizeof(OWFfloat);
   271     }
   250     }
   272     arraySize=itemSize*aLength;
   251     arraySize=itemSize*aLength;
   273 
   252     
   274     /* don't allocate cache for read-only 'butes */
   253     /* don't allocate cache for read-only 'butes */
   275     attr->attr_info.type        = aType;
   254     attr->attr_info.type        = aType;
   276     attr->attr_info.length      = aLength;
   255     attr->attr_info.length      = aLength;
   277     attr->attr_info.readonly    = aRdOnly;
   256     attr->attr_info.readonly    = aRdOnly;
   278     attr->attr_info.size        = itemSize;
   257     attr->attr_info.size        = itemSize;
   296                 cache = xalloc(arraySize,1);
   275                 cache = xalloc(arraySize,1);
   297                 COND_FAIL_NR(aContext, NULL != cache, ATTR_ERROR_NO_MEMORY);
   276                 COND_FAIL_NR(aContext, NULL != cache, ATTR_ERROR_NO_MEMORY);
   298                 attr->attr_value[copy].gen_ptr = cache;
   277                 attr->attr_value[copy].gen_ptr = cache;
   299                 }
   278                 }
   300              }
   279              }
       
   280         OWF_Attribute_Commit(attr,1,
       
   281                 WORKING_ATTR_VALUE_INDEX,COMMITTED_ATTR_VALUE_INDEX);
   301        }
   282        }
       
   283 
       
   284 
       
   285 
       
   286     
   302 
   287 
   303     SET_ERROR(aContext, ATTR_ERROR_NONE);
   288     SET_ERROR(aContext, ATTR_ERROR_NONE);
   304 
   289 
   305 }
   290 }
   306 
   291 
   435 {
   420 {
   436     OWFint                  index = 0;
   421     OWFint                  index = 0;
   437     OWF_ATTRIBUTE*          attr = 0;
   422     OWF_ATTRIBUTE*          attr = 0;
   438     OWFint                  result = 0;
   423     OWFint                  result = 0;
   439 
   424 
   440     COND_FAIL_NS(aContext, 0); 
   425     COND_FAIL(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT, 0);
   441 	COND_FAIL(aContext,
   426     CHECK_BAD(aContext, aName, 0);
       
   427     COND_FAIL(aContext,
   442               aContext->attributes,
   428               aContext->attributes,
   443               ATTR_ERROR_INVALID_CONTEXT,
   429               ATTR_ERROR_INVALID_CONTEXT,
   444               0);
   430               0);
   445     CHECK_BAD(aContext, aName, 0);
       
   446 
       
   447 
   431 
   448     index = aName - aContext->range_start;
   432     index = aName - aContext->range_start;
   449     attr = &aContext->attributes[index];
   433     attr = &aContext->attributes[index];
   450 
   434 
   451     COND_FAIL(aContext,
   435     COND_FAIL(aContext,
   508 {
   492 {
   509     OWFint                 index = 0;
   493     OWFint                 index = 0;
   510     OWF_ATTRIBUTE*          attr = NULL;
   494     OWF_ATTRIBUTE*          attr = NULL;
   511     OWFfloat                result = 0.f;
   495     OWFfloat                result = 0.f;
   512 
   496 
   513     COND_FAIL_NS(aContext, 0);
   497     COND_FAIL(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT, 0);
       
   498     CHECK_BAD(aContext, aName, 0);
   514     COND_FAIL(aContext,
   499     COND_FAIL(aContext,
   515               aContext->attributes,
   500               aContext->attributes,
   516               ATTR_ERROR_INVALID_CONTEXT,
   501               ATTR_ERROR_INVALID_CONTEXT,
   517               0);
   502               0);
   518     CHECK_BAD(aContext, aName, 0);
       
   519 
       
   520 
   503 
   521     index = aName - aContext->range_start;
   504     index = aName - aContext->range_start;
   522     attr = &aContext->attributes[index];
   505     attr = &aContext->attributes[index];
   523 
   506 
   524     COND_FAIL(aContext,
   507     COND_FAIL(aContext,
   567 {
   550 {
   568     OWFint                 index = 0;
   551     OWFint                 index = 0;
   569     OWF_ATTRIBUTE*          attr = NULL;
   552     OWF_ATTRIBUTE*          attr = NULL;
   570     OWFint                 count = 0;
   553     OWFint                 count = 0;
   571 
   554 
   572     COND_FAIL_NS(aContext, 0);
   555     COND_FAIL(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT, 0);
       
   556     CHECK_BAD(aContext, aName, 0);
   573     COND_FAIL(aContext,
   557     COND_FAIL(aContext,
   574               aContext->attributes,
   558               aContext->attributes,
   575               ATTR_ERROR_INVALID_CONTEXT,
   559               ATTR_ERROR_INVALID_CONTEXT,
   576               0);
   560               0);
   577     CHECK_BAD(aContext, aName, 0);
       
   578 
       
   579 
   561 
   580     index = aName - aContext->range_start;
   562     index = aName - aContext->range_start;
   581     attr = &aContext->attributes[index];
   563     attr = &aContext->attributes[index];
   582 
   564 
   583     COND_FAIL(aContext,
   565     COND_FAIL(aContext,
   638 {
   620 {
   639     OWFint                 index = 0;
   621     OWFint                 index = 0;
   640     OWF_ATTRIBUTE*          attr = NULL;
   622     OWF_ATTRIBUTE*          attr = NULL;
   641     OWFint                 count = 0;
   623     OWFint                 count = 0;
   642 
   624 
   643     COND_FAIL_NS(aContext, 0);
   625     COND_FAIL(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT, 0);
       
   626     CHECK_BAD(aContext, aName, 0);
   644     COND_FAIL(aContext,
   627     COND_FAIL(aContext,
   645               aContext->attributes,
   628               aContext->attributes,
   646               ATTR_ERROR_INVALID_CONTEXT,
   629               ATTR_ERROR_INVALID_CONTEXT,
   647               0);
   630               0);
   648     CHECK_BAD(aContext, aName, 0);
       
   649 
       
   650 
   631 
   651     index = aName - aContext->range_start;
   632     index = aName - aContext->range_start;
   652     attr = &aContext->attributes[index];
   633     attr = &aContext->attributes[index];
   653 
   634 
   654     COND_FAIL(aContext,
   635     COND_FAIL(aContext,
   711                         OWFint aValue)
   692                         OWFint aValue)
   712 {
   693 {
   713     OWFint                 index = 0;
   694     OWFint                 index = 0;
   714     OWF_ATTRIBUTE*          attr = NULL;
   695     OWF_ATTRIBUTE*          attr = NULL;
   715 
   696 
   716     COND_FAIL_NR_NS(aContext);
   697     COND_FAIL_NR(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT);
       
   698     CHECK_BAD_NR(aContext, aName);
   717     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   699     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   718     CHECK_BAD_NR(aContext, aName);
       
   719 
       
   720 
   700 
   721     index = aName - aContext->range_start;
   701     index = aName - aContext->range_start;
   722     attr = &aContext->attributes[index];
   702     attr = &aContext->attributes[index];
   723 
   703 
   724     COND_FAIL_NR(aContext,
   704     COND_FAIL_NR(aContext,
   764                         OWFfloat aValue)
   744                         OWFfloat aValue)
   765 {
   745 {
   766     OWFint                 index = 0;
   746     OWFint                 index = 0;
   767     OWF_ATTRIBUTE*          attr = NULL;
   747     OWF_ATTRIBUTE*          attr = NULL;
   768 
   748 
   769     COND_FAIL_NR_NS(aContext);
   749     COND_FAIL_NR(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT);
       
   750     CHECK_BAD_NR(aContext, aName);
   770     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   751     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   771     CHECK_BAD_NR(aContext, aName);
       
   772 
       
   773 
   752 
   774     index = aName - aContext->range_start;
   753     index = aName - aContext->range_start;
   775     attr = &aContext->attributes[index];
   754     attr = &aContext->attributes[index];
   776 
   755 
   777     COND_FAIL_NR(aContext,
   756     COND_FAIL_NR(aContext,
   838 {
   817 {
   839     OWFint                 index = 0;
   818     OWFint                 index = 0;
   840     OWF_ATTRIBUTE*          attr = NULL;
   819     OWF_ATTRIBUTE*          attr = NULL;
   841     OWFint                 count = 0;
   820     OWFint                 count = 0;
   842 
   821 
   843     COND_FAIL_NR_NS(aContext);
   822     COND_FAIL_NR(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT);
   844     COND_FAIL_NR(aContext, aValue, ATTR_ERROR_INVALID_ARGUMENT);
   823     COND_FAIL_NR(aContext, aValue, ATTR_ERROR_INVALID_ARGUMENT);
   845     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   824     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   846     CHECK_BAD_NR(aContext, aName);
   825     CHECK_BAD_NR(aContext, aName);
   847 
   826 
   848     index = aName - aContext->range_start;
   827     index = aName - aContext->range_start;
   907 {
   886 {
   908     OWFint                 index = 0;
   887     OWFint                 index = 0;
   909     OWF_ATTRIBUTE*          attr = NULL;
   888     OWF_ATTRIBUTE*          attr = NULL;
   910     OWFint                 count = 0;
   889     OWFint                 count = 0;
   911 
   890 
   912     COND_FAIL_NR_NS(aContext);
   891     COND_FAIL_NR(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT);
   913     COND_FAIL_NR(aContext, aValue, ATTR_ERROR_INVALID_ARGUMENT);
   892     COND_FAIL_NR(aContext, aValue, ATTR_ERROR_INVALID_ARGUMENT);
   914     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   893     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   915     CHECK_BAD_NR(aContext, aName);
   894     CHECK_BAD_NR(aContext, aName);
   916 
   895 
   917     index = aName - aContext->range_start;
   896     index = aName - aContext->range_start;
   964 static OWFint OWF_Attribute_Commit(OWF_ATTRIBUTE* aAttr, 
   943 static OWFint OWF_Attribute_Commit(OWF_ATTRIBUTE* aAttr, 
   965                             OWFint aDirtyFlag, 
   944                             OWFint aDirtyFlag, 
   966                             OWFint aCopyTo,
   945                             OWFint aCopyTo,
   967                             OWFint aCopyFrom )
   946                             OWFint aCopyFrom )
   968     {
   947     {
   969 	OWF_ASSERT(aCopyTo >= 0);
       
   970 	OWF_ASSERT(aCopyTo < NUM_ATTR_VALUE_COPIES);
       
   971 	OWF_ASSERT(aCopyFrom >= 0);
       
   972 	OWF_ASSERT(aCopyFrom < NUM_ATTR_VALUE_COPIES);
       
   973     /* if type is undefined, it means there're gaps in the attribute
   948     /* if type is undefined, it means there're gaps in the attribute
   974        range (e.g. reservations for future use and such.) ignore them. */
   949        range (e.g. reservations for future use and such.) ignore them. */
   975     if (aAttr->attr_info.type != AT_UNDEFINED && aDirtyFlag) 
   950     if (aAttr->attr_info.type != AT_UNDEFINED && aDirtyFlag) 
   976         {
   951         {
   977         /* poor-man's commit */
   952         /* poor-man's commit */
   984         {
   959         {
   985         return aDirtyFlag;
   960         return aDirtyFlag;
   986         }
   961         }
   987     }
   962     }
   988 
   963 
   989 
       
   990 OWF_API_CALL void
   964 OWF_API_CALL void
   991 OWF_AttributeList_Commit(OWF_ATTRIBUTE_LIST* aContext,
   965 OWF_AttributeList_Commit(OWF_ATTRIBUTE_LIST* aContext,
   992                      OWFint aStart,
   966                      OWFint aStart,
   993                      OWFint aEnd,
   967                      OWFint aEnd,
   994 		     OWFint aCopyTo )
   968                      OWFint aCopyTo )
   995 {
   969 {
   996     OWFint                 index = 0;
   970     OWFint                 index = 0;
   997     /* Attribute commit works like the element list commit
   971     /* Attribute commit works like the element list commit
   998      * by forward-copying the "working" attributes to the snapshot  
   972      * by forward-copying the "working" attributes to the snapshot  
   999      * during client invoked commit,
   973      * during client invoked commit,
  1000      * then copying the snapshot to the commited scene during the docommit job.
   974      * then copying the snapshot to the commited scene during the docommit job.
  1001      * This requires the same wait-for-the-previous-commit-job strategy used in the element commit.
   975      * This requires the same wait-for-the-previous-commit-job strategy used in the element commit.
  1002      * Could in future use copy-back technique to avoid having to wait substantially, 
   976      * Could in future use copy-back technique to avoid having to wait substantially, 
  1003      * in which case the index of the working attribute set would switch after each invoked commit,
   977      * in which case the index of the working attribute set would switch after each invoked commit,
  1004      * instead of being a constant.
   978      * instead of being a constant.
  1005      *
       
  1006      * The same number of copies would still need to take place  
   979      * The same number of copies would still need to take place  
  1007      * but would not need exclusive access to the list.
   980      * but would not need exclusive access to the list.
  1008      */
   981      */
  1009 
   982     COND_FAIL_NR(aContext, aContext, ATTR_ERROR_INVALID_ARGUMENT);
  1010     COND_FAIL_NR_NS(aContext);
       
  1011     COND_FAIL_NR(aContext, aStart <= aEnd, ATTR_ERROR_INVALID_ARGUMENT);
   983     COND_FAIL_NR(aContext, aStart <= aEnd, ATTR_ERROR_INVALID_ARGUMENT);
  1012     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
   984     COND_FAIL_NR(aContext, aContext->attributes, ATTR_ERROR_INVALID_CONTEXT);
  1013     CHECK_BAD_NR(aContext, aStart);
   985     CHECK_BAD_NR(aContext, aStart);
  1014     CHECK_BAD_NR(aContext, aEnd);
   986     CHECK_BAD_NR(aContext, aEnd);
  1015 
   987 
       
   988 
  1016     switch (aCopyTo)
   989     switch (aCopyTo)
  1017         {
   990         {
  1018         case COMMITTED_ATTR_VALUE_INDEX: /* Used in composition thread to set displayed scene attributes */
   991         case COMMITTED_ATTR_VALUE_INDEX: //Used in composition thread to set displayed scene attributes 
  1019             for (index = aStart; index <= aEnd; index++) 
   992             for (index = aStart; index <= aEnd; index++) 
  1020                 {
   993                 {
  1021                 OWF_ATTRIBUTE* attr = &aContext->attributes[index - aContext->range_start];
   994                 OWF_ATTRIBUTE* attr = &aContext->attributes[index - aContext->range_start];
  1022                 attr->attr_info.dirtysnapshot=
   995                 attr->attr_info.dirtysnapshot=
  1023                     OWF_Attribute_Commit(attr,attr->attr_info.dirtysnapshot,
   996                     OWF_Attribute_Commit(attr,attr->attr_info.dirtysnapshot,
  1024                             COMMITTED_ATTR_VALUE_INDEX,SNAPSHOT_ATTR_VALUE_INDEX);
   997                             COMMITTED_ATTR_VALUE_INDEX,SNAPSHOT_ATTR_VALUE_INDEX);
  1025                 }
   998                 }
  1026             break;
   999             break;
  1027         case SNAPSHOT_ATTR_VALUE_INDEX: /* Used in API threads to make a snapshot of the client attributes */
  1000         case SNAPSHOT_ATTR_VALUE_INDEX: //Used in API threads to make a snapshot of the client attributes
  1028              for (index = aStart; index <= aEnd; index++) 
  1001              for (index = aStart; index <= aEnd; index++) 
  1029                  {
  1002                  {
  1030                  OWF_ATTRIBUTE* attr = &aContext->attributes[index - aContext->range_start];
  1003                  OWF_ATTRIBUTE* attr = &aContext->attributes[index - aContext->range_start];
  1031                  OWFuint oldDirty=attr->attr_info.dirty;
  1004                  OWFuint oldDirty=attr->attr_info.dirty;
  1032                  attr->attr_info.dirtysnapshot=oldDirty;
  1005                  attr->attr_info.dirtysnapshot=oldDirty;
  1033                  attr->attr_info.dirty=
  1006                  attr->attr_info.dirty=
  1034                      OWF_Attribute_Commit(attr,oldDirty,
  1007                      OWF_Attribute_Commit(attr,oldDirty,
  1035                              SNAPSHOT_ATTR_VALUE_INDEX,WORKING_ATTR_VALUE_INDEX);
  1008                              SNAPSHOT_ATTR_VALUE_INDEX,WORKING_ATTR_VALUE_INDEX);
  1036                  }
  1009                  }
  1037              break;
  1010              break;
  1038         case WORKING_ATTR_VALUE_INDEX:   /* Used in initialisation to copy displayed attributes to client copies */
  1011         case WORKING_ATTR_VALUE_INDEX:   //Used in initialisation to copy displayed attributes to client copies
  1039              for (index = aStart; index <= aEnd; index++) 
  1012              for (index = aStart; index <= aEnd; index++) 
  1040                  {
  1013                  {
  1041                  OWF_ATTRIBUTE* attr = &aContext->attributes[index - aContext->range_start];
  1014                  OWF_ATTRIBUTE* attr = &aContext->attributes[index - aContext->range_start];
  1042                  OWF_Attribute_Commit(attr,!attr->attr_info.readonly,
  1015                  OWF_Attribute_Commit(attr,!attr->attr_info.readonly,
  1043                          WORKING_ATTR_VALUE_INDEX,COMMITTED_ATTR_VALUE_INDEX);
  1016                          WORKING_ATTR_VALUE_INDEX,COMMITTED_ATTR_VALUE_INDEX);
  1044                  }
  1017                  }
  1045              break;
  1018              break;
  1046 	case COMMIT_ATTR_DIRECT_FROM_WORKING: /* Used in WFD to commit new working values directly in 1 step. */
  1019             
  1047             for (index = aStart; index <= aEnd; index++) 
  1020         }
  1048                 {
       
  1049                 OWF_ATTRIBUTE* attr = &aContext->attributes[index - aContext->range_start];
       
  1050                 attr->attr_info.dirty=
       
  1051                     OWF_Attribute_Commit(attr,attr->attr_info.dirty,
       
  1052                             COMMITTED_ATTR_VALUE_INDEX,WORKING_ATTR_VALUE_INDEX);
       
  1053                 }
       
  1054             break;
       
  1055 	default:
       
  1056 			COND_FAIL_NR(aContext, 0, ATTR_ERROR_INVALID_ARGUMENT);
       
  1057           }
       
  1058     
  1021     
  1059     SET_ERROR(aContext, ATTR_ERROR_NONE);
  1022     SET_ERROR(aContext, ATTR_ERROR_NONE);
  1060 }
  1023 }
  1061 
  1024 
  1062 #ifdef __cplusplus
  1025 #ifdef __cplusplus