Beispiel #1
0
void createRadial()
{
  VGfloat stops[] = {
    0.0, 1.0, 0.0, 0.0, 1,
    0.5, 0.0, 1.0, 0.0, 1,
    1.0, 0.0, 0.0, 1.0, 1};
  
  VGint numstops = sizeof(stops) / sizeof(VGfloat);
  
  VGfloat radial[5];
  radial[0] = cx;
  radial[1] = cy;
  radial[2] = fx;
  radial[3] = fy;
  radial[4] = r;
  
  vgSetParameteri(radialFill, VG_PAINT_COLOR_RAMP_SPREAD_MODE, spread[sindex]);
  vgSetParameteri(radialFill, VG_PAINT_TYPE, VG_PAINT_TYPE_RADIAL_GRADIENT);
  vgSetParameterfv(radialFill, VG_PAINT_RADIAL_GRADIENT, 5, radial);
  vgSetParameterfv(radialFill, VG_PAINT_COLOR_RAMP_STOPS, numstops, stops);

  vgClearPath(center, VG_PATH_CAPABILITY_ALL);
  createCross(center, cx, cy);
  
  vgClearPath(focus, VG_PATH_CAPABILITY_ALL);
  vguEllipse(focus, fx, fy, 8,8);
  
  vgClearPath(radius, VG_PATH_CAPABILITY_ALL);
  vguEllipse(radius, cx, cy, r*2, r*2);
}
Beispiel #2
0
void loadTiger()
{
  int i;
  VGPath temp;
  
  temp = testCreatePath();  
  tigerPaths = (VGPath*)malloc(pathCount * sizeof(VGPath));
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgTranslate(-100,100);
  vgScale(1,-1);
  
  for (i=0; i<pathCount; ++i) {
    
    vgClearPath(temp, VG_PATH_CAPABILITY_ALL);
    vgAppendPathData(temp, commandCounts[i],
                     commandArrays[i], dataArrays[i]);
    
    tigerPaths[i] = testCreatePath();
    vgTransformPath(tigerPaths[i], temp);
  }
  
  tigerStroke = vgCreatePaint();
  tigerFill = vgCreatePaint();
  vgSetPaint(tigerStroke, VG_STROKE_PATH);
  vgSetPaint(tigerFill, VG_FILL_PATH);
  vgLoadIdentity();
  vgDestroyPath(temp);
}
Beispiel #3
0
NwSvgFigure::~NwSvgFigure()
{
	if( VG_INVALID_HANDLE != m_path )
	{
		vgClearPath(m_path, VG_PATH_CAPABILITY_ALL);
		vgDestroyPath(m_path);
	}
}
Beispiel #4
0
void NwSvgFigure::clearSvgFigure()
{
	if( VG_INVALID_HANDLE != m_path )
	{
		vgClearPath(m_path, VG_PATH_CAPABILITY_ALL);
		vgDestroyPath(m_path);
		m_path = VG_INVALID_HANDLE;
	}
	m_bHasData	= false;
}
void PlatformPathOpenVG::clear()
{
    makeCompatibleContextCurrent();

    vgClearPath(m_vgPath, WEBKIT_VG_PATH_CAPABILITIES);
    ASSERT_VG_NO_ERROR();

    m_subpathStartPoint.setX(0);
    m_subpathStartPoint.setY(0);
    m_currentPoint = m_subpathStartPoint;
}
Beispiel #6
0
void NwSvgFigure::draw()
{
	setAttribute();
	VGbitfield paintModes = 0;
	if( STROKE_NONE != m_svgAttribute.nStrokeType )
	{
		paintModes |= VG_STROKE_PATH;
	}
	if( FILL_NONE != m_svgAttribute.nFillType )
	{
		paintModes |= VG_FILL_PATH;
	}
	vgDrawPath(m_path, paintModes);
	//vgFinish();
	vgClearPath(m_path, VG_PATH_CAPABILITY_ALL);
}
 void clear() {
   vgClearPath(path_, VG_PATH_CAPABILITY_ALL);
   assert(!vgGetError());
 }
Beispiel #8
0
void createMorph()
{
  vgClearPath(iMorph, VG_PATH_CAPABILITY_ALL);
  vgInterpolatePath(iMorph, iApple, iPear, amount);
}
Beispiel #9
0
TInt CNVGCSIcon::DoDrawL(const TSize aSize)
    {
    TInt ret = KErrNone;
    
    vgSetPaint(iFillPaint,   VG_FILL_PATH);
    vgSetPaint(iStrokePaint, VG_STROKE_PATH);
    iLastFillPaintColor     = 0;
    iLastStrkePaintColor    = 0;
    iLastFillPaintType      = 0;
    iLastStrokePaintType    = 0;

    VGfloat lCurrentPathMatrix[9];
    vgGetMatrix(lCurrentPathMatrix);
    
    vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);  
    vgLoadMatrix(lCurrentPathMatrix);
    SetRotation();
#ifdef __MIRROR_    
    vgScale(1.0f, -1.0f);
    vgTranslate(0, (VGfloat)(-aSize.iHeight) );
