mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-22 15:11:03 +00:00
Change approach somewhat to avoid adding drawing code in the screen manager.
This commit is contained in:
parent
e3d2c65ba0
commit
5d6d4a08f4
@ -815,7 +815,7 @@ void ShaderListScreen::CreateViews() {
|
||||
layout->Add(tabs_);
|
||||
layout->Add(new Button(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(shaderTypes); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(shaderTypes); i++) {
|
||||
ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0));
|
||||
LinearLayout *shaderList = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT));
|
||||
ListShaders(shaderTypes[i].type, shaderList);
|
||||
|
@ -861,6 +861,24 @@ void EmuScreen::render() {
|
||||
}
|
||||
}
|
||||
|
||||
bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
|
||||
|
||||
if (!useBufferedRendering) {
|
||||
Thin3DContext *thin3d = screenManager()->getThin3DContext();
|
||||
thin3d->Clear(T3DClear::COLOR | T3DClear::DEPTH | T3DClear::STENCIL, 0xFF000000, 0.0f, 0);
|
||||
|
||||
T3DViewport viewport;
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
viewport.Width = pixel_xres;
|
||||
viewport.Height = pixel_yres;
|
||||
viewport.MaxDepth = 1.0;
|
||||
viewport.MinDepth = 0.0;
|
||||
thin3d->SetViewports(1, &viewport);
|
||||
thin3d->SetTargetSize(pixel_xres, pixel_yres);
|
||||
}
|
||||
|
||||
|
||||
// Reapply the graphics state of the PSP
|
||||
ReapplyGfxState();
|
||||
|
||||
@ -882,7 +900,6 @@ void EmuScreen::render() {
|
||||
if (invalid_)
|
||||
return;
|
||||
|
||||
bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
|
||||
if (useBufferedRendering && g_Config.iGPUBackend == GPU_BACKEND_OPENGL)
|
||||
fbo_unbind();
|
||||
|
||||
@ -970,9 +987,3 @@ void EmuScreen::releaseButtons() {
|
||||
input.id = 0;
|
||||
touch(input);
|
||||
}
|
||||
|
||||
int EmuScreen::expects() const {
|
||||
// We only want the framework to clear for us when we are running non-buffered. Otherwise, it's a complete waste of time
|
||||
// to clear the backbuffer only to then go off rendering to another buffer. Better to clear when we are actually copying the final image instead.
|
||||
return (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) ? (SCREEN_EXPECTS_CLEAR | SCREEN_EXPECTS_VIEWPORT) : 0;
|
||||
}
|
@ -45,8 +45,6 @@ public:
|
||||
bool key(const KeyInput &key) override;
|
||||
bool axis(const AxisInput &axis) override;
|
||||
|
||||
int expects() const override;
|
||||
|
||||
protected:
|
||||
void CreateViews() override;
|
||||
UI::EventReturn OnDevTools(UI::EventParams ¶ms);
|
||||
|
@ -99,24 +99,6 @@ void ScreenManager::resized() {
|
||||
|
||||
void ScreenManager::render() {
|
||||
if (!stack_.empty()) {
|
||||
int expects = stack_.back().screen->expects();
|
||||
|
||||
if (expects & SCREEN_EXPECTS_CLEAR) {
|
||||
thin3DContext_->Clear(T3DClear::COLOR | T3DClear::DEPTH | T3DClear::STENCIL, 0xFF000000, 0.0f, 0);
|
||||
}
|
||||
|
||||
if (expects & SCREEN_EXPECTS_VIEWPORT) {
|
||||
T3DViewport viewport;
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
viewport.Width = pixel_xres;
|
||||
viewport.Height = pixel_yres;
|
||||
viewport.MaxDepth = 1.0;
|
||||
viewport.MinDepth = 0.0;
|
||||
thin3DContext_->SetViewports(1, &viewport);
|
||||
thin3DContext_->SetTargetSize(pixel_xres, pixel_yres);
|
||||
}
|
||||
|
||||
switch (stack_.back().flags) {
|
||||
case LAYER_SIDEMENU:
|
||||
case LAYER_TRANSPARENT:
|
||||
@ -128,13 +110,19 @@ void ScreenManager::render() {
|
||||
iter--;
|
||||
iter--;
|
||||
Layer backback = *iter;
|
||||
// Also shift to the right somehow...
|
||||
|
||||
// TODO: Make really sure that this "mismatched" pre/post only happens
|
||||
// when screens are "compatible" (both are UIScreens, for example).
|
||||
backback.screen->preRender();
|
||||
backback.screen->render();
|
||||
stack_.back().screen->render();
|
||||
stack_.back().screen->postRender();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
stack_.back().screen->preRender();
|
||||
stack_.back().screen->render();
|
||||
stack_.back().screen->postRender();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -33,12 +33,6 @@ enum DialogResult {
|
||||
DR_BACK,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
SCREEN_EXPECTS_VIEWPORT = 1 << 0,
|
||||
SCREEN_EXPECTS_CLEAR = 1 << 1,
|
||||
};
|
||||
|
||||
class ScreenManager;
|
||||
class UIContext;
|
||||
class Thin3DContext;
|
||||
@ -52,7 +46,9 @@ public:
|
||||
|
||||
virtual void onFinish(DialogResult reason) {}
|
||||
virtual void update(InputState &input) {}
|
||||
virtual void preRender() {}
|
||||
virtual void render() {}
|
||||
virtual void postRender() {}
|
||||
virtual void deviceLost() {}
|
||||
virtual void resized() {}
|
||||
virtual void dialogFinished(const Screen *dialog, DialogResult result) {}
|
||||
@ -75,8 +71,6 @@ public:
|
||||
virtual bool isTransparent() const { return false; }
|
||||
virtual bool isTopLevel() const { return false; }
|
||||
|
||||
virtual int expects() const { return SCREEN_EXPECTS_VIEWPORT | SCREEN_EXPECTS_CLEAR; }
|
||||
|
||||
private:
|
||||
ScreenManager *screenManager_;
|
||||
DISALLOW_COPY_AND_ASSIGN(Screen);
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "base/display.h"
|
||||
#include "input/input_state.h"
|
||||
#include "input/keycodes.h"
|
||||
#include "ui/ui_screen.h"
|
||||
@ -36,6 +37,24 @@ void UIScreen::update(InputState &input) {
|
||||
}
|
||||
}
|
||||
|
||||
void UIScreen::preRender() {
|
||||
Thin3DContext *thin3d = screenManager()->getThin3DContext();
|
||||
thin3d->Clear(T3DClear::COLOR | T3DClear::DEPTH | T3DClear::STENCIL, 0xFF000000, 0.0f, 0);
|
||||
|
||||
T3DViewport viewport;
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
viewport.Width = pixel_xres;
|
||||
viewport.Height = pixel_yres;
|
||||
viewport.MaxDepth = 1.0;
|
||||
viewport.MinDepth = 0.0;
|
||||
thin3d->SetViewports(1, &viewport);
|
||||
thin3d->SetTargetSize(pixel_xres, pixel_yres);
|
||||
}
|
||||
|
||||
void UIScreen::postRender() {
|
||||
}
|
||||
|
||||
void UIScreen::render() {
|
||||
DoRecreateViews();
|
||||
|
||||
|
@ -12,7 +12,9 @@ public:
|
||||
~UIScreen();
|
||||
|
||||
virtual void update(InputState &input) override;
|
||||
virtual void preRender() override;
|
||||
virtual void render() override;
|
||||
virtual void postRender() override;
|
||||
|
||||
virtual bool touch(const TouchInput &touch) override;
|
||||
virtual bool key(const KeyInput &touch) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user