egl/sfegltest/src/vgline.cpp
author Gareth Stockwell <gareth.stockwell@accenture.com>
Fri, 22 Oct 2010 22:42:40 +0100
branchbug235_bringup_0
changeset 211 3804ba25b23f
child 215 097e92a68d68
permissions -rw-r--r--
Refactored eglbringuptest to separate EGL and VG code This allows for a more complex demo (e.g. one which includes animated rendering) to be implemented simply by writing a new class derived from CEglRendering, and modifying CWsApp::ConstructL to create an instance of this new class.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     2
// All rights reserved.
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     7
//
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     8
// Initial Contributors:
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    10
//
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    11
// Contributors:
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    12
//
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    13
// Description:
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    14
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    15
#include "vgline.h"
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    16
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    17
CVGLine* CVGLine::NewL(RWindow& aWindow)
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    18
    {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    19
    CVGLine* self = new (ELeave) CVGLine(aWindow);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    20
    CleanupStack::PushL(self);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    21
    self->ConstructL();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    22
    CleanupStack::Pop(self);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    23
    return self;
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    24
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    25
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    26
CVGLine::CVGLine(RWindow& aWindow)
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    27
    :   CEGLRendering(aWindow)
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    28
    {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    29
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    30
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    31
void CVGLine::KhrSetup()
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    32
    {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    33
    static VGubyte const Segments[] =
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    34
        {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    35
        VG_MOVE_TO_ABS,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    36
        VG_LINE_TO_REL,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    37
        VG_CLOSE_PATH
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    38
        };
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    39
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    40
    static VGfloat const Coords[] =
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    41
        {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    42
        110, 35,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    43
        50, 160,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    44
        };
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    45
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    46
    VGfloat strokeColor[4]  = {1.f, 0.f, 0.f, 1.f};
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    47
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    48
    RDebug::Printf("[EBT] CVGLine::KhrSetup vgCreatePaint");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    49
    iVGPaint = vgCreatePaint();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    50
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    51
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    52
    RDebug::Printf("[EBT] CVGLine::KhrSetup vgSetParameterX");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    53
    vgSetParameteri(iVGPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    54
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    55
    vgSetParameterfv(iVGPaint, VG_PAINT_COLOR, 4, strokeColor);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    56
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    57
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    58
    RDebug::Printf("[EBT] CVGLine::KhrSetup vgCreatePath");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    59
    iVGPath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    60
                            VG_PATH_DATATYPE_F,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    61
                            1.0f, // scale
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    62
                            0.0f, // bias
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    63
                            3,    // segmentCapacityHint
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    64
                            4,    // coordCapacityHint
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    65
                            VG_PATH_CAPABILITY_ALL);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    66
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    67
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    68
    RDebug::Printf("[EBT] CVGLine::KhrSetup vgAppendPathData");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    69
    vgAppendPathData(iVGPath, sizeof(Segments), Segments, Coords);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    70
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    71
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    72
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    73
void CVGLine::KhrPaint()
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    74
    {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    75
    RDebug::Printf("[EBT] CVGLine::KhrPaint vgSetPaint");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    76
    vgSetPaint(iVGPaint, VG_STROKE_PATH);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    77
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    78
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    79
    RDebug::Printf("[EBT] CVGLine::KhrPaint vgDrawPath");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    80
    vgDrawPath(iVGPath, VG_STROKE_PATH);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    81
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    82
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    83