Skip to content

Commit

Permalink
Remove screen_surface
Browse files Browse the repository at this point in the history
Seems to be an unneccessary step between the accumulation_surface and the screen, probably leftover from SDL 1.2 before screen_tex was a thing
  • Loading branch information
TellowKrinkle committed Jun 12, 2021
1 parent ba29850 commit 8007b6d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
9 changes: 1 addition & 8 deletions src/PonscripterLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,10 +1210,6 @@ int PonscripterLabel::init(const char* preferred_script)
image_surface = SDL_CreateRGBSurface(0, 1, 1, 32, 0x00ff0000,
0x0000ff00, 0x000000ff, 0xff000000);

screen_surface = SDL_CreateRGBSurface(0, screen_width, screen_height, 32, 0x00ff0000,
0x0000ff00, 0x000000ff, 0xff000000);


accumulation_surface =
AnimationInfo::allocSurface(screen_width, screen_height);
backup_surface =
Expand All @@ -1229,10 +1225,8 @@ int PonscripterLabel::init(const char* preferred_script)
SDL_SetSurfaceAlphaMod(effect_src_surface, SDL_ALPHA_OPAQUE);
SDL_SetSurfaceAlphaMod(effect_dst_surface, SDL_ALPHA_OPAQUE);
SDL_SetSurfaceAlphaMod(effect_tmp_surface, SDL_ALPHA_OPAQUE);
SDL_SetSurfaceAlphaMod(screen_surface, SDL_ALPHA_OPAQUE);

SDL_SetSurfaceBlendMode(accumulation_surface, SDL_BLENDMODE_NONE);
SDL_SetSurfaceBlendMode(screen_surface, SDL_BLENDMODE_NONE);
SDL_SetSurfaceBlendMode(backup_surface, SDL_BLENDMODE_NONE);
SDL_SetSurfaceBlendMode(effect_src_surface, SDL_BLENDMODE_NONE);
SDL_SetSurfaceBlendMode(effect_dst_surface, SDL_BLENDMODE_NONE);
Expand Down Expand Up @@ -1472,9 +1466,8 @@ void PonscripterLabel::flushDirect(SDL_Rect &rect, int refresh_mode, bool update
refreshSurface(accumulation_surface, &rect, refresh_mode);

if(!updaterect) return;
SDL_BlitSurface(accumulation_surface, &rect, screen_surface, &rect);

if(SDL_UpdateTexture(screen_tex, NULL, screen_surface->pixels, screen_surface->pitch)) {
if(SDL_UpdateTexture(screen_tex, NULL, accumulation_surface->pixels, accumulation_surface->pitch)) {
fprintf(stderr,"Error updating texture: %s\n", SDL_GetError());
}
}
Expand Down
1 change: 0 additions & 1 deletion src/PonscripterLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ class PonscripterLabel : public ScriptParser {
SDL_Surface* backup_surface;
// Text + Select_image + Tachi image + background:
public:
SDL_Surface* screen_surface;
SDL_Window *screen;
SDL_Renderer *renderer;
SDL_Texture *screen_tex;
Expand Down
28 changes: 11 additions & 17 deletions src/PonscripterLabel_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,8 +1381,7 @@ int PonscripterLabel::playCommand(const pstring& cmd)

int PonscripterLabel::ofscopyCommand(const pstring& cmd)
{
fprintf(stderr, "Non-upgraded command, help\n");
SDL_BlitSurface(screen_surface, NULL, accumulation_surface, NULL);
fprintf(stderr, "Non-upgraded command, help\n");

return RET_CONTINUE;
}
Expand Down Expand Up @@ -2336,7 +2335,7 @@ int PonscripterLabel::getscreenshotCommand(const pstring& cmd)
SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0, 0);

SDL_Surface* surface =
SDL_ConvertSurface(screen_surface,image_surface->format, SDL_SWSURFACE);
SDL_ConvertSurface(accumulation_surface, image_surface->format, SDL_SWSURFACE);

AnimationInfo::resizeSurface(surface, screenshot_surface);
SDL_FreeSurface(surface);
Expand Down Expand Up @@ -2786,7 +2785,7 @@ int PonscripterLabel::drawsp3Command(const pstring& cmd)
si.inv_mat[1][1] = si.mat[0][0] * 1000 / denom;
}

