Exemplo n.º 1
0
void VDP::draw_screen()
{
	memset(bg, 0, sizeof(bg));
	
	for(int y = 0; y < 24; y++) {
		int y8 = y << 3, y32 = y << 5;
		
		for(int x = 2; x < 30; x++) {
			int x8 = x << 3;
			uint8 code = vram[y32 + x];
			
			if(code < 0xe0 || force_pattern) {
				draw_pattern(x8, y8, code << 5);
			}
			else {
				draw_pcg(x8, y8, (code & 0x1f) << 5);
			}
		}
	}
	for(int y = 0; y < 192; y++) {
		scrntype* dest = emu->screen_buffer(y);
		for(int x = 0; x < 256; x++) {
			dest[x] = palette_pc[bg[y][x] & 7];
		}
	}
}
enum piglit_result
piglit_display(void)
{
	int row, col;
	bool pass = true;

	glClear(GL_COLOR_BUFFER_BIT);
	glUseProgram(prog);
	glUniform2f(window_size_loc, piglit_width/2, piglit_height);
	glVertexAttribPointer(vertex_attr, 2, GL_FLOAT, GL_FALSE,
			      sizeof(vertex_patterns[test->pattern][0]),
			      vertex_patterns[test->pattern]);
	glEnableVertexAttribArray(vertex_attr);

	for (col = 0; col < NUM_COLS; col++) {
		if (col == 0)
			glViewport(0, 0, piglit_width/2, piglit_height);
		else
			glViewport(piglit_width/2, 0, piglit_width/2, piglit_height);

		for (row = 0; row < NUM_ROWS; row++) {
			glUniform2f(offset_loc, 0,
				    (NUM_ROWS - 1 - row) * PATTERN_SIZE);
			draw_pattern(row + 1, col == 0);
		}
	}

	glViewport(0, 0, piglit_width, piglit_height);
	pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width,
						   piglit_height) && pass;
	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
	piglit_present_results();
	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Exemplo n.º 3
0
enum piglit_result
piglit_display()
{
	bool pass = true;
	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	/* Draw test pattern in single sample resolve_fbo with GL_POLYGON_STIPPLE
	 * enabled.
	 */
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);
	resolve_fbo.set_viewport();
	draw_pattern();

	/* Blit resolve_fbo to the right half of window system framebuffer. This
	 * is a reference image.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
			  pattern_width, 0, 2 * pattern_width, pattern_height,
			  buffer_to_test, GL_NEAREST);

	/* Test with multisample FBO and GL_POLYGON_STIPPLE enabled */
	pass = test_polygon_stipple() && pass;

	if (!piglit_automatic &&
	    buffer_to_test != GL_DEPTH_BUFFER_BIT)
		piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Exemplo n.º 4
