Skip to content

Commit

Permalink
Remove SDL_gfxBlitFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
dorkster committed Apr 11, 2015
1 parent bef5d36 commit c3a5a9b
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 687 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Expand Up @@ -161,7 +161,6 @@ Set (FLARE_SOURCES
./src/RenderDevice.cpp
./src/RenderDeviceList.cpp
./src/SaveLoad.cpp
./src/SDL_gfxBlitFunc.c
./src/SDLInputState.cpp
./src/SDLSoftwareRenderDevice.cpp
./src/SDLSoundManager.cpp
Expand Down
1 change: 0 additions & 1 deletion flare-android-project/jni/src/Android.mk
Expand Up @@ -85,7 +85,6 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
../../../src/RenderDevice.cpp \
../../../src/RenderDeviceList.cpp \
../../../src/SaveLoad.cpp \
../../../src/SDL_gfxBlitFunc.c \
../../../src/SDLInputState.cpp \
../../../src/SDLHardwareRenderDevice.cpp \
../../../src/SDLSoftwareRenderDevice.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/MenuManager.cpp
Expand Up @@ -186,7 +186,7 @@ void MenuManager::setDragIcon(int icon_id) {

icons->setClip(src);
icons->setDest(dest);
render_device->renderToImage(icons->getGraphics(), src, drag_icon->getGraphics(), dest, true);
render_device->renderToImage(icons->getGraphics(), src, drag_icon->getGraphics(), dest);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/RenderDevice.h
Expand Up @@ -192,8 +192,7 @@ class RenderDevice {
/** Screen operations */
virtual int render(Sprite* r) = 0;
virtual int render(Renderable& r, Rect dest) = 0;
virtual int renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest,
bool dest_is_transparent = false) = 0;
virtual int renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest) = 0;
virtual int renderText(FontStyle *font_style, const std::string& text, Color color, Rect& dest) = 0;
virtual Image* renderTextToImage(FontStyle* font_style, const std::string& text, Color color, bool blended = true) = 0;
virtual void blankScreen() = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/SDLFontEngine.cpp
Expand Up @@ -144,8 +144,7 @@ void SDLFontEngine::render(const std::string& text, int x, int y, int justify, I

// Render text graphics into target
clip = temp->getClip();
render_device->renderToImage(temp->getGraphics(), clip,
target, dest_rect, active_font->blend);
render_device->renderToImage(temp->getGraphics(), clip, target, dest_rect);

// text is cached, we can free temp resource
delete temp;
Expand Down
7 changes: 1 addition & 6 deletions src/SDLHardwareRenderDevice.cpp
Expand Up @@ -335,18 +335,13 @@ int SDLHardwareRenderDevice::render(Sprite *r) {
return SDL_RenderCopy(renderer, static_cast<SDLHardwareImage *>(r->getGraphics())->surface, &src, &dest);
}

int SDLHardwareRenderDevice::renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest, bool dest_is_transparent) {
int SDLHardwareRenderDevice::renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest) {
if (!src_image || !dest_image)
return -1;

if (SDL_SetRenderTarget(renderer, static_cast<SDLHardwareImage *>(dest_image)->surface) != 0)
return -1;

if (dest_is_transparent) {
// do nothing
// this block is here to suppress an unused variable compiler warning
}

dest.w = src.w;
dest.h = src.h;
SDL_Rect _src = src;
Expand Down
2 changes: 1 addition & 1 deletion src/SDLHardwareRenderDevice.h
Expand Up @@ -70,7 +70,7 @@ class SDLHardwareRenderDevice : public RenderDevice {

virtual int render(Renderable& r, Rect dest);
virtual int render(Sprite* r);
virtual int renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest, bool dest_is_transparent = false);
virtual int renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest);

int renderText(FontStyle *font_style, const std::string& text, Color color, Rect& dest);
Image *renderTextToImage(FontStyle* font_style, const std::string& text, Color color, bool blended = true);
Expand Down
11 changes: 3 additions & 8 deletions src/SDLSoftwareRenderDevice.cpp
Expand Up @@ -22,7 +22,6 @@ FLARE. If not, see http://www.gnu.org/licenses/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_gfxBlitFunc.h"

#include "SharedResources.h"
#include "Settings.h"
Expand Down Expand Up @@ -348,18 +347,14 @@ int SDLSoftwareRenderDevice::render(Sprite *r) {
return SDL_BlitSurface(static_cast<SDLSoftwareImage *>(r->getGraphics())->surface, &src, screen, &dest);
}

int SDLSoftwareRenderDevice::renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest, bool dest_is_transparent) {
int SDLSoftwareRenderDevice::renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest) {
if (!src_image || !dest_image) return -1;

SDL_Rect _src = src;
SDL_Rect _dest = dest;

if (dest_is_transparent)
return SDL_gfxBlitRGBA(static_cast<SDLSoftwareImage *>(src_image)->surface, &_src,
static_cast<SDLSoftwareImage *>(dest_image)->surface, &_dest);
else
return SDL_BlitSurface(static_cast<SDLSoftwareImage *>(src_image)->surface, &_src,
static_cast<SDLSoftwareImage *>(dest_image)->surface, &_dest);
return SDL_BlitSurface(static_cast<SDLSoftwareImage *>(src_image)->surface, &_src,
static_cast<SDLSoftwareImage *>(dest_image)->surface, &_dest);
}

int SDLSoftwareRenderDevice::renderText(
Expand Down
2 changes: 1 addition & 1 deletion src/SDLSoftwareRenderDevice.h
Expand Up @@ -68,7 +68,7 @@ class SDLSoftwareRenderDevice : public RenderDevice {

virtual int render(Renderable& r, Rect dest);
virtual int render(Sprite* r);
virtual int renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest, bool dest_is_transparent = false);
virtual int renderToImage(Image* src_image, Rect& src, Image* dest_image, Rect& dest);

int renderText(FontStyle *font_style, const std::string& text, Color color, Rect& dest);
Image* renderTextToImage(FontStyle* font_style, const std::string& text, Color color, bool blended = true);
Expand Down

0 comments on commit c3a5a9b

Please sign in to comment.