int move(){ int done = 0; Uint32 slowdown, slowdown2 = SDL_GetTicks(); hero tux = {1, 0, 0, 0, 0, 0, 1, gd->screen.width/NASOBIC_1, 25, 39, 0}; map_info map = {NULL, (7*gd->screen.height)/BACK_Y, 0, 0, 0, gd->screen.height - tux.h, 0}; SDL_Rect src = { 0, BACK_Y, gd->screen.width, gd->screen.height}; SDL_Rect pst = { gd->screen.width/2, gd->screen.height - tux.h, 0, 0}; platform **first_plat = (platform **)malloc(sizeof(platform *)), **last_plat = (platform **)malloc(sizeof(platform *)); if(!move_init(&map, tux, first_plat, last_plat)) return 0; while(!done){ if(!screen_blit(map.surface, &src, &pst, tux)) return 0; slowdown = SDL_GetTicks(); if((slowdown-slowdown2)<FRAME_WAIT) SDL_Delay(FRAME_WAIT-slowdown+slowdown2); slowdown2 = SDL_GetTicks(); if(!keys(&pst, &tux, map.limit)) return 0; if(!data_handling(&pst, &src, &tux, &map, first_plat, last_plat)) done = 1; } return 1; }
void display_frame(ffdec_context *ffd_context, AVFrame *frame) { ffdec_reserved *ffd_reserved = (ffdec_reserved*) ffd_context->reserved; ffdec_view *view = ffd_reserved->view; if (!view) return; screen_window_t screen_window = view->screen_window; screen_buffer_t screen_pixel_buffer = view->screen_pixel_buffer; screen_context_t screen_context = view->screen_context; int stride = view->stride; unsigned char *ptr = NULL; screen_get_buffer_property_pv(screen_pixel_buffer, SCREEN_PROPERTY_POINTER, (void**) &ptr); int width = frame->width; int height = frame->height; uint8_t *srcy = frame->data[0]; uint8_t *srcu = frame->data[1]; uint8_t *srcv = frame->data[2]; unsigned char *y = ptr; unsigned char *u = y + (height * stride); unsigned char *v = u + (height * stride) / 4; for (int i = 0; i < height; i++) { int doff = i * stride; int soff = i * frame->linesize[0]; memcpy(&y[doff], &srcy[soff], frame->width); } for (int i = 0; i < height / 2; i++) { int doff = i * stride / 2; int soff = i * frame->linesize[1]; memcpy(&u[doff], &srcu[soff], frame->width / 2); } for (int i = 0; i < height / 2; i++) { int doff = i * stride / 2; int soff = i * frame->linesize[2]; memcpy(&v[doff], &srcv[soff], frame->width / 2); } screen_buffer_t screen_buffer; screen_get_window_property_pv(screen_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &screen_buffer); int attribs[] = { SCREEN_BLIT_SOURCE_WIDTH, width, SCREEN_BLIT_SOURCE_HEIGHT, height, SCREEN_BLIT_END }; screen_blit(screen_context, screen_buffer, screen_pixel_buffer, attribs); int dirty_rects[] = { 0, 0, width, height }; screen_post_window(screen_window, screen_buffer, 1, dirty_rects, 0); }
void QQnxRasterWindow::blitPreviousToCurrent(const QRegion ®ion, int dx, int dy, bool flush) { qRasterWindowDebug() << Q_FUNC_INFO << "window =" << window(); // Abort if previous buffer is invalid or if nothing to copy if (m_previousBufferIndex == -1 || region.isEmpty()) return; QQnxBuffer ¤tBuffer = m_buffers[m_currentBufferIndex]; QQnxBuffer &previousBuffer = m_buffers[m_previousBufferIndex]; // Break down region into non-overlapping rectangles const QVector<QRect> rects = region.rects(); for (int i = rects.size() - 1; i >= 0; i--) { // Clip rectangle to bounds of target const QRect rect = rects[i].intersected(currentBuffer.rect()); if (rect.isEmpty()) continue; // Setup blit operation int attribs[] = { SCREEN_BLIT_SOURCE_X, rect.x(), SCREEN_BLIT_SOURCE_Y, rect.y(), SCREEN_BLIT_SOURCE_WIDTH, rect.width(), SCREEN_BLIT_SOURCE_HEIGHT, rect.height(), SCREEN_BLIT_DESTINATION_X, rect.x() + dx, SCREEN_BLIT_DESTINATION_Y, rect.y() + dy, SCREEN_BLIT_DESTINATION_WIDTH, rect.width(), SCREEN_BLIT_DESTINATION_HEIGHT, rect.height(), SCREEN_BLIT_END }; // Queue blit operation Q_SCREEN_CHECKERROR(screen_blit(m_screenContext, currentBuffer.nativeBuffer(), previousBuffer.nativeBuffer(), attribs), "Failed to blit buffers"); } // Check if flush requested if (flush) { // Wait for all blits to complete Q_SCREEN_CHECKERROR(screen_flush_blits(m_screenContext, SCREEN_WAIT_IDLE), "Failed to flush blits"); // Buffer was modified outside the CPU currentBuffer.invalidateInCache(); } }
void Control::draw(screen_buffer_t buffer) const { screen_get_pixmap_property_pv(m_pixmap, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&m_buffer); int attribs[] = { SCREEN_BLIT_SOURCE_X, 0, SCREEN_BLIT_SOURCE_Y, 0, SCREEN_BLIT_SOURCE_WIDTH, m_srcWidth, SCREEN_BLIT_SOURCE_HEIGHT, m_srcHeight, SCREEN_BLIT_DESTINATION_X, m_x, SCREEN_BLIT_DESTINATION_Y, m_y, SCREEN_BLIT_DESTINATION_WIDTH, m_width, SCREEN_BLIT_DESTINATION_HEIGHT, m_height, SCREEN_BLIT_TRANSPARENCY, SCREEN_TRANSPARENCY_NONE, SCREEN_BLIT_GLOBAL_ALPHA, 0x30, SCREEN_BLIT_END }; screen_blit(m_context, buffer, m_buffer, attribs); }
static void bb10display_fillWindowBuffer(BB10Display *d, MSPicture *yuvbuf) { uint8_t *ptr = NULL; screen_get_buffer_property_pv(d->pixmap_buffer, SCREEN_PROPERTY_POINTER, (void **)&ptr); if (ptr) { uint8_t *dest_planes[3]; int dest_strides[3]; MSVideoSize roi = {0}; uint8_t *y = ptr; uint8_t *u = y + (d->vsize.height * d->stride); uint8_t *v = u + (d->vsize.height * d->stride) / 4; dest_planes[0] = y; dest_planes[1] = u; dest_planes[2] = v; dest_strides[0] = d->stride; dest_strides[1] = d->stride / 2; dest_strides[2] = d->stride / 2; roi.width = yuvbuf->w; roi.height = yuvbuf->h; ms_yuv_buf_copy(yuvbuf->planes, yuvbuf->strides, dest_planes, dest_strides, roi); screen_buffer_t buffer; screen_get_window_property_pv(d->window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &buffer); MSRect rect; ms_layout_center_rectangle(d->wsize, d->vsize, &rect); int attributes[] = { SCREEN_BLIT_SOURCE_WIDTH, d->vsize.width, SCREEN_BLIT_SOURCE_HEIGHT, d->vsize.height, SCREEN_BLIT_DESTINATION_X, rect.x, SCREEN_BLIT_DESTINATION_Y, rect.y, SCREEN_BLIT_DESTINATION_WIDTH, rect.w, SCREEN_BLIT_DESTINATION_HEIGHT, rect.h, SCREEN_BLIT_END }; screen_blit(d->context, buffer, d->pixmap_buffer, attributes); int dirty_rect[4] = { 0, 0, d->wsize.width, d->wsize.height }; screen_post_window(d->window, buffer, 1, dirty_rect, 0); } }
int ShowVideo(void) { Image *Output; int SX,SY; /* Must have active video image, X11 display */ if(!VideoImg||!VideoImg->Data) return(0); /* Allocate image buffer if none */ if(!OutImg.Data&&!NewImage(&OutImg,XSize,YSize)) return(0); /* Count framerate */ if((Effects&EFF_SHOWFPS)&&(++FrameCount>=120)) { struct timeval NewTS; int Time; gettimeofday(&NewTS,0); Time = (NewTS.tv_sec-TimeStamp.tv_sec)*1000 + (NewTS.tv_usec-TimeStamp.tv_usec)/1000; FrameRate = 1000*FrameCount/(Time>0? Time:1); TimeStamp = NewTS; FrameCount = 0; FrameRate = FrameRate>999? 999:FrameRate; } /* If not scaling or post-processing image, avoid extra work */ if(!(Effects&(EFF_SOFTEN|EFF_SCALE|EFF_TVLINES))) { /* Show framerate if requested */ if((Effects&EFF_SHOWFPS)&&(FrameRate>0)) { char S[8]; sprintf(S,"%02dfps",FrameRate); PrintXY(VideoImg,S, 8,8, FPS_COLOR,PIXEL(255,255,255) ); } screen_buffer_t screen_buf[1]; screen_get_window_property_pv(window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)screen_buf); int bg[] = { SCREEN_BLIT_END }; screen_blit(ctxt, screen_buf[0], VideoImg->pbuf, bg); screen_post_window(window, screen_buf[0], 1, rect, 0); return 1; } /* By default, we will be showing OutImg */ Output = &OutImg; SX = 0; SY = 0; if(Effects&EFF_SOFTEN) { /* Apply softening */ SoftenImage(&OutImg,VideoImg,VideoX,VideoY,VideoW,VideoH); /* Apply TV scanlines, if needed */ if(Effects&EFF_TVLINES) TelevizeImage(&OutImg,0,0,OutImg.W,OutImg.H); } else if(Effects&EFF_TVLINES) { if(Effects&EFF_SCALE) { /* Scale VideoImg into OutImg */ ScaleImage(&OutImg,VideoImg,VideoX,VideoY,VideoW,VideoH); /* Apply TV scanlines */ TelevizeImage(&OutImg,0,0,OutImg.W,OutImg.H); } else { /* Center VideoImg in OutImg */ IMGCopy(&OutImg,(OutImg.W-VideoW)>>1,(OutImg.H-VideoH)>>1,VideoImg,VideoX,VideoY,VideoW,VideoH,-1); /* Apply TV scanlines */ TelevizeImage(&OutImg,(OutImg.W-VideoW)>>1,(OutImg.H-VideoH)>>1,VideoW,VideoH); } } else if((OutImg.W==VideoW)&&(OutImg.H==VideoH))
static int do_splash(int argc, char *argv[]) { struct surface s; struct screen sc; int ret, opt, fd; char *fbdev = "/dev/fb0"; char *image_file; int offscreen = 0; u32 bg_color = 0x00000000; bool do_bg = false; memset(&s, 0, sizeof(s)); memset(&sc, 0, sizeof(sc)); s.x = -1; s.y = -1; s.width = -1; s.height = -1; while((opt = getopt(argc, argv, "f:x:y:ob:")) > 0) { switch(opt) { case 'f': fbdev = optarg; break; case 'b': bg_color = simple_strtoul(optarg, NULL, 0); do_bg = true; break; case 'x': s.x = simple_strtoul(optarg, NULL, 0); break; case 'y': s.y = simple_strtoul(optarg, NULL, 0); case 'o': offscreen = 1; } } if (optind == argc) { printf("no filename given\n"); return 1; } image_file = argv[optind]; fd = fb_open(fbdev, &sc, offscreen); if (fd < 0) { perror("fd_open"); return 1; } if (sc.offscreenbuf) { if (do_bg) memset_pixel(&sc.info, sc.offscreenbuf, bg_color, sc.s.width * sc.s.height); else memcpy(sc.offscreenbuf, sc.fb, sc.fbsize); } else if (do_bg) { memset_pixel(&sc.info, sc.fb, bg_color, sc.s.width * sc.s.height); } if (image_renderer_file(&sc, &s, image_file) < 0) ret = 1; screen_blit(&sc); fb_close(&sc); return ret; }