Ejemplo n.º 1
0
void PainterOpenVG::drawRect(const FloatRect& rect, VGbitfield specifiedPaintModes)
{
    ASSERT(m_state);

    VGbitfield paintModes = 0;
    if (!m_state->strokeDisabled())
        paintModes |= VG_STROKE_PATH;
    if (!m_state->fillDisabled())
        paintModes |= VG_FILL_PATH;

    paintModes &= specifiedPaintModes;

    if (!paintModes)
        return;

    m_surface->makeCurrent();

    VGPath 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();

    if (vguRect(path, rect.x(), rect.y(), rect.width(), rect.height()) == VGU_NO_ERROR) {
        vgDrawPath(path, paintModes);
        ASSERT_VG_NO_ERROR();
    }

    vgDestroyPath(path);
    ASSERT_VG_NO_ERROR();
}
Ejemplo n.º 2
0
  void push(int x, int y, int width, int height) {
    assert(width >= 0);
    assert(height >= 0);

    vguRect(path_, x, y, width, height);
    assert(!vgGetError());
  };
Ejemplo n.º 3
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;

        default:
            ASSERT_NOT_REACHED();
        }

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

    return paths.at(which);
}
Ejemplo n.º 4
0
void createPrimitives()
{
  VGfloat points[] = {-30,-30, 30,-30, 0,30};
  
  line = testCreatePath();
  vguLine(line, -30,-30,30,30);
  primitives[0] = line;
  
  polyOpen = testCreatePath();
  vguPolygon(polyOpen, points, 3, VG_FALSE);
  primitives[1] = polyOpen;
  
  polyClosed = testCreatePath();
  vguPolygon(polyClosed, points, 3, VG_TRUE);
  primitives[2] = polyClosed;
  
  rect = testCreatePath();
  vguRect(rect, -50,-30, 100,60);
  primitives[3] = rect;
  
  rectRound = testCreatePath();
  vguRoundRect(rectRound, -50,-30, 100,60, 30,30);
  primitives[4] = rectRound;
  
  ellipse = testCreatePath();
  vguEllipse(ellipse, 0,0, 100, 100);
  primitives[5] = ellipse;
  
  arcOpen = testCreatePath();
  vguArc(arcOpen, 0,0, 100,60, 0, 270, VGU_ARC_OPEN);
  primitives[6] = arcOpen;
  
  arcChord = testCreatePath();
  vguArc(arcChord, 0,0, 100,60, 0, 270, VGU_ARC_CHORD);
  primitives[7] = arcChord;
  
  
  arcPie = testCreatePath();
  vguArc(arcPie, 0,0, 100,60, 0, 270, VGU_ARC_PIE);
  primitives[8] = arcPie;
  
}
Ejemplo n.º 5
0
void Path::addRect(const FloatRect& rect)
{
    if (rect.isEmpty()) {
        moveTo(rect.location());
        if (rect.width() > FLT_EPSILON) {
            addLineTo(FloatPoint(rect.x() + rect.width(), rect.y()));
            closeSubpath();
        } else if (rect.height() > FLT_EPSILON) {
            addLineTo(FloatPoint(rect.x(), rect.y() + rect.height()));
            closeSubpath();
        }
        return;
    }

    m_path->makeCompatibleContextCurrent();
    VGUErrorCode error = vguRect(m_path->vgPath(),
        rect.x(), rect.y(), rect.width(), rect.height());
    ASSERT(error == VGU_NO_ERROR);

    m_path->m_currentPoint = m_path->m_subpathStartPoint = rect.location();
}
Ejemplo n.º 6
0
LRESULT OnPaint(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{

	VGPaint strokePaint = vgCreatePaint();
	vgSetPaint(strokePaint, VG_STROKE_PATH);

	VGfloat color[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
	vgSetParameterfv(strokePaint, VG_PAINT_COLOR, 4, &color[0]);

	VGPath line = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
	vguLine(line, 20, 20, 130, 130);

	VGPath square = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
	vguRect(square, 10.0f, 10.0f, 130.0f, 50.0f);

	vgSetf(VG_STROKE_LINE_WIDTH, 7.0f);
	vgDrawPath(line, VG_STROKE_PATH);
	vgDrawPath(square, VG_STROKE_PATH);



	::ValidateRect(hWnd, NULL);
	return 0;
}
Ejemplo n.º 7
0
// RectOutline makes a rectangle at the specified location and dimensions, outlined 
void RectOutline(VGfloat x, VGfloat y, VGfloat w, VGfloat h) {
	VGPath path = newpath();
	vguRect(path, x, y, w, h);
	vgDrawPath(path, VG_STROKE_PATH);
	vgDestroyPath(path);
}
Ejemplo n.º 8
0
int main() {
	int running = GL_TRUE;
	int width = 640;
	int height = 480;
	int x = 50;
	int y = 50;
	int w = 10;
	int h = 10;
	/*
	Window *win = check_malloc (sizeof(Window));
	win->width = 640;
	win->height = 480;
	*/

	// Initialize GLFW, create a ShivaVG context, open a window

	if( !glfwInit() )
	{
		return 1; // Couldn't initialize GLFW
	}

	int n = glfwOpenWindow(width, height, 0,0,0,0,0,0, GLFW_WINDOW);
	if (!n) {
		glfwTerminate(); // Cleanup GLFW
		return 1; // Couldn't create a window
	}

	glfwSetWindowCloseCallback(window_close_callback);

	glfwSetWindowTitle("Shiva test");

	vgCreateContextSH(width, height); // XXX: TODO: handle errors!!!!
	
	/*
	Rect *r = make_rect(0,0,100,100,0,1,1,1);
	win->rect = r;
	*/
	
	//make color
	VGPaint paint;
	VGfloat paint_array[] = {1,0,1,1};
	paint = vgCreatePaint();
    vgSetParameterfv(paint, VG_PAINT_COLOR, 4, paint_array);
	
	//make rect

	VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
								1,0,0,0, VG_PATH_CAPABILITY_ALL);
	vguRect(path, 0, 0, w, h);


	VGfloat magenta[] = {0.9,0,0,1};
	

	while (running) {
			
		vgSetfv(VG_CLEAR_COLOR, 4, magenta);
		vgClear(0, 0, width, height);
		
		vgLoadIdentity();

		vgTranslate(x, y);
		vgSetPaint(paint, VG_FILL_PATH);
		vgDrawPath(path, VG_FILL_PATH);

		glfwSwapBuffers();	

		// Terminate when ESC is pressed or the window is closed
		running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
	}

	// Close the window, clean up the ShivaVG context, and clean up GLFW
	vgDestroyContextSH();

	// Close window and terminate GLFW
	glfwTerminate();

	
	return 0;
}
Ejemplo n.º 9
0
	void OpenVG_SVGHandler::onPathRect( float x, float y, float w, float h ) {
		vguRect( _current_group->current_path->path, x, y, w, h );
	}