~linaro-graphics-wg/+junk/spandex-package

« back to all changes in this revision

Viewing changes to sct/common/modules/openvg/sct_openvgcheckextensionaction.c

  • Committer: Alexandros Frantzis
  • Date: 2011-05-04 08:50:52 UTC
  • Revision ID: alexandros.frantzis@linaro.org-20110504085052-88gps4jrg317s6lc
Tags: upstream-1.1.3~git20110502.0ae20368
ImportĀ upstreamĀ versionĀ 1.1.3~git20110502.0ae20368

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Spandex benchmark and test framework.
 
3
 *
 
4
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 
5
 *
 
6
 * Contact: Kari J. Kangas <kari.j.kangas@nokia.com>
 
7
 *
 
8
 *   This framework is free software; you can redistribute it and/or modify it
 
9
 * under the terms of the GNU Lesser General Public License as published by the
 
10
 * Free Software Foundation, version 2.1 of the License.
 
11
 *
 
12
 *   This framework is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
14
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 
15
 * for more details.
 
16
 *
 
17
 *   You should have received a copy of the GNU Lesser General Public License
 
18
 * along with this framework; if not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 */
 
21
 
 
22
#include "sct_openvgcheckextensionaction.h"
 
23
#include "sct_sicommon.h"
 
24
#include "sct_utils.h"
 
25
#include "sct_vg.h"
 
26
 
 
27
#include <stdio.h>
 
28
#include <string.h>
 
29
 
 
30
/*!
 
31
 *
 
32
 *
 
33
 */
 
34
void* sctiCreateOpenVGCheckExtensionActionContext( void* moduleContext, SCTAttributeList* attributes )
 
35
{
 
36
    SCTOpenVGCheckExtensionActionContext*   context;
 
37
 
 
38
    SCT_ASSERT_ALWAYS( moduleContext != NULL );
 
39
    SCT_ASSERT_ALWAYS( attributes != NULL );
 
40
 
 
41
    context = ( SCTOpenVGCheckExtensionActionContext* )( siCommonMemoryAlloc( NULL, sizeof( SCTOpenVGCheckExtensionActionContext ) ) );
 
42
    if( context == NULL )
 
43
    {
 
44
        SCT_LOG_ERROR( "Allocation failed in CheckExtension@OpenVG action context creation." );
 
45
        return NULL;
 
46
    }
 
47
    memset( context, 0, sizeof( SCTOpenVGCheckExtensionActionContext ) );
 
48
 
 
49
    if( sctiParseOpenVGCheckExtensionActionAttributes( &( context->data ), attributes ) == SCT_FALSE )
 
50
    {
 
51
        sctiDestroyOpenVGCheckExtensionActionContext( context );
 
52
        return NULL;
 
53
    }
 
54
 
 
55
    return context;
 
56
}
 
57
 
 
58
/*!
 
59
 *
 
60
 *
 
61
 */
 
62
void sctiDestroyOpenVGCheckExtensionActionContext( void* context )
 
63
{
 
64
    if( context == NULL )
 
65
    {
 
66
        return;
 
67
    }
 
68
    siCommonMemoryFree( NULL, context );
 
69
}
 
70
 
 
71
/*!
 
72
 *
 
73
 *
 
74
 */
 
75
SCTBoolean sctiOpenVGCheckExtensionActionExecute( SCTAction* action, int frameNumber )
 
76
{
 
77
    SCTOpenVGCheckExtensionActionContext*   context;
 
78
    const char*                             str;
 
79
 
 
80
    SCT_ASSERT_ALWAYS( action != NULL );
 
81
    SCT_ASSERT_ALWAYS( action->context != NULL );
 
82
    SCT_USE_VARIABLE( frameNumber );
 
83
 
 
84
    context = ( SCTOpenVGCheckExtensionActionContext* )( action->context );
 
85
 
 
86
    /* Get VG extension string. */
 
87
    str = ( const char* )( vgGetString( VG_EXTENSIONS ) );
 
88
    if( str == NULL )
 
89
    {
 
90
        SCT_LOG_ERROR( "Getting extension string failed in CheckExtension@OpenVG action execute." );
 
91
        return SCT_FALSE;
 
92
    }
 
93
 
 
94
    if( strstr( str, context->data.extension ) == NULL )
 
95
    {
 
96
        char buf[ 1024 ];
 
97
        sprintf( buf, "Extension %s not found in CheckExtension@OpenVG action execute.", context->data.extension );
 
98
        SCT_LOG_ERROR( buf );
 
99
 
 
100
        return SCT_FALSE;
 
101
    }  
 
102
 
 
103
    return SCT_TRUE;
 
104
}
 
105
 
 
106
/*!
 
107
 *
 
108
 *
 
109
 */
 
110
void sctiOpenVGCheckExtensionActionDestroy( SCTAction* action )
 
111
{
 
112
    SCTOpenVGCheckExtensionActionContext*   context;
 
113
 
 
114
    SCT_ASSERT_ALWAYS( action != NULL );
 
115
 
 
116
    context = ( SCTOpenVGCheckExtensionActionContext* )( action->context );
 
117
 
 
118
    action->context = NULL;
 
119
    sctiDestroyOpenVGCheckExtensionActionContext( context );
 
120
}
 
121