ANDROID: Rework 3D screen setup

All the setupScreen functions were useless as there is only one place
where it's called.
_opengl was always true.
_game_pbuf was never initialized.
This commit is contained in:
Le Philousophe 2021-10-24 20:11:36 +02:00 committed by Paweł Kołodziejski
parent d4e9c0eca4
commit 20df3369b4
2 changed files with 12 additions and 50 deletions

View file

@ -51,12 +51,10 @@
AndroidGraphics3dManager::AndroidGraphics3dManager() :
_screenChangeID(0),
_graphicsMode(0),
_opengl(false),
_fullscreen(true),
_ar_correction(true),
_force_redraw(false),
_game_texture(0),
_game_pbuf(),
_frame_buffer(0),
_cursorX(0),
_cursorY(0),
@ -197,12 +195,6 @@ void AndroidGraphics3dManager::updateScreen() {
if (!JNI::haveSurface())
return;
if (_game_pbuf) {
int pitch = _game_texture->width() * _game_texture->getPixelFormat().bytesPerPixel;
_game_texture->updateBuffer(0, 0, _game_texture->width(), _game_texture->height(),
_game_pbuf.getRawBuffer(), pitch);
}
if (!_force_redraw &&
!_game_texture->dirty() &&
!_overlay_texture->dirty() &&
@ -518,7 +510,12 @@ void AndroidGraphics3dManager::copyRectToScreen(const void *buf, int pitch,
void AndroidGraphics3dManager::initSize(uint width, uint height,
const Graphics::PixelFormat *format) {
setupScreen(width, height, true, true);
initViewport();
// resize game texture
initSizeIntern(width, height, 0);
_game_texture->setGameTexture();
}
void AndroidGraphics3dManager::initSizeIntern(uint width, uint height,
@ -737,32 +734,6 @@ bool AndroidGraphics3dManager::lockMouse(bool lock) {
return true;
}
void AndroidGraphics3dManager::setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d) {
setupScreen(screenW, screenH, fullscreen, accel3d, true);
}
void AndroidGraphics3dManager::setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d, bool isGame) {
_opengl = accel3d;
initViewport();
if (_opengl) {
// resize game texture
initSizeIntern(screenW, screenH, 0);
if (isGame)
_game_texture->setGameTexture();
// format is not used by the gfx_opengl driver, use fake format
_game_pbuf.set(Graphics::PixelFormat(), 0);
} else {
Graphics::PixelFormat format = GLES565Texture::pixelFormat();
initSizeIntern(screenW, screenH, &format);
// as there is no support for the texture surface's lock/unlock mechanism in gfx_tinygl/...
// do not use _game_texture->surface()->pixels directly
_game_pbuf.create(_game_texture->getPixelFormat(),
_game_texture->width() * _game_texture->height(), DisposeAfterUse::YES);
}
}
void AndroidGraphics3dManager::clipMouse(Common::Point &p) const {
const GLESBaseTexture *tex = getActiveTexture();
@ -892,11 +863,7 @@ void AndroidGraphics3dManager::clearScreen(FixupType type, byte count) {
for (byte i = 0; i < count; ++i) {
// clear screen
GLCALL(glClearColor(0, 0, 0, 1 << 16));
if (_opengl) {
GLCALL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
} else {
GLCALL(glClear(GL_COLOR_BUFFER_BIT));
}
switch (type) {
case kClear:

View file

@ -102,19 +102,16 @@ public:
virtual void setCursorPalette(const byte *colors, uint start, uint num) override;
void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d);
void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d, bool isGame);
void updateScreenRect();
const GLESBaseTexture *getActiveTexture() const;
void clipMouse(Common::Point &p) const;
#ifdef USE_RGB_COLOR
virtual Graphics::PixelFormat getScreenFormat() const override;
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
#endif
protected:
void updateScreenRect();
const GLESBaseTexture *getActiveTexture() const;
void clipMouse(Common::Point &p) const;
void setSystemMousePosition(int x, int y) {}
bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format);
@ -146,14 +143,12 @@ private:
private:
int _screenChangeID;
int _graphicsMode;
bool _opengl;
bool _fullscreen;
bool _ar_correction;
bool _force_redraw;
// Game layer
GLESBaseTexture *_game_texture;
Graphics::PixelBuffer _game_pbuf;
OpenGL::FrameBuffer *_frame_buffer;
/**