void d3d_lock_rectangle_clear(LPDIRECT3DTEXTURE tex, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned rectangle_height, unsigned flags) { #if defined(_XBOX) level = 0; #endif memset(lock_rect->pBits, level, rectangle_height * lock_rect->Pitch); d3d_unlock_rectangle(tex); }
static bool d3d_overlay_load(void *data, const void *image_data, unsigned num_images) { unsigned i, y; d3d_video_t *d3d = (d3d_video_t*)data; const struct texture_image *images = (const struct texture_image*) image_data; if (!d3d) return false; d3d_free_overlays(d3d); d3d->overlays.resize(num_images); for (i = 0; i < num_images; i++) { D3DLOCKED_RECT d3dlr; unsigned width = images[i].width; unsigned height = images[i].height; overlay_t *overlay = (overlay_t*)&d3d->overlays[i]; overlay->tex = d3d_texture_new(d3d->dev, NULL, width, height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL); if (!overlay->tex) { RARCH_ERR("[D3D]: Failed to create overlay texture\n"); return false; } if (d3d_lock_rectangle(overlay->tex, 0, &d3dlr, NULL, 0, D3DLOCK_NOSYSLOCK)) { uint32_t *dst = (uint32_t*)(d3dlr.pBits); const uint32_t *src = images[i].pixels; unsigned pitch = d3dlr.Pitch >> 2; for (y = 0; y < height; y++, dst += pitch, src += width) memcpy(dst, src, width << 2); d3d_unlock_rectangle(overlay->tex); } overlay->tex_w = width; overlay->tex_h = height; /* Default. Stretch to whole screen. */ d3d_overlay_tex_geom(d3d, i, 0, 0, 1, 1); d3d_overlay_vertex_geom(d3d, i, 0, 0, 1, 1); }
void d3d_texture_blit(unsigned pixel_size, LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame, unsigned width, unsigned height, unsigned pitch) { if (d3d_lock_rectangle(tex, 0, lr, NULL, 0, 0)) { #if defined(_XBOX360) && defined(_XBOX360) D3DSURFACE_DESC desc; tex->GetLevelDesc(0, &desc); XGCopySurface(lr->pBits, lr->Pitch, width, height, desc.Format, NULL, frame, pitch, desc.Format, NULL, 0, 0); #else unsigned y; for (y = 0; y < height; y++) { const uint8_t *in = (const uint8_t*)frame + y * pitch; uint8_t *out = (uint8_t*)lr->pBits + y * lr->Pitch; memcpy(out, in, width * pixel_size); } #endif d3d_unlock_rectangle(tex); } }