#endif
    
    SetViewBoxToViewTransformationL(aSize);
   
    
    vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
    
    VGfloat currentMatrix[9];
    
    vgGetMatrix(currentMatrix);
    
    iNVGIconData->BeginRead();

    while (!iNVGIconData->EOF())
        {
        switch (iNVGIconData->ReadInt32L())
            {
            case EPath:
                {
                VGPath path = (VGPath)iNVGIconData->ReadInt32L();
                VGPaintMode paintMode = (VGPaintMode)iNVGIconData->ReadInt32L();

                if (path == VG_INVALID_HANDLE)
                    {
                    vgDrawPath(iPath, paintMode);
                    }
                else
                    {
                    vgDrawPath(path, paintMode);
                    }
                
                break;
                }
            case EPathData:
                {                
                if (iPath != VG_INVALID_HANDLE)
                    {
                    VGint numSegments;
                    VGubyte * pathSegments = 0;
                    VGubyte * pathData = 0;
                    
                    numSegments  = iNVGIconData->ReadInt32L();
                    pathSegments = new (ELeave) VGubyte[numSegments];
                    CleanupStack::PushL(TCleanupItem(CleanupArray, pathSegments));
                    if (pathSegments)
                        {
                        iNVGIconData->ReadL(pathSegments, numSegments);
                        VGint coordinateCount = iNVGIconData->ReadInt32L();
                        pathData = new (ELeave) VGubyte[coordinateCount * 4];
                        if (pathData)
                            {
                            CleanupStack::PushL(TCleanupItem(CleanupArray, pathData));
                            iNVGIconData->ReadL(pathData, coordinateCount * 4);
                            vgClearPath(iPath, VG_PATH_CAPABILITY_APPEND_TO);
                            vgAppendPathData(iPath, numSegments, pathSegments, pathData);
                            CleanupStack::PopAndDestroy();
                            }                        
                        }
                    CleanupStack::PopAndDestroy();
                    }
                break;
                }
            case EPaint:
                {
                DrawPaintL(iFillPaint, VG_MATRIX_FILL_PAINT_TO_USER, iLastFillPaintType, iLastFillPaintColor, VG_FILL_PATH);
                break;
                }
            case EColorRamp:
                {
                iNVGIconData->ReadInt32L();
                break;
                }
            case ETransform:
                {
                TInt flag;
                VGfloat transformMatrix[9];
                
                TPtr8 tmPtr((TUint8 *)transformMatrix, 9 * sizeof(VGfloat));
                
                iNVGIconData->ReadL(tmPtr, 9 * sizeof(VGfloat));
                flag = iNVGIconData->ReadInt32L();
                
                vgLoadMatrix(currentMatrix);
                if (flag)
                    {
                    vgMultMatrix(transformMatrix);
                    }
                }
                break;
            case EStrokeWidth:
                {
                VGfloat strokeWidth = iNVGIconData->ReadReal32L();
                vgSetf(VG_STROKE_LINE_WIDTH, strokeWidth);
                break;
                }
            case EStrokeMiterLimit:
                {
                VGfloat miterLimit = iNVGIconData->ReadReal32L();
                vgSetf(VG_STROKE_MITER_LIMIT, miterLimit);
                break;
                }
            case EStrokeLineJoinCap:
                {
                VGint lineJoin = iNVGIconData->ReadInt32L();
                VGint cap = iNVGIconData->ReadInt32L();
                
                vgSeti(VG_STROKE_JOIN_STYLE, (VGJoinStyle)lineJoin);
                vgSeti(VG_STROKE_CAP_STYLE, (VGCapStyle)cap);
                break;
                }
            case EStrokePaint:
                {
                DrawPaintL(iStrokePaint, VG_MATRIX_STROKE_PAINT_TO_USER, iLastStrokePaintType, iLastStrkePaintColor, VG_STROKE_PATH);
                break;
                }
            case EStrokeColorRamp:
                {
                iNVGIconData->ReadInt32L();
                break;
                }
            default:
                {
                User::Leave(KErrCorrupt);
                break;
                }
            }
        }
    
    iNVGIconData->EndRead();
    
    return ret;
    }
