Renamed driverdata to internal
This was done to SDL_DisplayMode for consistency with SDL_Surface and gives it a type so we don't have to do casts in SDL code. I considered switching to an ID and hashing the driver data, etc. but all of that involved a lot of internal code churn and this solution gives us flexibility in how we handle this in the future. After consideration, I made this renaming global across the project, for consistency. Fixes https://github.com/libsdl-org/SDL/issues/10198
This commit is contained in:
@@ -53,7 +53,7 @@ typedef struct
|
||||
|
||||
static SDL_Surface *SW_ActivateRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->internal;
|
||||
|
||||
if (!data->surface) {
|
||||
data->surface = data->window;
|
||||
@@ -69,7 +69,7 @@ static SDL_Surface *SW_ActivateRenderer(SDL_Renderer *renderer)
|
||||
|
||||
static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->internal;
|
||||
|
||||
if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) {
|
||||
data->surface = NULL;
|
||||
@@ -79,7 +79,7 @@ static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
|
||||
static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->internal;
|
||||
|
||||
if (data->surface) {
|
||||
if (w) {
|
||||
@@ -107,7 +107,7 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return SDL_SetError("Cannot create surface");
|
||||
}
|
||||
texture->driverdata = surface;
|
||||
texture->internal = surface;
|
||||
r = (Uint8)SDL_roundf(SDL_clamp(texture->color.r, 0.0f, 1.0f) * 255.0f);
|
||||
g = (Uint8)SDL_roundf(SDL_clamp(texture->color.g, 0.0f, 1.0f) * 255.0f);
|
||||
b = (Uint8)SDL_roundf(SDL_clamp(texture->color.b, 0.0f, 1.0f) * 255.0f);
|
||||
@@ -129,7 +129,7 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->internal;
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
@@ -156,7 +156,7 @@ static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->internal;
|
||||
|
||||
*pixels =
|
||||
(void *)((Uint8 *)surface->pixels + rect->y * surface->pitch +
|
||||
@@ -175,10 +175,10 @@ static void SW_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->internal;
|
||||
|
||||
if (texture) {
|
||||
data->surface = (SDL_Surface *)texture->driverdata;
|
||||
data->surface = (SDL_Surface *)texture->internal;
|
||||
} else {
|
||||
data->surface = data->window;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
const SDL_Rect *srcrect, const SDL_Rect *final_rect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_FlipMode flip, float scale_x, float scale_y)
|
||||
{
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Surface *src = (SDL_Surface *)texture->internal;
|
||||
SDL_Rect tmp_rect;
|
||||
SDL_Surface *src_clone, *src_rotated, *src_scaled;
|
||||
SDL_Surface *mask = NULL, *mask_rotated = NULL;
|
||||
@@ -624,7 +624,7 @@ static void PrepTextureForCopy(const SDL_RenderCommand *cmd, SW_DrawStateCache *
|
||||
const Uint8 a = drawstate->color.a;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->internal;
|
||||
const SDL_bool colormod = ((r & g & b) != 0xFF);
|
||||
const SDL_bool alphamod = (a != 0xFF);
|
||||
const SDL_bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL));
|
||||
@@ -812,7 +812,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const SDL_Rect *srcrect = verts;
|
||||
SDL_Rect *dstrect = verts + 1;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Surface *src = (SDL_Surface *)texture->internal;
|
||||
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
@@ -900,7 +900,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
if (texture) {
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Surface *src = (SDL_Surface *)texture->internal;
|
||||
|
||||
GeometryCopyData *ptr = (GeometryCopyData *)verts;
|
||||
|
||||
@@ -996,7 +996,7 @@ static int SW_RenderPresent(SDL_Renderer *renderer)
|
||||
|
||||
static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->internal;
|
||||
|
||||
SDL_DestroySurface(surface);
|
||||
}
|
||||
@@ -1004,7 +1004,7 @@ static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static void SW_DestroyRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->internal;
|
||||
|
||||
if (window) {
|
||||
SDL_DestroyWindowSurface(window);
|
||||
@@ -1147,7 +1147,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
||||
renderer->RenderPresent = SW_RenderPresent;
|
||||
renderer->DestroyTexture = SW_DestroyTexture;
|
||||
renderer->DestroyRenderer = SW_DestroyRenderer;
|
||||
renderer->driverdata = data;
|
||||
renderer->internal = data;
|
||||
SW_InvalidateCachedState(renderer);
|
||||
|
||||
renderer->name = SW_RenderDriver.name;
|
||||
|
||||
Reference in New Issue
Block a user