static void UpdateYUVTextureData(SDL_Texture * texture) { D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; SDL_Rect rect; RECT d3drect; D3DLOCKED_RECT locked; HRESULT result; d3drect.left = 0; d3drect.right = texture->w; d3drect.top = 0; d3drect.bottom = texture->h; result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); if (FAILED(result)) { return; } rect.x = 0; rect.y = 0; rect.w = texture->w; rect.h = texture->h; SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, texture->h, locked.pBits, locked.Pitch); IDirect3DTexture9_UnlockRect(data->texture, 0); }
static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect) { SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata; SDL_Window *window = renderer->window; SDL_VideoDisplay *display = window->display; if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { SDL_Surface *target = data->screens[data->current_screen]; void *pixels = (Uint8 *) target->pixels + dstrect->y * target->pitch + dstrect->x * target->format->BytesPerPixel; return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata, srcrect, display->current_mode.format, dstrect->w, dstrect->h, pixels, target->pitch); } else { SDL_Surface *surface = (SDL_Surface *) texture->driverdata; SDL_Surface *target = data->screens[data->current_screen]; SDL_Rect real_srcrect = *srcrect; SDL_Rect real_dstrect = *dstrect; return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect); } }
static int SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch) { SDL_Texture *native = texture->native; SDL_Rect full_rect; if (SDL_SW_UpdateYUVTexture(texture->yuv, rect, pixels, pitch) < 0) { return -1; } full_rect.x = 0; full_rect.y = 0; full_rect.w = texture->w; full_rect.h = texture->h; rect = &full_rect; if (texture->access == SDL_TEXTUREACCESS_STREAMING) { /* We can lock the texture and copy to it */ void *native_pixels; int native_pitch; if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { return -1; } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, rect->w, rect->h, native_pixels, native_pitch); SDL_UnlockTexture(native); } else { /* Use a temporary buffer for updating */ void *temp_pixels; int temp_pitch; temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); temp_pixels = SDL_malloc(rect->h * temp_pitch); if (!temp_pixels) { SDL_OutOfMemory(); return -1; } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, rect->w, rect->h, temp_pixels, temp_pitch); SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); SDL_free(temp_pixels); } return 0; }
static void UpdateYUVTextureData(SDL_Texture * texture) { X11_TextureData *data = (X11_TextureData *) texture->driverdata; SDL_Rect rect; rect.x = 0; rect.y = 0; rect.w = texture->w; rect.h = texture->h; SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, texture->h, data->pixels, data->pitch); }
static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect) { SW_RenderData *data = (SW_RenderData *) renderer->driverdata; //SDL_Window *window = SDL_GetWindowFromID(renderer->window); int status; if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { SDL_AddDirtyRect(&data->dirty, dstrect); } if (data->renderer->LockTexture(data->renderer, data->texture[data->current_texture], dstrect, 1, &data->surface.pixels, &data->surface.pitch) < 0) { return -1; } if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { status = SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata, srcrect, data->format, dstrect->w, dstrect->h, data->surface.pixels, data->surface.pitch); } else { SDL_Surface *surface = (SDL_Surface *) texture->driverdata; SDL_Rect real_srcrect = *srcrect; SDL_Rect real_dstrect; data->surface.w = dstrect->w; data->surface.h = dstrect->h; data->surface.clip_rect.w = dstrect->w; data->surface.clip_rect.h = dstrect->h; real_dstrect = data->surface.clip_rect; status = SDL_LowerBlit(surface, &real_srcrect, &data->surface, &real_dstrect); } data->renderer->UnlockTexture(data->renderer, data->texture[data->current_texture]); return status; }
static void SDL_UnlockTextureYUV(SDL_Texture * texture) { SDL_Texture *native = texture->native; void *native_pixels; int native_pitch; SDL_Rect rect; rect.x = 0; rect.y = 0; rect.w = texture->w; rect.h = texture->h; if (SDL_LockTexture(native, &rect, &native_pixels, &native_pitch) < 0) { return; } SDL_SW_CopyYUVToRGB(texture->yuv, &rect, native->format, rect.w, rect.h, native_pixels, native_pitch); SDL_UnlockTexture(native); }