static gxj_pixel_type* startDirectPaint(int &dstWidth, int &dstHeight, int &dstYPitch) { gxj_pixel_type *dst = NULL; #if JWC_WINCE_USE_DIRECT_DRAW if (isScreenRotated() || !isScreenFullyVisible() || editBoxShown) { /* DDraw is not very reliable on an rotated screen. Use GDI instead. */ return NULL; } if (g_pDD == NULL) { /* DirectDraw failed to initialize. Let's use GDI to Blit to the LCD. */ return NULL; } HRESULT hRet; DDSURFACEDESC surfaceDesc; DDSURFACEDESC ddsd; if (g_pDDSPrimary == NULL) { /* Create the primary surface with 0 back buffer */ memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE ; hRet = g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL); if (hRet != DD_OK) { g_pDDSPrimary = NULL; return NULL; } } surfaceDesc.dwSize = sizeof(surfaceDesc); hRet = g_pDDSPrimary->Lock(NULL, &surfaceDesc, DDLOCK_DISCARD | DDLOCK_WRITEONLY, NULL); if (hRet == DD_OK) { dst = (gxj_pixel_type*)surfaceDesc.lpSurface; dstWidth = surfaceDesc.dwWidth; dstHeight = surfaceDesc.dwHeight; dstYPitch = surfaceDesc.lPitch; } else { /* Release the DD resources. Maybe we'd get lucky and can allocate * it next time. */ g_pDDSPrimary->Release(); g_pDDSPrimary = NULL; return NULL; } #else if (editBoxShown) { return NULL; } dstWidth = gxDispProps.cxWidth; dstHeight = gxDispProps.cyHeight; dstYPitch = gxDispProps.cbyPitch; dst = (gxj_pixel_type*)GXBeginDraw(); #endif return dst; }
static int Lock(picture_t *picture) { vout_display_t *vd = picture->p_sys->vd; vout_display_sys_t *sys = vd->sys; /* */ if (sys->rect_dest_clipped.right - sys->rect_dest_clipped.left != vd->fmt.i_width || sys->rect_dest_clipped.bottom - sys->rect_dest_clipped.top != vd->fmt.i_height) return VLC_EGENERIC; /* */ GXDisplayProperties gxdisplayprop = GXGetDisplayProperties(); uint8_t *p_pic_buffer = GXBeginDraw(); if (!p_pic_buffer) { msg_Err(vd, "GXBeginDraw error %d ", GetLastError()); return VLC_EGENERIC; } p_pic_buffer += sys->rect_dest.top * gxdisplayprop.cbyPitch + sys->rect_dest.left * gxdisplayprop.cbxPitch; /* */ picture->p[0].i_pitch = gxdisplayprop.cbyPitch; picture->p[0].p_pixels = p_pic_buffer; return VLC_SUCCESS; }
extern "C" void * GXBEGINDRAW() { #ifndef _USE_GAPI_ if(gx->BeginDraw()) return gx->GetFBAddress(); return NULL; #else return GXBeginDraw(); #endif }
bool SkWindow::update(SkIRect* updateArea) { if (!fDirtyRgn.isEmpty()) { SkBitmap bm = this->getBitmap(); #if defined(SK_BUILD_FOR_WINCE) && defined(USE_GX_SCREEN) char* buffer = (char*)GXBeginDraw(); SkASSERT(buffer); RECT rect; GetWindowRect((HWND)((SkOSWindow*)this)->getHWND(), &rect); buffer += rect.top * gDisplayProps.cbyPitch + rect.left * gDisplayProps.cbxPitch; bm.setPixels(buffer); #endif SkAutoTUnref<SkSurface> surface(this->createSurface()); SkCanvas* canvas = surface->getCanvas(); canvas->clipRegion(fDirtyRgn); if (updateArea) *updateArea = fDirtyRgn.getBounds(); SkAutoCanvasRestore acr(canvas, true); canvas->concat(fMatrix); // empty this now, so we can correctly record any inval calls that // might be made during the draw call. fDirtyRgn.setEmpty(); #ifdef SK_SIMULATE_FAILED_MALLOC gEnableControlledThrow = true; #endif #ifdef SK_BUILD_FOR_WIN32 //try { this->draw(canvas); //} //catch (...) { //} #else this->draw(canvas); #endif #ifdef SK_SIMULATE_FAILED_MALLOC gEnableControlledThrow = false; #endif #if defined(SK_BUILD_FOR_WINCE) && defined(USE_GX_SCREEN) GXEndDraw(); #endif return true; } return false; }
static GF_Err GAPI_FlipBackBuffer(GF_VideoOutput *dr) { GF_VideoSurface src, dst; unsigned char *ptr; GAPICTX(dr); if (!gctx || !gctx->gx_mode) return GF_BAD_PARAM; /*get a pointer to video memory*/ if (gctx->gx_mode==1) { ptr = (unsigned char *) GXBeginDraw(); } else { ptr = (unsigned char *) gctx->raw_ptr; } if (!ptr) return GF_IO_ERR; src.video_buffer = gctx->backbuffer; src.width = gctx->bb_width; src.height = gctx->bb_height; src.pitch_x = gctx->BPP; src.pitch_y = gctx->y_pitch; src.pixel_format = gctx->pixel_format; src.is_hardware_memory = 0; dst.width = gctx->dst_blt.w; dst.height = gctx->dst_blt.h; dst.pixel_format = gctx->pixel_format; dst.is_hardware_memory = 1; dst.video_buffer = (char*)ptr; dst.pitch_x = gctx->x_pitch; dst.pitch_y = gctx->y_pitch; if (gctx->fullscreen) { if (gctx->erase_dest) { gctx->erase_dest = 0; GAPI_ClearFS(gctx, ptr); } } else { gctx->dst_blt.x += gctx->off_x; gctx->dst_blt.y += gctx->off_y; } /*apply x/y offset*/ if (!gctx->fullscreen) dst.video_buffer += gctx->dst_blt.x * gctx->x_pitch + gctx->y_pitch * gctx->dst_blt.y; if (gctx->contiguous_mem) { memcpy(dst.video_buffer, src.video_buffer, src.width*gctx->BPP*src.height ); } else if (landscape) { u32 y, lsize = dst.height*gctx->x_pitch; for (y=0; y<dst.width; y++) { char *s = src.video_buffer + y*gctx->y_pitch; char *d = dst.video_buffer + y*gctx->y_pitch; memcpy(d, s, lsize); } } else { u32 y, lsize = dst.width*gctx->x_pitch; for (y=0; y<dst.height; y++) { char *s = src.video_buffer + y*gctx->y_pitch; char *d = dst.video_buffer + y*gctx->y_pitch; memcpy(d, s, lsize); } } if (gctx->gx_mode==1) GXEndDraw(); return GF_OK; }