SDL_Rect clip = { 0, 0, screen_surface->w, screen_surface->h };
SDL_Rect clip = { 0, 0, accumulation_surface->w, accumulation_surface->h };
si.blendOnSurface2(accumulation_surface, x, y, clip, alpha);
si.setCell(old_cell_no);

Expand All @@ -2811,7 +2810,7 @@ int PonscripterLabel::drawsp2Command(const pstring& cmd)
int old_cell_no = si.current_cell;
si.setCell(cell_no);

SDL_Rect clip = { 0, 0, screen_surface->w, screen_surface->h };
SDL_Rect clip = { 0, 0, accumulation_surface->w, accumulation_surface->h };
si.blendOnSurface2(accumulation_surface, si.pos.x, si.pos.y, clip, alpha);
si.setCell(old_cell_no);

Expand Down Expand Up @@ -2876,7 +2875,7 @@ int PonscripterLabel::drawbg2Command(const pstring& cmd)
bg_info.rot = script_h.readIntValue();
bg_info.calcAffineMatrix();

SDL_Rect clip = { 0, 0, screen_surface->w, screen_surface->h };
SDL_Rect clip = { 0, 0, accumulation_surface->w, accumulation_surface->h };
bg_info.blendOnSurface2(accumulation_surface, x, y, clip, 256);

return RET_CONTINUE;
Expand Down Expand Up @@ -3395,13 +3394,11 @@ int PonscripterLabel::bltCommand(const pstring& cmd)
SDL_Rect src_rect = { sx, sy, sw, sh };
SDL_Rect dst_rect = { dx, dy, dw, dh };

SDL_BlitSurface(btndef_info.image_surface, &src_rect, screen_surface, &dst_rect);
SDL_BlitSurface(btndef_info.image_surface, &src_rect, accumulation_surface, &dst_rect);
//TODO, fix this. haven't found it used yet
//SDL_UpdateRect(screen_surface, dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h);
SDL_UpdateTexture(screen_tex, NULL, screen_surface->pixels, screen_surface->pitch);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, screen_tex, NULL, NULL);
SDL_RenderPresent(renderer);
SDL_UpdateTexture(screen_tex, NULL, accumulation_surface->pixels, accumulation_surface->pitch);
rerender();
dirty_rect.clear();
}
else {
Expand Down Expand Up @@ -3528,13 +3525,11 @@ int PonscripterLabel::endrollCommand(const pstring& cmd)
amountcounter += dist;
SDL_Rect src_rect = { sx, sy + amountcounter, sw, sh };
SDL_Rect dst_rect = { dx, dy, dw, dh };
SDL_BlitSurface(btndef_info.image_surface, &src_rect, screen_surface, &dst_rect);
SDL_BlitSurface(btndef_info.image_surface, &src_rect, accumulation_surface, &dst_rect);
//TODO, fix this. haven't found it used yet
//SDL_UpdateRect(screen_surface, dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h);
SDL_UpdateTexture(screen_tex, NULL, screen_surface->pixels, screen_surface->pitch);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, screen_tex, NULL, NULL);
SDL_RenderPresent(renderer);
SDL_UpdateTexture(screen_tex, NULL, accumulation_surface->pixels, accumulation_surface->pitch);
rerender();
//dirty_rect.clear();

nexttime = SDL_GetTicks();
Expand Down Expand Up @@ -3618,7 +3613,6 @@ int PonscripterLabel::bidirectCommand(const pstring& cmd)

int PonscripterLabel::bgcopyCommand(const pstring& cmd)
{
SDL_BlitSurface(screen_surface, NULL, accumulation_surface, NULL);
fprintf(stderr, "Likely partially-updated command used bgcopyCommand\n");

bg_info.num_of_cells = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/PonscripterLabel_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ void PonscripterLabel::playAVI(const pstring& filename, bool click_flag)

AVIWrapper* avi = new AVIWrapper();
if (avi->init(abs_fname, false) == 0
&& avi->initAV(screen_surface, audio_open_flag) == 0) {
&& avi->initAV(accumulation_surface, audio_open_flag) == 0) {
if (avi->play(click_flag)) endCommand();
}

Expand Down

0 comments on commit 8007b6d

Please sign in to comment.