mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-03 07:11:49 +00:00
TINYGL: Added 2d blitting draft interface.
This commit is contained in:
parent
9bf27c050d
commit
6ab14ac528
@ -51,6 +51,7 @@ MODULE_OBJS := \
|
||||
tinygl/zline.o \
|
||||
tinygl/zmath.o \
|
||||
tinygl/ztriangle.o \
|
||||
tinygl/zblit.o \
|
||||
|
||||
ifdef USE_SCALERS
|
||||
MODULE_OBJS += \
|
||||
|
84
graphics/tinygl/zblit.cpp
Normal file
84
graphics/tinygl/zblit.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include "graphics/tinygl/zblit.h"
|
||||
#include "graphics/tinygl/zgl.h"
|
||||
|
||||
namespace TinyGL {
|
||||
struct TinyGLBlitTexture {
|
||||
public:
|
||||
TinyGLBlitTexture(Graphics::PixelBuffer &buffer, int width, int height, int colorKey) {
|
||||
|
||||
}
|
||||
|
||||
Graphics::PixelBuffer dataBuffer;
|
||||
int width, height;
|
||||
};
|
||||
|
||||
|
||||
void tglUploadBlitTexture(int* textureHandle, int width, int height, Graphics::PixelBuffer &buffer, int colorKey) {
|
||||
|
||||
}
|
||||
|
||||
void tglDisposeBlitTexture(int textureHandle) {
|
||||
|
||||
}
|
||||
|
||||
template <bool disableBlending, bool disableColoring, bool disableTransform>
|
||||
void tglBlitGeneric(int blitTextureHandle, int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, float rotation, float rTint, float gTint, float bTint, float aTint) {
|
||||
TinyGL::GLContext* c =TinyGL::gl_get_context();
|
||||
|
||||
if (dstX >= c->fb->xsize|| dstY >= c->fb->ysize)
|
||||
return;
|
||||
|
||||
int clampWidth, clampHeight;
|
||||
|
||||
if (dstX + width > c->fb->xsize)
|
||||
clampWidth = c->fb->xsize - dstX;
|
||||
else
|
||||
clampWidth = width;
|
||||
|
||||
if (dstY + height > c->fb->ysize)
|
||||
clampHeight = c->fb->ysize - dstY;
|
||||
else
|
||||
clampHeight = height;
|
||||
|
||||
TinyGLBlitTexture* texture;
|
||||
|
||||
Graphics::PixelBuffer srcBuf(texture->dataBuffer);
|
||||
srcBuf.shiftBy(srcX + (srcY * texture->width));
|
||||
|
||||
for (int l = 0; l < clampHeight; l++) {
|
||||
for (int r = 0; r < clampWidth; ++r) {
|
||||
byte aDst, rDst, gDst, bDst;
|
||||
srcBuf.getARGBAt(r, aDst, rDst, gDst, bDst);
|
||||
c->fb->writePixel((dstX + r) + (dstY + l) * c->fb->xsize, aDst * aTint, rDst * rTint, gDst * gTint, bDst * bTint);
|
||||
}
|
||||
srcBuf.shiftBy(srcWidth);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tglBlit(int blitTextureHandle, int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, float rotation, float rTint, float gTint, float bTint, float aTint) {
|
||||
|
||||
TinyGL::GLContext* c =TinyGL::gl_get_context();
|
||||
bool disableColor = aTint == 1.0f && bTint == 1.0f && gTint == 1.0f && rTint == 1.0f;
|
||||
bool disableTransform = srcWidth == width && srcHeight == height && rotation == 0;
|
||||
bool disableBlend = c->enableBlend == false;
|
||||
if (disableColor && disableTransform && disableBlend) {
|
||||
tglBlitGeneric<true, true, true>(blitTextureHandle, dstX, dstY, width, height, srcX, srcY, srcWidth, srcHeight, rotation, rTint, gTint, bTint, aTint);
|
||||
} else if (disableColor && disableTransform) {
|
||||
tglBlitGeneric<false, true, true>(blitTextureHandle, dstX, dstY, width, height, srcX, srcY, srcWidth, srcHeight, rotation, rTint, gTint, bTint, aTint);
|
||||
} else if (disableTransform) {
|
||||
tglBlitGeneric<false, false, true>(blitTextureHandle, dstX, dstY, width, height, srcX, srcY, srcWidth, srcHeight, rotation, rTint, gTint, bTint, aTint);
|
||||
} else {
|
||||
tglBlitGeneric<false, false, false>(blitTextureHandle, dstX, dstY, width, height, srcX, srcY, srcWidth, srcHeight, rotation, rTint, gTint, bTint, aTint);
|
||||
}
|
||||
}
|
||||
|
||||
void tglBlitNoBlend(int blitTextureHandle, int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, float rotation, float rTint, float gTint, float bTint, float aTint) {
|
||||
tglBlitGeneric<true, false, false>(blitTextureHandle, dstX, dstY, width, height, srcX, srcY, srcWidth, srcHeight, rotation, rTint, gTint, bTint, aTint);
|
||||
}
|
||||
|
||||
void tglBlitFast(int blitTextureHandle, int x, int y, int width, int height) {
|
||||
tglBlitGeneric<true, true, true>(blitTextureHandle, x, y, width, height, 0, 0, width, height, 0, 255, 255, 255 ,255);
|
||||
}
|
||||
|
||||
}
|
21
graphics/tinygl/zblit.h
Normal file
21
graphics/tinygl/zblit.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef _tgl_zblit_h_
|
||||
#define _tgl_zblit_h_
|
||||
|
||||
#include "graphics/pixelbuffer.h"
|
||||
|
||||
namespace TinyGL {
|
||||
|
||||
|
||||
void tglUploadBlitTexture(int* textureHandle, int width, int height, Graphics::PixelBuffer &buffer, int colorKey);
|
||||
void tglDisposeBlitTexture(int textureHandle);
|
||||
|
||||
void tglBlit(int blitTextureHandle, int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, float rotation = 0, float rTint = 1.0f, float gTint = 1.0f, float bTint = 1.0f, float aTint = 1.0f);
|
||||
|
||||
// Disables blending explicitly.
|
||||
void tglBlitNoBlend(int blitTextureHandle, int dstX, int dstY, int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, float rotation, float rTint, float gTint, float bTint, float aTint);
|
||||
|
||||
// Disables blending, transforms and tinting.
|
||||
void tglBlitFast(int blitTextureHandle, int x, int y, int width, int height);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user