void onDraw(SkCanvas* canvas) override { GrContext* ctx = canvas->getGrContext(); // must be opaque to have a hope of testing LCD text const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType); const struct { SkPixelGeometry fGeo; const char* fLabel; } rec[] = { { kUnknown_SkPixelGeometry, "Unknown" }, { kRGB_H_SkPixelGeometry, "RGB_H" }, { kBGR_H_SkPixelGeometry, "BGR_H" }, { kRGB_V_SkPixelGeometry, "RGB_V" }, { kBGR_V_SkPixelGeometry, "BGR_V" }, }; SkScalar x = 0; for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) { for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) { SkScalar y = 0; for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) { SkAutoTUnref<SkSurface> surface(make_surface(ctx, info, rec[i].fGeo, disallowAA, disallowDither)); test_draw(surface->getCanvas(), rec[i].fLabel); surface->draw(canvas, x, y, nullptr); y += H; } x += W; } } }
main(int argc, char **argv) { Errcode err; tcb.ovmode = pj_get_vmode(); if((err = getargs(argc,argv)) < Success) goto error; if((err = init_screen(&tcb.vd, &tcb.dcel, tcb.vd_path, tcb.vd_mode)) < Success) goto error; err = test_draw(tcb.dcel); goto done; error: errline(err,"failure in main"); done: pj_rcel_free(tcb.dcel); pj_close_vdriver(&tcb.vd); pj_set_vmode(tcb.ovmode); exit((err < Success)?-1:0); }
static bool pass_link_test(int y_index, const char *vs_prefix, int vs_blocks, const char *fs_prefix, int fs_blocks) { bool pass = true; GLuint prog; GLuint *bos = (GLuint *) calloc(vs_blocks + fs_blocks, sizeof(GLuint)); GLint active_blocks; int i; prog = build_shaders(vs_prefix, vs_blocks, fs_prefix, fs_blocks); if (!prog) { printf("shader with (%d, %d) blocks failed to link\n", vs_blocks, fs_blocks); free(bos); return false; } glUseProgram(prog); glGetProgramInterfaceiv(prog, GL_SHADER_STORAGE_BLOCK, GL_ACTIVE_RESOURCES, &active_blocks); glGenBuffers(active_blocks, bos); for (i = 0; i < active_blocks; i++) { glShaderStorageBlockBinding(prog, i, i); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, i, bos[i]); } for (i = 0; i < active_blocks; i++) { if (!test_draw(y_index, prog, bos, i, active_blocks)) { pass = false; } } glDeleteBuffers(active_blocks, bos); glDeleteProgram(prog); free(bos); return pass; }
static adv_error cmd_onvideo_test(void) { adv_crtc* crtc; adv_mode mode; adv_bool done; adv_crtc crtc_save; adv_bool dirty = 1; adv_bool crtc_save_modified; mode_reset(&mode); crtc = menu_current(); if (!crtc) return -1; if (!crtc_is_fake(crtc) && !crtc_clock_check(&the_monitor, crtc)) return -1; if (video_mode_generate(&mode, crtc, the_mode_index)!=0) { return -1; } if (text_mode_set(&mode) != 0) { text_reset(); return -1; } crtc_save = *crtc; crtc_save_modified = the_modes_modified; done = 0; while (!done) { int userkey; adv_bool modify = 0; adv_crtc last_crtc = *crtc; adv_mode last_mode = mode; adv_bool vm_last_modified = the_modes_modified; if (dirty) { video_write_lock(); test_draw(1, 1, &mode); video_write_unlock(0, 0, 0, 0, 0); dirty = 0; } video_wait_vsync(); target_idle(); os_poll(); userkey = inputb_get(); switch (userkey) { case INPUTB_ESC : done = 1; /* restore */ *crtc = crtc_save; the_modes_modified = crtc_save_modified; break; case INPUTB_ENTER : done = 1; break; } if (!done) { modify = test_exe_crtc(userkey, crtc); if (modify) { the_modes_modified = 1; dirty = 1; if ((crtc_is_fake(crtc) || crtc_clock_check(&the_monitor, crtc)) && video_mode_generate(&mode, crtc, the_mode_index)==0) { if (text_mode_set(&mode) != 0) { text_reset(); /* abort */ *crtc = crtc_save; the_modes_modified = crtc_save_modified; return -1; } } else { /* restore */ mode = last_mode; *crtc = last_crtc; the_modes_modified = vm_last_modified; dirty = 1; sound_error(); } } else { sound_warn(); } } } return 0; }