0
bool
test_polygon_stipple()
{
	bool result = true;
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);
	draw_pattern();

	/* Blit ms_fbo to resolve_fbo to resolve multisample buffer */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);
	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
			  0, 0, pattern_width, pattern_height,
			  buffer_to_test, GL_NEAREST);

	/* Blit resolve_fbo to the left half of window system framebuffer.
	 * This is the test image.
	 */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo.handle);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
	glBlitFramebuffer(0, 0, pattern_width, pattern_height,
			  0, 0, pattern_width, pattern_height,
			  buffer_to_test, GL_NEAREST);

	/* Check that the left and right halves of the screen match */
	glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
	result = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width,
						     piglit_height)
		 && result;

	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
	result = piglit_check_gl_error(GL_NO_ERROR) && result;
	return result;
}
Exemplo n.º 5
0
static void init(void)
{
   ex.FPS = 60;

   ex.font = al_load_font("data/fixed_font.tga", 0, 0);
   if (!ex.font) {
      abort_example("data/fixed_font.tga not found.\n");
   }
   ex.background = al_color_name("beige");
   ex.foreground = al_color_name("black");
   ex.outline = al_color_name("red");
   ex.text = al_color_name("blue");
   ex.white = al_color_name("white");
   ex.pattern = al_create_bitmap(32, 32);
   ex.zoom = al_create_bitmap(32, 32);
   draw_pattern(ex.pattern);
}
Exemplo n.º 6
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_surface_t *surface;
    cairo_surface_t *similar;
    cairo_t *cr2;

    cairo_set_source_rgb (cr, 0, 0, 0);
    cairo_paint (cr);

    surface = create_source_surface (SOURCE_SIZE);
    if (surface == NULL) /* can't create the source so skip the test */
	return CAIRO_TEST_UNTESTED;

    draw_pattern (&surface, SOURCE_SIZE);

    /* copy a subregion to a smaller intermediate surface */
    similar = cairo_surface_create_similar (surface,
					    CAIRO_CONTENT_COLOR_ALPHA,
					    INTER_SIZE, INTER_SIZE);
    cr2 = cairo_create (similar);
    cairo_surface_destroy (similar);
    cairo_set_source_surface (cr2, surface,
			      (INTER_SIZE - SOURCE_SIZE)/2,
			      (INTER_SIZE - SOURCE_SIZE)/2);
    cairo_paint (cr2);

    /* and then paint onto a small surface for checking */
    cairo_set_source_surface (cr, cairo_get_target (cr2),
			      (width - INTER_SIZE)/2,
			      (height - INTER_SIZE)/2);
    cairo_destroy (cr2);
    cairo_rectangle (cr, 16, 16, 64, 64);
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
    cairo_fill (cr);

    /* destroy the surface last, as this triggers XCloseDisplay */
    cairo_surface_destroy (surface);

    return CAIRO_TEST_SUCCESS;
}
Exemplo n.º 7
0
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
    Display *dpy;
    unsigned char *reference_data;
    unsigned char *test_data;
    unsigned char *diff_data;
    cairo_surface_t *reference_surface;
    cairo_bool_t use_pixmap;
    cairo_bool_t set_size;
    cairo_bool_t offscreen;
    cairo_test_status_t status, result = CAIRO_TEST_UNTESTED;
    int stride;

    if (! cairo_test_is_target_enabled (ctx, "xlib"))
        goto CLEANUP_TEST;

    dpy = XOpenDisplay (NULL);
    if (!dpy) {
        cairo_test_log (ctx, "xlib-surface: Cannot open display, skipping\n");
        goto CLEANUP_TEST;
    }

    if (!check_visual (dpy)) {
        cairo_test_log (ctx, "xlib-surface: default visual is not RGB24 or BGR24, skipping\n");
        goto CLEANUP_DISPLAY;
    }

    stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, SIZE);

    reference_data = xcalloc (ctx, SIZE, stride);
    test_data = xcalloc (ctx, SIZE, stride);
    diff_data = xcalloc (ctx, SIZE, stride);

    reference_surface = cairo_image_surface_create_for_data (reference_data,
                        CAIRO_FORMAT_RGB24,
                        SIZE, SIZE,
                        stride);

    draw_pattern (reference_surface);
    cairo_surface_destroy (reference_surface);

    result = CAIRO_TEST_SUCCESS;

    for (set_size = 0; set_size <= 1; set_size++)
        for (use_pixmap = 0; use_pixmap <= 1; use_pixmap++)
            for (offscreen = 0; offscreen <= 1; offscreen++) {
                status = do_test (ctx, dpy,
                                  reference_data, test_data, diff_data,
                                  use_pixmap, set_size, offscreen);
                if (status)
                    result = status;
            }

    free (reference_data);
    free (test_data);
    free (diff_data);

CLEANUP_DISPLAY:
    XCloseDisplay (dpy);

