Skip to content

Commit

Permalink
examples/devpmtest: kill some tests cases when drawing to a memory pi…
Browse files Browse the repository at this point in the history
…xelmap

It doesn't support format conversions.
  • Loading branch information
vs49688 committed May 10, 2024
1 parent fceb84b commit f805651
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions examples/devpmtest/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ typedef struct br_smpte_state {
br_pixelmap *pm;
} br_smpte_state;

static void smpte_fini(void *user)
{
br_smpte_state *state = user;
BrPixelmapFree(state->pm);
}

static br_error smpte_init(void *user, br_pixelmap *screen, br_pixelmap *backbuffer, void *arg)
{
br_smpte_state *state = user;
Expand All @@ -180,6 +186,12 @@ static br_error smpte_init(void *user, br_pixelmap *screen, br_pixelmap *backbuf
return BRE_FAIL;
}

if(ObjectDevice(backbuffer) == NULL && state->pm->type != backbuffer->type) {
BrLogError("APP", "Disabling SMPTE type %d due to memory device format %d", state->pm->type, backbuffer->type);
smpte_fini(state);
return BRE_FAIL;
}

return BRE_OK;
}

Expand All @@ -193,12 +205,6 @@ static void smpte_draw(br_pixelmap *dest, float dt, void *user)
BrPixelmapRectangleCopy(dest, base_x, base_y, pm, -pm->origin_x, -pm->origin_y, pm->width, pm->height);
}

static void smpte_fini(void *user)
{
br_smpte_state *state = user;
BrPixelmapFree(state->pm);
}

typedef struct br_index8nopal_state {
br_pixelmap *earth;
br_pixelmap *pal_std;
Expand Down Expand Up @@ -508,6 +514,15 @@ static br_error submap_init(void *user, br_pixelmap *screen, br_pixelmap *backbu
return BRE_FAIL;
}

/*
* Memory pixelmaps don't support copying different types.
*/
if(ObjectDevice(state->checkerboard_device) == NULL) {
BrLogWarn("APP", "Disable Sub-pixelmap test due to memory device.");
submap_fini(user);
return BRE_FAIL;
}

BrPixelmapCopy(state->checkerboard_device, state->checkerboard_memory);

if((state->middle_square = BrPixelmapAllocateSub(backbuffer, -300, -300, 600, 600)) == NULL) {
Expand Down

0 comments on commit f805651

Please sign in to comment.