static void resetGpuState() { if (NULL == gContext) { SkDebugf("creating context for first time\n"); gContext = make_context(); } else { SkDebugf("------ gContext refcnt=%d\n", gContext->refcnt()); gContext->abandonAllTextures(); gContext->unref(); gContext = make_context(); } }
void scene9(void) { int width, height, scanline; int i, formula = 1; char *buffer1; signal(SIGFPE, SIG_IGN); width = aa_imgwidth(context); height = aa_imgheight(context); scanline = width; buffer1 = context->imagebuffer; params->bright = -255; params->dither = AA_NONE; zcontext = make_context(width, height, scanline, 0, 1, flip_buffers, ui_waitfunc, buffer1, buffer1, get_pixelwidth(width), get_pixelheight(height)); if (!zcontext) { exit(-1); } set_formula(zcontext, formula); for (i = 0; i < 255; i++) { zcontext->colors[i] = (i * 15) % 255 + 1; } zcontext->colors[0] = 0; zcontext->num_colors = 255; tbreak = 2; zcontext->maxiter = 255; fastmode--; zcontext->range = 8; zcontext->incoloringmode = 0; zcontext->coloringmode = 0; zcontext->plane = 0; starttime = endtime; sef = 1; eef = 0; is = -1; rs = -1; ie = 2; re = -2; timestuff(0, NULL, juliov, ETIME2); sef = 0; eef = 0; is = ie, rs = re; ie = 2; re = 2; timestuff(0, NULL, juliov, ETIME2); sef = 0; eef = 0; is = ie, rs = re; ie = -2; re = 2; timestuff(0, NULL, juliov, ETIME2); sef = 0; eef = 1; is = ie, rs = re; ie = 2; re = -2; timestuff(0, NULL, juliov, ETIME2); context->imagebuffer = buffer1; params->bright = 0; params->dither = AA_FLOYD_S; }
auto process_format_aux(F f, Format, Pairs... pairs) { return apply_actions ( make_actions<CTTE_MAKE_STRING(Format)>{}, make_context(pairs...), std::move(f) ); }
draw_context_t GSFrameBase::new_context() { if (void* context = make_context()) { return std::shared_ptr<void>(context, [this](void* ctxt) { delete_context(ctxt); }); } return nullptr; }
int main(int argc, char *argv[]) { filedb_top("."); make_init(); context* ctx = make_context(); assert(lib_read(argv[1],strlen(argv[1]),ctx)); VipsImage* image = lib_thumbnail(ctx); lib_write(image,argv[2],1,ctx); return 0; }
static void doDraw() { if (NULL == gContext) { gContext = make_context(); } State* state = get_state(); SkBitmap viewport; viewport.setConfig(SkBitmap::kARGB_8888_Config, state->getWidth(), state->getHeight()); SkGpuCanvas canvas(gContext); canvas.setBitmapDevice(viewport); state->applyMatrix(&canvas); drawIntoCanvas(state, &canvas); GrGLCheckErr(); GrGLClearErr(); // gContext->checkError(); // gContext->clearError(); if (true) { static const int FRAME_COUNT = 32; static SkMSec gDuration; static SkMSec gNow; static int gFrameCounter; if (++gFrameCounter == FRAME_COUNT) { gFrameCounter = 0; SkMSec now = SkTime::GetMSecs(); gDuration = now - gNow; gNow = now; } int fps = (FRAME_COUNT * 1000) / gDuration; SkString str; str.printf("FPS=%3d MS=%3d", fps, gDuration / FRAME_COUNT); SkGpuCanvas c(gContext); c.setBitmapDevice(viewport); SkPaint p; p.setAntiAlias(true); SkRect r = { 0, 0, 110, 16 }; p.setColor(SK_ColorWHITE); c.drawRect(r, p); p.setColor(SK_ColorBLACK); c.drawText(str.c_str(), str.size(), 4, 12, p); } }
bool MediaPlayer::stop() { HRESULT hr; bool success = true; hr = m_context->spMediaControl->Stop(); if(FAILED(hr)) { m_context->error = vfwErrorString("IMediaControl::Stop() failed", hr); success = false; } m_context = make_context(m_context->hwnd); return success; }
MediaPlayer::MediaPlayer() : m_context() , m_version("") , m_type("Mac") { try { m_context = make_context(); } catch(const InitializationException& e) { m_context = PlayerContextPtr(new PlayerContext); m_context->error = e.what(); throw; } }
Context( const x11::Display& display, const FBConfig& fbc, int version_major, int version_minor ): x11::DisplayObject< ::GLXContext, void(::Display*, ::GLXContext)>( display, make_context( display, fbc, version_major, version_minor ), ::glXDestroyContext, "Error creating glX context" ){ }
void go_up_level(bool is_quote) { int col_tag; lexical_stack_height++; lexical_stack = realloc(lexical_stack,sizeof(void*)*lexical_stack_height); /* This is where the tagging takes place: */ if(is_quote==true) { col_tag=QUOTE; push(scope_stack,make_context(peek(scope_stack))); } else col_tag=LIST; ccell* new_cell = cons(NULL,NULL); lexical_stack[lexical_stack_height-1] =make_cd(col_tag,peek(scope_stack),new_cell); current_col_size = 0; current_node = new_cell; }
MediaPlayer::MediaPlayer() : m_context() , m_version("") , m_type("DirectShow") { ::CoInitializeEx(0, COINIT_MULTITHREADED); try { m_context = make_context(0); } catch(const InitializationException& e) { if(!m_context) m_context = PlayerContextPtr(new PlayerContext); m_context->error = e.what(); throw; } }
bool MediaPlayer::play(const std::string& file_) { HRESULT hr; CA2W fileConversion(file_.c_str()); CComBSTR file(fileConversion); PlayerContextPtr context = make_context(m_context->hwnd); hr = context->spGraph->RenderFile(file, 0); if(FAILED(hr)) { m_context->error = vfwErrorString("IGraphBuilder::RenderFile() failed", hr); return false; } OAFilterState state; hr = m_context->spMediaControl->GetState(50, &state); if(FAILED(hr)) { m_context->error = vfwErrorString("IMediaControl::GetState() failed", hr); return false; } if(state == State_Running) { hr = m_context->spMediaControl->Stop(); if(FAILED(hr)) { m_context->error = vfwErrorString("IMediaControl::Stop() failed: ", hr); return false; } } std::swap(m_context, context); activateVideo(m_context); hr = m_context->spMediaControl->Run(); if(FAILED(hr)) { m_context->error = vfwErrorString("IMediaControl::Run() failed", hr); return false; } return true; }
auto for_each_part_aux(Format, Pairs... pairs) { auto context = make_context(pairs...); return for_each_part_aux_operator<decltype(context), Format>{std::move(context)}; }
void scene6(void) { int width, height, scanline; int i, formula = 0; char *buffer1, *buffer2; displayed = 0; incalculation = 0; fastmode = 2; interruptiblemode = 0; autopilot = 0; maxstep = MAXSTEP; speedup = STEP; step = 0; tbreak = 0; maintimer = tl_create_timer(); signal(SIGFPE, SIG_IGN); width = aa_imgwidth(context); height = aa_imgheight(context); scanline = width; buffer1 = context->imagebuffer; buffer2 = malloc(width * height); endtime = starttime + ETIME1; params->bright = -255; zcontext = make_context(width, height, scanline, 0, 1, flip_buffers, ui_waitfunc, buffer1, buffer2, get_pixelwidth(width), get_pixelheight(height)); if (!zcontext) { exit(-1); } set_formula(zcontext, formula); for (i = 0; i < 255; i++) { /*zcontext->colors[i] = (i * 15) % 255 + 1; */ zcontext->colors[i] = (i * 8) % 255 + 1; } zcontext->colors[0] = 0; zcontext->num_colors = 255; tbreak = 2; zcontext->maxiter = 150; fastmode--; zcontext->range = 8; zcontext->incoloringmode = 0; zcontext->coloringmode = 0; zcontext->plane = 0; ui_do_fractal(NEW_IMAGE); ui_autopilot(); speedup = 1 * STEP; maxstep *= 5; step = -maxstep; tl_process_group(syncgroup, NULL); bbupdate(); tl_reset_timer(maintimer); main_loop(); starttime = endtime; context->imagebuffer = buffer1; free(buffer2); tl_free_timer(maintimer); params->bright = 0; params->randomval = 0; initlepic(); drawptr = mydraw1; timestuff(-60, ctrllepic, draw, 2000000); drawptr = mydraw; /*timestuff(60, NULL, draw, 4 * 1000000); */ /*timestuff(20, blur, draw, 4 * 1000000); */ timestuff(60, NULL, draw, 3 * 1000000); }
INT32 os_create_process(char *name, void *test_name, INT32 initial_prriority,INT32 *pid_ptr,INT32 *p_error_prt, INT32 status) { S_PCB *PCB_PTR = NULL; if(initial_prriority == ILLEGAL) { *p_error_prt = ERR_BAD_PARAM; return -1; } if(readyHead != NULL) { S_PCB *temp =readyHead; while(temp != NULL) { if(strcmp(temp->p_name, name) == 0) { printf("same name error"); (*p_error_prt) = ERR_BAD_PARAM; return -1; } else { temp = temp->next; } } } if(timerHead != NULL) { S_PCB *temp =timerHead; while(temp != NULL) { if(strcmp(temp->p_name, name) == 0) { printf("same name error"); (*p_error_prt) = ERR_BAD_PARAM; return -1; } else { temp = temp->next; } }} //check total pid (*p_error_prt) = ERR_BAD_PARAM; PCB_PTR = (S_PCB*)(malloc(sizeof(S_PCB))); PCB_PTR-> p_time = 0; PCB_PTR->p_status = status; PCB_PTR->p_position = CREATE; PCB_PTR->p_id = PCBSTRARTID; (*pid_ptr) = PCBSTRARTID; PCBSTRARTID++; PCB_PTR->p_time = 0; PCB_PTR->p_priority = initial_prriority; strcpy(PCB_PTR->p_name, name); if(PCBSTRARTID >MAXPROCESS) { *p_error_prt = TOOMUCHPROCESSES; return -1; } make_context(PCB_PTR, test_name); if(status == RUN) { addToReadyQ(PCB_PTR); Dispatcher(); } else { addToReadyQ(PCB_PTR); *p_error_prt = ERR_SUCCESS; } return 0; }
/* Accepts the mipmap dir, the output filename */ int main(int argc, char *argv[]) { /* Get arguments */ char * output_dir = argv[1]; char * filename = argv[2]; /* Create GLES2 context */ make_context(); /* List directories (adapted from scandir manpage) */ struct dirent **namelist; int levels = scandir(output_dir, &namelist, no_dot_output_filter, alphasort); if (levels < 0) perror("scandir"); /* Structs used to write the final output */ KTX_texture_info tex_info; KTX_image_info *img_info = (KTX_image_info*)malloc(levels * sizeof(KTX_image_info)); int cur_lev; char cur_path[4096]; /* Write a file from Memory */ /* Write memory object to file */ strcpy(cur_path, output_dir); strcat(cur_path, filename); FILE* fileo = fopen(cur_path, "wb"); if (fileo == NULL) printf("File not opened\n"); for (cur_lev = 0; cur_lev < levels; ++cur_lev) { /* Create full file path */ char * cur_file = namelist[cur_lev]->d_name; strcpy(cur_path, output_dir); strcat(cur_path, cur_file); //printf("%s\n", cur_path); /* Read in the file from memory */ FILE* file = fopen(cur_path, "rb"); if (file == NULL) printf("File not opened\n"); /* Read the identifier and endianness */ uint32_t header_top[4]; size_t size_read = fread(header_top, 1, 16, file); if (size_read < 16) printf("bad read 0\n"); /* Read the appropriate header bits */ KTX_texture_info ltex_info; size_read = fread(<ex_info, 1, sizeof(ltex_info), file); if (size_read < sizeof(ltex_info)) printf("bad read 1\n"); /* Skip the bytes of Key Value Data */ int error = fseek(file, 4, SEEK_CUR); if (error) printf("File seek bad\n"); /* Get the image size */ GLsizei *lsize = &img_info[cur_lev].size; GLubyte **ldata = &img_info[cur_lev].data; size_read = fread(lsize, 1, 4, file); if (size_read < 4) printf("bad read 2\n"); /* Get the image data */ *ldata = (GLubyte*) malloc(*lsize); size_read = fread(*ldata, 1, *lsize, file); if (size_read < *lsize) printf("bad read 2\n"); /* Clean up */ free(namelist[cur_lev]); /* Close the file */ if (file != NULL) fclose(file); /* Fill out final struct */ if (cur_lev == 0) { memcpy(&tex_info, <ex_info, sizeof(ltex_info)); /* Update the mipmap section */ tex_info.numberOfMipmapLevels = levels; /* Update the final file with this data */ uint32_t nokvdat = 0; fwrite(header_top, 16, 1, fileo); fwrite(&tex_info, sizeof(tex_info), 1, fileo); fwrite(&nokvdat, sizeof(nokvdat), 1, fileo); } /* Update the final file with this data */ fwrite(lsize, sizeof(GLubyte), 1, fileo); fwrite(*ldata, *lsize, 1, fileo); /* mip padding */ error = fseek(fileo, 3-((*lsize+3) % 4), SEEK_CUR); if (error) printf("File seek bad\n"); } ///KTX_error_code kec; ///kec = ktxWriteKTXN(cur_path, &tex_info, 0, NULL, levels, img_info); ///printf("%s - %s\n", cur_path, ktxErrorString(kec)); /* Close the file */ if (fileo != NULL) fclose(fileo); /* Cleanup */ free(namelist); for (cur_lev = 0; cur_lev < levels; ++cur_lev) free(img_info[cur_lev].data); free(img_info); return 0; }