CLEANUP_TEST:
    return result;
}
Exemplo n.º 8
0
static cairo_test_status_t
do_test (const cairo_test_context_t *ctx,
         Display        *dpy,
         unsigned char  *reference_data,
         unsigned char  *test_data,
         unsigned char  *diff_data,
         cairo_bool_t    use_pixmap,
         cairo_bool_t    set_size,
         cairo_bool_t    offscreen)
{
    cairo_surface_t *surface;
    cairo_surface_t *test_surface;
    cairo_t *test_cr;
    buffer_diff_result_t result;
    Drawable drawable;
    int screen = DefaultScreen (dpy);

    if (use_pixmap && offscreen)
        return CAIRO_TEST_SUCCESS;

    if (use_pixmap) {
        drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
                                  SIZE, SIZE, DefaultDepth (dpy, screen));
    } else {
        XSetWindowAttributes xwa;
        int x, y;

        xwa.override_redirect = True;

        if (offscreen) {
            x = - OFFSCREEN_OFFSET;
            y = - OFFSCREEN_OFFSET;
        } else {
            x = 0;
            y = 0;
        }

        drawable = XCreateWindow (dpy, DefaultRootWindow (dpy),
                                  x, y, SIZE, SIZE, 0,
                                  DefaultDepth (dpy, screen), InputOutput,
                                  DefaultVisual (dpy, screen),
                                  CWOverrideRedirect, &xwa);
        XMapWindow (dpy, drawable);
    }

    surface = cairo_xlib_surface_create (dpy,
                                         drawable,
                                         DefaultVisual (dpy, screen),
                                         SIZE, SIZE);

    if (! surface_compare_visual_and_format (surface))
        return CAIRO_TEST_FAILURE;

    if (set_size) {
        cairo_xlib_surface_set_size (surface, SIZE, SIZE);

        if (cairo_xlib_surface_get_width (surface) != SIZE ||
                cairo_xlib_surface_get_height (surface) != SIZE)
            return CAIRO_TEST_FAILURE;
    }

    if (! check_similar_visual_and_format (surface))
        return CAIRO_TEST_FAILURE;

    draw_pattern (surface);

    test_surface = cairo_image_surface_create_for_data (test_data,
                   CAIRO_FORMAT_RGB24,
                   SIZE, SIZE,
                   SIZE * 4);

    test_cr = cairo_create (test_surface);
    cairo_set_source_surface (test_cr, surface, 0, 0);
    cairo_paint (test_cr);

    cairo_destroy (test_cr);
    cairo_surface_destroy (test_surface);

    /* We erase the surface to black in case we get the same
     * memory back again for the pixmap case.
     */
    erase_pattern (surface);
    cairo_surface_destroy (surface);

    if (use_pixmap)
        XFreePixmap (dpy, drawable);
    else
        XDestroyWindow (dpy, drawable);

    if (offscreen) {
        size_t offset = 4 * (SIZE * OFFSCREEN_OFFSET + OFFSCREEN_OFFSET);

        buffer_diff_noalpha (reference_data + offset,
                             test_data + offset,
                             diff_data + offset,
                             SIZE - OFFSCREEN_OFFSET,
                             SIZE - OFFSCREEN_OFFSET,
                             4 * SIZE,
                             &result);
    } else {
        buffer_diff_noalpha (reference_data,
                             test_data,
                             diff_data,
                             SIZE,
                             SIZE,
                             4 * SIZE,
                             &result);
    }

    cairo_test_log (ctx, "xlib-surface: %s, %s, %s: %s\n",
                    set_size ? "   size" : "no-size",
                    use_pixmap ? "pixmap" : "window",
                    use_pixmap ?  "           " : (offscreen ? ", offscreen" : ",  onscreen"),
                    image_diff_is_failure (&result, 0) ? "FAIL" : "PASS");

    if (image_diff_is_failure (&result, 0))
        return CAIRO_TEST_FAILURE;
    else
        return CAIRO_TEST_SUCCESS;
}
void ledDisplay::drawChar(char character)
{
    if (character == 'a' || character == 'A'){
        draw_pattern(5);
    }
    else if (character == 'b' || character == 'B'){draw_pattern(6);
    }
    else if (character == 'c' || character == 'C'){draw_pattern(7);
    }
    else if (character == 'd' || character == 'D'){draw_pattern(8);
    }
    else if (character == 'e' || character == 'E'){draw_pattern(9);
    }
    else if (character == 'f' || character == 'F'){draw_pattern(10);
    }
    else if (character == 'g' || character == 'G'){draw_pattern(11);
    }
    else if (character == 'h' || character == 'H'){draw_pattern(12);
    }
    else if (character == 'i' || character == 'I'){draw_pattern(13);
    }
    else if (character == 'j' || character == 'J'){draw_pattern(14);
    }
    else if (character == 'k' || character == 'K'){draw_pattern(15);
    }
    else if (character == 'l' || character == 'L'){draw_pattern(16);
    }
    else if (character == 'm' || character == 'M'){draw_pattern(17);
    }
    else if (character == 'n' || character == 'N'){draw_pattern(18);
    }
    else if (character == 'o' || character == 'O'){draw_pattern(19);
    }
    else if (character == 'p' || character == 'P'){draw_pattern(20);
    }
    else if (character == 'q' || character == 'Q'){draw_pattern(21);
    }
    else if (character == 'r' || character == 'R'){draw_pattern(22);
    }
    else if (character == 's' || character == 'S'){draw_pattern(23);
    }
    else if (character == 't' || character == 'T'){draw_pattern(24);
    }
    else if (character == 'u' || character == 'U'){draw_pattern(25);
    }
    else if (character == 'v' || character == 'V'){draw_pattern(26);
    }
    else if (character == 'w' || character == 'W'){draw_pattern(27);
    }
    else if (character == 'x' || character == 'X'){draw_pattern(28);
    }
    else if (character == 'y' || character == 'Y'){draw_pattern(29);
    }
    else if (character == 'z' || character == 'Z'){draw_pattern(30);
    }
    else{draw_pattern(31);}
    
}