Beispiel #10
0
VGPath SurfaceOpenVG::cachedPath(CachedPathDescriptor which)
{
    Vector<VGPath>& paths = cachedPaths();

    if (paths.isEmpty()) {
        paths.resize(CachedPathCount);
        paths.fill(VG_INVALID_HANDLE);
    }

    if (paths.at(which) == VG_INVALID_HANDLE) {
        sharedSurface()->makeCurrent();
        VGPath path = VG_INVALID_HANDLE;
        VGUErrorCode errorCode;

        switch (which) {
        case CachedLinePath:
            path = vgCreatePath(
                       VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
                       1.0 /* scale */, 0.0 /* bias */,
                       2 /* expected number of segments */,
                       4 /* expected number of total coordinates */,
                       VG_PATH_CAPABILITY_APPEND_TO);
            ASSERT_VG_NO_ERROR();

            errorCode = vguLine(path, 0, 0, 1, 0);
            ASSERT(errorCode == VGU_NO_ERROR);
            break;

        case CachedRectPath:
            path = vgCreatePath(
                       VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
                       1.0 /* scale */, 0.0 /* bias */,
                       5 /* expected number of segments */,
                       5 /* expected number of total coordinates */,
                       VG_PATH_CAPABILITY_APPEND_TO);
            ASSERT_VG_NO_ERROR();

            errorCode = vguRect(path, 0, 0, 1, 1);
            ASSERT(errorCode == VGU_NO_ERROR);
            break;

        case CachedCirclePath:
            path = vgCreatePath(
                       VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
                       1.0 /* scale */, 0.0 /* bias */,
                       4 /* expected number of segments */,
                       10 /* expected number of total coordinates */,
                       VG_PATH_CAPABILITY_APPEND_TO);
            ASSERT_VG_NO_ERROR();

            errorCode = vguEllipse(path, 0.5, 0.5, 1, 1);
            ASSERT(errorCode == VGU_NO_ERROR);
            break;

        case EmptyTemporaryPath:
            path = vgCreatePath(
                       VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
                       1.0 /* scale */, 0.0 /* bias */,
                       0 /* expected number of segments */,
                       0 /* expected number of total coordinates */,
                       VG_PATH_CAPABILITY_ALL);
            ASSERT_VG_NO_ERROR();
            break;

        default:
            ASSERT_NOT_REACHED();
        }

        paths.at(which) = path;
        makeCurrent();
    }

    if (which == EmptyTemporaryPath) {
        VGPath path = paths.at(EmptyTemporaryPath);
        vgClearPath(path, VG_PATH_CAPABILITY_ALL);
        ASSERT_VG_NO_ERROR();
        return path;
    }

    return paths.at(which);
}
Beispiel #11
0
void reshape(int x, int y)
{
  vgClearPath(p, VG_PATH_CAPABILITY_ALL);
  createSquare(p);
}
Beispiel #12
0
static void update_display(envelope_render_internal_t *renderer)
{
    // Calculate scale
    envelope_t *envelope = renderer->definition.envelope;
    int32_t total_duration = 0;

    envelope_stage_t *stage = envelope->stages;
    for (int i = 0; i < envelope->stage_count; i++, stage++)
    {
        if (stage->duration == DURATION_HELD)
        {
            total_duration += HELD_DURATION_LENGTH;
        }
        else
        {
            total_duration += stage->duration;
        }
    }

    float horizontal_scale = (float)(renderer->definition.width - 1) / (float) total_duration;
    float vertical_scale = (float)(renderer->definition.height - 1) / (float)envelope->peak;

    // Build path segments from envelope stages
    int command_index = 0;
    int coord_index = 0;

    int32_t	last_level = -1;
    int32_t	elapsed_duration = 0;

    stage = envelope->stages;
    for (int i = 0; i < envelope->stage_count; i++, stage++)
    {
        if (last_level != stage->start_level && stage->start_level != LEVEL_CURRENT)
        {
            commands[command_index++] = VG_MOVE_TO_ABS;
            coords[coord_index++] = (float)elapsed_duration * horizontal_scale;
            coords[coord_index++] = (float)stage->start_level * vertical_scale;
        }

        last_level = stage->end_level;
        if (stage->duration == DURATION_HELD)
        {
            elapsed_duration += HELD_DURATION_LENGTH;
        }
        else
        {
            elapsed_duration += stage->duration;
        }

        commands[command_index++] = VG_LINE_TO_ABS;
        coords[coord_index++] = (float)elapsed_duration * horizontal_scale;
        coords[coord_index++] = (float)stage->end_level * vertical_scale;
    }

    vgAppendPathData(renderer->state.path, command_index, commands, coords);

    // Render it out
    vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
    vgLoadIdentity();
    vgSetfv(VG_CLEAR_COLOR, 4, renderer->definition.background_colour);
    vgClear(renderer->definition.x, renderer->definition.y,
            renderer->definition.width, renderer->definition.height);

    vgSetf(VG_STROKE_LINE_WIDTH, renderer->definition.line_width);
    vgSeti(VG_STROKE_CAP_STYLE, renderer->definition.line_cap_style);
    vgSeti(VG_STROKE_JOIN_STYLE, renderer->definition.line_join_style);
    vgSetPaint(renderer->state.line_paint, VG_STROKE_PATH);
    vgSeti(VG_RENDERING_QUALITY, renderer->definition.rendering_quality);
    vgTranslate(renderer->definition.x, renderer->definition.y);
    vgDrawPath(renderer->state.path, VG_STROKE_PATH);
    vgClearPath(renderer->state.path, VG_PATH_CAPABILITY_APPEND_TO);

    vgSeti(VG_RENDERING_QUALITY, renderer->definition.text_quality);
    vgSetPaint(renderer->state.text_paint, VG_FILL_PATH);
    gfx_render_text(0, renderer->definition.height - 12, renderer->definition.text, &gfx_font_sans, 9);
}