~ppsspp/ppsspp/ppsspp_1.3.0

« back to all changes in this revision

Viewing changes to ext/native/ui/ui_context.h

  • Committer: Sérgio Benjamim
  • Date: 2017-01-02 00:12:05 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20170102001205-cxbta9za203nmjwm
1.3.0 source (from ppsspp_1.3.0-r160.p5.l1762.a165.t83~56~ubuntu16.04.1.tar.xz).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma once
 
2
 
 
3
#include <vector>
 
4
 
 
5
#include "base/basictypes.h"
 
6
#include "math/geom2d.h"
 
7
#include "gfx/texture_atlas.h"
 
8
 
 
9
// Everything you need to draw a UI collected into a single unit that can be passed around.
 
10
// Everything forward declared so this header is safe everywhere.
 
11
 
 
12
class Thin3DContext;
 
13
class Thin3DShaderSet;
 
14
class Thin3DDepthStencilState;
 
15
class Thin3DTexture;
 
16
class Thin3DBlendState;
 
17
class Thin3DSamplerState;
 
18
class Texture;
 
19
class DrawBuffer;
 
20
class TextDrawer;
 
21
 
 
22
namespace UI {
 
23
        struct Drawable;
 
24
        struct Theme;
 
25
        struct FontStyle;
 
26
}
 
27
 
 
28
class DrawBuffer;
 
29
 
 
30
class UIContext {
 
31
public:
 
32
        UIContext();
 
33
        ~UIContext();
 
34
 
 
35
        void Init(Thin3DContext *thin3d, Thin3DShaderSet *uiShaderTex, Thin3DShaderSet *uiShaderNoTex, Thin3DTexture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop);
 
36
 
 
37
        void Begin();
 
38
        void BeginNoTex();
 
39
        void Flush();
 
40
        void End();
 
41
 
 
42
        void RebindTexture() const;
 
43
 
 
44
        // TODO: Support transformed bounds using stencil
 
45
        void PushScissor(const Bounds &bounds);
 
46
        void PopScissor();
 
47
        Bounds GetScissorBounds();
 
48
 
 
49
        void ActivateTopScissor();
 
50
 
 
51
        DrawBuffer *Draw() const { return uidrawbuffer_; }
 
52
        DrawBuffer *DrawTop() const { return uidrawbufferTop_; }
 
53
        const UI::Theme *theme;
 
54
 
 
55
        // Utility methods
 
56
 
 
57
        TextDrawer *Text() const { return textDrawer_; }
 
58
 
 
59
        void SetFontStyle(const UI::FontStyle &style);
 
60
        const UI::FontStyle &GetFontStyle() { return *fontStyle_; }
 
61
        void SetFontScale(float scaleX, float scaleY);
 
62
        void MeasureTextCount(const UI::FontStyle &style, float scaleX, float scaleY, const char *str, int count, float *x, float *y, int align = 0) const;
 
63
        void MeasureText(const UI::FontStyle &style, float scaleX, float scaleY, const char *str, float *x, float *y, int align = 0) const;
 
64
        void MeasureTextRect(const UI::FontStyle &style, float scaleX, float scaleY, const char *str, int count, const Bounds &bounds, float *x, float *y, int align = 0) const;
 
65
        void DrawText(const char *str, float x, float y, uint32_t color, int align = 0);
 
66
        void DrawTextShadow(const char *str, float x, float y, uint32_t color, int align = 0);
 
67
        void DrawTextRect(const char *str, const Bounds &bounds, uint32_t color, int align = 0);
 
68
        void FillRect(const UI::Drawable &drawable, const Bounds &bounds);
 
69
 
 
70
        // in dps, like dp_xres and dp_yres
 
71
        void SetBounds(const Bounds &b) { bounds_ = b; }
 
72
        const Bounds &GetBounds() const { return bounds_; }
 
73
        Thin3DContext *GetThin3DContext() { return thin3d_; }
 
74
 
 
75
private:
 
76
        Thin3DContext *thin3d_;
 
77
        Bounds bounds_;
 
78
 
 
79
        float fontScaleX_;
 
80
        float fontScaleY_;
 
81
        UI::FontStyle *fontStyle_;
 
82
        TextDrawer *textDrawer_;
 
83
 
 
84
        Thin3DContext *thin3D_;
 
85
        Thin3DDepthStencilState *depth_;
 
86
        Thin3DBlendState *blend_;
 
87
        Thin3DSamplerState *sampler_;
 
88
        Thin3DShaderSet *uishader_;
 
89
        Thin3DShaderSet *uishadernotex_;
 
90
        Thin3DTexture *uitexture_;
 
91
 
 
92
        DrawBuffer *uidrawbuffer_;
 
93
        DrawBuffer *uidrawbufferTop_;
 
94
 
 
95
        std::vector<Bounds> scissorStack_;
 
96
};