summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-12-16 01:03:19 +0300
committerAndrei Karas <akaras@inbox.ru>2015-12-16 01:03:19 +0300
commit78fb544aeb8761e8d554487487bc27e610822e2d (patch)
tree45ec42f5dcba94cd391f54a4cef2c017d7318d38 /src/render
parentfcdc44b21bda79052205ca1884b7f3a1ebd32957 (diff)
downloadplus-78fb544aeb8761e8d554487487bc27e610822e2d.tar.gz
plus-78fb544aeb8761e8d554487487bc27e610822e2d.tar.bz2
plus-78fb544aeb8761e8d554487487bc27e610822e2d.tar.xz
plus-78fb544aeb8761e8d554487487bc27e610822e2d.zip
Use screenshort helpers for creating screenshots
Diffstat (limited to 'src/render')
-rw-r--r--src/render/graphics.h11
-rw-r--r--src/render/graphicsdef.hpp5
-rw-r--r--src/render/imagegraphics.h3
-rw-r--r--src/render/mobileopengl2graphics.cpp57
-rw-r--r--src/render/mobileopenglgraphics.cpp57
-rw-r--r--src/render/modernopenglgraphics.cpp57
-rw-r--r--src/render/normalopenglgraphics.cpp58
-rw-r--r--src/render/nullopenglgraphics.cpp9
-rw-r--r--src/render/openglgraphicsdef.hpp2
-rw-r--r--src/render/safeopenglgraphics.cpp56
-rw-r--r--src/render/sdl2graphics.cpp22
-rw-r--r--src/render/sdl2softwaregraphics.cpp22
-rw-r--r--src/render/sdlgraphics.cpp22
-rw-r--r--src/render/surfacegraphics.h3
14 files changed, 3 insertions, 381 deletions
diff --git a/src/render/graphics.h b/src/render/graphics.h
index f8d10a832..0f0e14776 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -105,6 +105,9 @@ struct SDL_Window;
class Graphics notfinal
{
public:
+#ifdef USE_OPENGL
+ friend class OpenGLScreenshotHelper;
+#endif
friend class SdlScreenshotHelper;
A_DELETE_COPY(Graphics)
@@ -246,14 +249,6 @@ class Graphics notfinal
*/
int getHeight() const A_WARN_UNUSED;
- /**
- * Takes a screenshot and returns it as SDL surface.
- */
- virtual SDL_Surface *getScreenshot() A_WARN_UNUSED = 0;
-
- virtual void prepareScreenshot()
- { }
-
int getMemoryUsage() const A_WARN_UNUSED;
virtual void drawNet(const int x1, const int y1,
diff --git a/src/render/graphicsdef.hpp b/src/render/graphicsdef.hpp
index fb90c2fb4..4c77b46d5 100644
--- a/src/render/graphicsdef.hpp
+++ b/src/render/graphicsdef.hpp
@@ -84,11 +84,6 @@ public:
void updateScreen() override final;
- /**
- * Takes a screenshot and returns it as SDL surface.
- */
- SDL_Surface *getScreenshot() override final A_WARN_UNUSED;
-
void calcWindow(ImageCollection *const vertCol,
const int x, const int y,
const int w, const int h,
diff --git a/src/render/imagegraphics.h b/src/render/imagegraphics.h
index 8957543d4..df07bdacd 100644
--- a/src/render/imagegraphics.h
+++ b/src/render/imagegraphics.h
@@ -131,9 +131,6 @@ class ImegeGraphics final : public Graphics
void updateScreen() override final
{ }
- SDL_Surface *getScreenshot() override final A_WARN_UNUSED
- { return nullptr; }
-
void drawNet(const int x1 A_UNUSED,
const int y1 A_UNUSED,
const int x2 A_UNUSED,
diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp
index 979d17224..9db0f07f4 100644
--- a/src/render/mobileopengl2graphics.cpp
+++ b/src/render/mobileopengl2graphics.cpp
@@ -860,63 +860,6 @@ void MobileOpenGL2Graphics::endDraw()
popClipArea();
}
-void MobileOpenGL2Graphics::prepareScreenshot()
-{
- if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mRect.w, mRect.h, &mFbo);
-}
-
-SDL_Surface* MobileOpenGL2Graphics::getScreenshot()
-{
- const int h = mRect.h;
- const int w = mRect.w - (mRect.w % 4);
- GLint pack = 1;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(
- SDL_SWSURFACE, w, h, 24,
- 0xff0000, 0x00ff00, 0x0000ff, 0x000000);
-
- if (!screenshot)
- return nullptr;
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_LockSurface(screenshot);
-
- const size_t lineSize = 3 * w;
- GLubyte *const buf = new GLubyte[lineSize];
-
- // Grap the pixel buffer and write it to the SDL surface
- mglGetIntegerv(GL_PACK_ALIGNMENT, &pack);
- mglPixelStorei(GL_PACK_ALIGNMENT, 1);
- mglReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels);
-
- // Flip the screenshot, as OpenGL has 0,0 in bottom left
- const int h2 = h / 2;
- for (int i = 0; i < h2; i++)
- {
- GLubyte *const top = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * i;
- GLubyte *const bot = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * (h - 1 - i);
-
- memcpy(buf, top, lineSize);
- memcpy(top, bot, lineSize);
- memcpy(bot, buf, lineSize);
- }
-
- delete [] buf;
-
- if (config.getBoolValue("usefbo"))
- graphicsManager.deleteFBO(&mFbo);
-
- mglPixelStorei(GL_PACK_ALIGNMENT, pack);
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_UnlockSurface(screenshot);
-
- return screenshot;
-}
-
void MobileOpenGL2Graphics::pushClipArea(const Rect &area)
{
Graphics::pushClipArea(area);
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 0b3d4e4dc..ce7501e27 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -938,63 +938,6 @@ void MobileOpenGLGraphics::endDraw()
popClipArea();
}
-void MobileOpenGLGraphics::prepareScreenshot()
-{
- if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mRect.w, mRect.h, &mFbo);
-}
-
-SDL_Surface* MobileOpenGLGraphics::getScreenshot()
-{
- const int h = mRect.h;
- const int w = mRect.w - (mRect.w % 4);
- GLint pack = 1;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(
- SDL_SWSURFACE, w, h, 24,
- 0xff0000, 0x00ff00, 0x0000ff, 0x000000);
-
- if (!screenshot)
- return nullptr;
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_LockSurface(screenshot);
-
- const size_t lineSize = 3 * w;
- GLubyte *const buf = new GLubyte[lineSize];
-
- // Grap the pixel buffer and write it to the SDL surface
- mglGetIntegerv(GL_PACK_ALIGNMENT, &pack);
- mglPixelStorei(GL_PACK_ALIGNMENT, 1);
- mglReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels);
-
- // Flip the screenshot, as OpenGL has 0,0 in bottom left
- const int h2 = h / 2;
- for (int i = 0; i < h2; i++)
- {
- GLubyte *const top = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * i;
- GLubyte *const bot = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * (h - 1 - i);
-
- memcpy(buf, top, lineSize);
- memcpy(top, bot, lineSize);
- memcpy(bot, buf, lineSize);
- }
-
- delete [] buf;
-
- if (config.getBoolValue("usefbo"))
- graphicsManager.deleteFBO(&mFbo);
-
- mglPixelStorei(GL_PACK_ALIGNMENT, pack);
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_UnlockSurface(screenshot);
-
- return screenshot;
-}
-
void MobileOpenGLGraphics::pushClipArea(const Rect &area)
{
int transX = 0;
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index fc59a7413..1ff55045c 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -849,63 +849,6 @@ void ModernOpenGLGraphics::endDraw()
popClipArea();
}
-void ModernOpenGLGraphics::prepareScreenshot()
-{
- if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mRect.w, mRect.h, &mFbo);
-}
-
-SDL_Surface* ModernOpenGLGraphics::getScreenshot()
-{
- const int h = mRect.h;
- const int w = mRect.w - (mRect.w % 4);
- GLint pack = 1;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(
- SDL_SWSURFACE, w, h, 24,
- 0xff0000, 0x00ff00, 0x0000ff, 0x000000);
-
- if (!screenshot)
- return nullptr;
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_LockSurface(screenshot);
-
- const size_t lineSize = 3 * w;
- GLubyte *const buf = new GLubyte[lineSize];
-
- // Grap the pixel buffer and write it to the SDL surface
- mglGetIntegerv(GL_PACK_ALIGNMENT, &pack);
- mglPixelStorei(GL_PACK_ALIGNMENT, 1);
- mglReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels);
-
- // Flip the screenshot, as OpenGL has 0,0 in bottom left
- const int h2 = h / 2;
- for (int i = 0; i < h2; i++)
- {
- GLubyte *const top = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * i;
- GLubyte *const bot = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * (h - 1 - i);
-
- memcpy(buf, top, lineSize);
- memcpy(top, bot, lineSize);
- memcpy(bot, buf, lineSize);
- }
-
- delete [] buf;
-
- if (config.getBoolValue("usefbo"))
- graphicsManager.deleteFBO(&mFbo);
-
- mglPixelStorei(GL_PACK_ALIGNMENT, pack);
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_UnlockSurface(screenshot);
-
- return screenshot;
-}
-
void ModernOpenGLGraphics::pushClipArea(const Rect &area)
{
Graphics::pushClipArea(area);
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index f58e10f92..b86859f6d 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -1268,64 +1268,6 @@ void NormalOpenGLGraphics::endDraw()
popClipArea();
}
-void NormalOpenGLGraphics::prepareScreenshot()
-{
- if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mRect.w, mRect.h, &mFbo);
-}
-
-SDL_Surface* NormalOpenGLGraphics::getScreenshot()
-{
- const int h = mRect.h;
- const int w = mRect.w - (mRect.w % 4);
- GLint pack = 1;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(
- SDL_SWSURFACE,
- w, h, 24,
- 0xff0000, 0x00ff00, 0x0000ff, 0x000000);
-
- if (!screenshot)
- return nullptr;
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_LockSurface(screenshot);
-
- // Grap the pixel buffer and write it to the SDL surface
- glGetIntegerv(GL_PACK_ALIGNMENT, &pack);
- glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels);
-
- // Flip the screenshot, as OpenGL has 0,0 in bottom left
- const size_t lineSize = 3 * w;
- GLubyte *const buf = new GLubyte[lineSize];
-
- const int h2 = h / 2;
- for (int i = 0; i < h2; i++)
- {
- GLubyte *const top = static_cast<GLubyte *const>(
- screenshot->pixels) + lineSize * i;
- GLubyte *const bot = static_cast<GLubyte *const>(
- screenshot->pixels) + lineSize * (h - 1 - i);
-
- memcpy(buf, top, lineSize);
- memcpy(top, bot, lineSize);
- memcpy(bot, buf, lineSize);
- }
-
- delete [] buf;
-
- if (config.getBoolValue("usefbo"))
- graphicsManager.deleteFBO(&mFbo);
-
- glPixelStorei(GL_PACK_ALIGNMENT, pack);
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_UnlockSurface(screenshot);
-
- return screenshot;
-}
-
void NormalOpenGLGraphics::pushClipArea(const Rect &area)
{
int transX = 0;
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index 27013f93b..9be3626a8 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -956,15 +956,6 @@ void NullOpenGLGraphics::endDraw()
popClipArea();
}
-void NullOpenGLGraphics::prepareScreenshot()
-{
-}
-
-SDL_Surface* NullOpenGLGraphics::getScreenshot()
-{
- return nullptr;
-}
-
void NullOpenGLGraphics::pushClipArea(const Rect &area)
{
int transX = 0;
diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp
index 90f65af06..7f100f832 100644
--- a/src/render/openglgraphicsdef.hpp
+++ b/src/render/openglgraphicsdef.hpp
@@ -30,8 +30,6 @@ public:
static void dumpSettings();
- void prepareScreenshot() override final;
-
int getMemoryUsage() A_WARN_UNUSED;
void updateTextureFormat();
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index f2609c299..143594733 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -517,62 +517,6 @@ void SafeOpenGLGraphics::endDraw()
popClipArea();
}
-void SafeOpenGLGraphics::prepareScreenshot()
-{
- if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mRect.w, mRect.h, &mFbo);
-}
-
-SDL_Surface* SafeOpenGLGraphics::getScreenshot()
-{
- const int h = mRect.h;
- const int w = mRect.w - (mRect.w % 4);
- GLint pack = 1;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(
- SDL_SWSURFACE, w, h, 24, 0xff0000, 0x00ff00, 0x0000ff, 0x000000);
-
- if (!screenshot || !screenshot->pixels)
- return nullptr;
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_LockSurface(screenshot);
-
- // Grap the pixel buffer and write it to the SDL surface
- glGetIntegerv(GL_PACK_ALIGNMENT, &pack);
- glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels);
-
- // Flip the screenshot, as OpenGL has 0,0 in bottom left
- size_t lineSize = 3 * w;
- GLubyte* buf = new GLubyte[lineSize];
-
- const int h2 = h / 2;
- for (int i = 0; i < h2; i++)
- {
- GLubyte *const top = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * i;
- GLubyte *const bot = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * (h - 1 - i);
-
- memcpy(buf, top, lineSize);
- memcpy(top, bot, lineSize);
- memcpy(bot, buf, lineSize);
- }
-
- delete [] buf;
-
- if (config.getBoolValue("usefbo"))
- graphicsManager.deleteFBO(&mFbo);
-
- glPixelStorei(GL_PACK_ALIGNMENT, pack);
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_UnlockSurface(screenshot);
-
- return screenshot;
-}
-
void SafeOpenGLGraphics::pushClipArea(const Rect &area)
{
int transX = 0;
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
index 7bad93889..fa0c4a0d1 100644
--- a/src/render/sdl2graphics.cpp
+++ b/src/render/sdl2graphics.cpp
@@ -606,28 +606,6 @@ void SDLGraphics::updateScreen()
BLOCK_END("Graphics::updateScreen")
}
-SDL_Surface *SDLGraphics::getScreenshot()
-{
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
-#else
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
-#endif
- const int amask = 0x00000000;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
- mRect.w, mRect.h, 24, rmask, gmask, bmask, amask);
-
-// if (screenshot)
-// SDL_BlitSurface(mWindow, nullptr, screenshot, nullptr);
-
- return screenshot;
-}
-
void SDLGraphics::calcWindow(ImageCollection *const vertCol,
const int x, const int y,
const int w, const int h,
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 3afadd27c..653fd5a68 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -790,28 +790,6 @@ void SDL2SoftwareGraphics::updateScreen()
BLOCK_END("Graphics::updateScreen")
}
-SDL_Surface *SDL2SoftwareGraphics::getScreenshot()
-{
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
-#else
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
-#endif
- const int amask = 0x00000000;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
- mRect.w, mRect.h, 24, rmask, gmask, bmask, amask);
-
- if (screenshot)
- SDL_BlitSurface(mSurface, nullptr, screenshot, nullptr);
-
- return screenshot;
-}
-
void SDL2SoftwareGraphics::calcWindow(ImageCollection *const vertCol,
const int x, const int y,
const int w, const int h,
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index 771d000d8..66a954927 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -789,28 +789,6 @@ void SDLGraphics::updateScreen()
BLOCK_END("Graphics::updateScreen")
}
-SDL_Surface *SDLGraphics::getScreenshot()
-{
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
-#else
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
-#endif
- const int amask = 0x00000000;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
- mRect.w, mRect.h, 24, rmask, gmask, bmask, amask);
-
- if (screenshot)
- SDL_BlitSurface(mWindow, nullptr, screenshot, nullptr);
-
- return screenshot;
-}
-
void SDLGraphics::calcWindow(ImageCollection *const vertCol,
const int x, const int y,
const int w, const int h,
diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h
index c8f5d3880..1de7cbc71 100644
--- a/src/render/surfacegraphics.h
+++ b/src/render/surfacegraphics.h
@@ -131,9 +131,6 @@ class SurfaceGraphics final : public Graphics
void updateScreen() override final
{ }
- SDL_Surface *getScreenshot() override final A_WARN_UNUSED
- { return nullptr; }
-
void drawNet(const int x1 A_UNUSED,
const int y1 A_UNUSED,
const int x2 A_UNUSED,