| 1 | //  SuperTux | 
|---|
| 2 | //  Copyright (C) 2006 Matthias Braun <matze@braunis.de> | 
|---|
| 3 | // | 
|---|
| 4 | //  This program is free software: you can redistribute it and/or modify | 
|---|
| 5 | //  it under the terms of the GNU General Public License as published by | 
|---|
| 6 | //  the Free Software Foundation, either version 3 of the License, or | 
|---|
| 7 | //  (at your option) any later version. | 
|---|
| 8 | // | 
|---|
| 9 | //  This program is distributed in the hope that it will be useful, | 
|---|
| 10 | //  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 11 | //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 12 | //  GNU General Public License for more details. | 
|---|
| 13 | // | 
|---|
| 14 | //  You should have received a copy of the GNU General Public License | 
|---|
| 15 | //  along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| 16 |  | 
|---|
| 17 | #ifndef HEADER_SUPERTUX_VIDEO_DRAWING_REQUEST_HPP | 
|---|
| 18 | #define | 
|---|
| 19 |  | 
|---|
| 20 | #include <string> | 
|---|
| 21 | #include <memory> | 
|---|
| 22 |  | 
|---|
| 23 | #include "math/rectf.hpp" | 
|---|
| 24 | #include "math/sizef.hpp" | 
|---|
| 25 | #include "math/vector.hpp" | 
|---|
| 26 | #include "video/color.hpp" | 
|---|
| 27 | #include "video/drawing_context.hpp" | 
|---|
| 28 | #include "video/font.hpp" | 
|---|
| 29 |  | 
|---|
| 30 | class Surface; | 
|---|
| 31 |  | 
|---|
| 32 | enum RequestType | 
|---|
| 33 | { | 
|---|
| 34 | TEXTURE, GRADIENT, FILLRECT, INVERSEELLIPSE, GETPIXEL, LINE, TRIANGLE | 
|---|
| 35 | }; | 
|---|
| 36 |  | 
|---|
| 37 | struct DrawingRequest | 
|---|
| 38 | { | 
|---|
| 39 | RequestType type; | 
|---|
| 40 |  | 
|---|
| 41 | int layer; | 
|---|
| 42 | Flip flip; | 
|---|
| 43 | float alpha; | 
|---|
| 44 | Blend blend; | 
|---|
| 45 |  | 
|---|
| 46 | DrawingRequest() = delete; | 
|---|
| 47 | DrawingRequest(RequestType type_) : | 
|---|
| 48 | type(type_), | 
|---|
| 49 | layer(), | 
|---|
| 50 | flip(), | 
|---|
| 51 | alpha(), | 
|---|
| 52 | blend() | 
|---|
| 53 | {} | 
|---|
| 54 | virtual ~DrawingRequest() {} | 
|---|
| 55 | }; | 
|---|
| 56 |  | 
|---|
| 57 | struct TextureRequest : public DrawingRequest | 
|---|
| 58 | { | 
|---|
| 59 | TextureRequest() : | 
|---|
| 60 | DrawingRequest(TEXTURE), | 
|---|
| 61 | texture(), | 
|---|
| 62 | displacement_texture(), | 
|---|
| 63 | srcrects(), | 
|---|
| 64 | dstrects(), | 
|---|
| 65 | angles(), | 
|---|
| 66 | color(1.0f, 1.0f, 1.0f) | 
|---|
| 67 | {} | 
|---|
| 68 |  | 
|---|
| 69 | const Texture* texture; | 
|---|
| 70 | const Texture* displacement_texture; | 
|---|
| 71 | std::vector<Rectf> srcrects; | 
|---|
| 72 | std::vector<Rectf> dstrects; | 
|---|
| 73 | std::vector<float> angles; | 
|---|
| 74 | Color color; | 
|---|
| 75 |  | 
|---|
| 76 | private: | 
|---|
| 77 | TextureRequest(const TextureRequest&) = delete; | 
|---|
| 78 | TextureRequest& operator=(const TextureRequest&) = delete; | 
|---|
| 79 | }; | 
|---|
| 80 |  | 
|---|
| 81 | struct GradientRequest : public DrawingRequest | 
|---|
| 82 | { | 
|---|
| 83 | GradientRequest()  : | 
|---|
| 84 | DrawingRequest(GRADIENT), | 
|---|
| 85 | pos(), | 
|---|
| 86 | size(), | 
|---|
| 87 | top(), | 
|---|
| 88 | bottom(), | 
|---|
| 89 | direction(), | 
|---|
| 90 | region() | 
|---|
| 91 | {} | 
|---|
| 92 |  | 
|---|
| 93 | Vector pos; | 
|---|
| 94 | Vector size; | 
|---|
| 95 | Color top; | 
|---|
| 96 | Color bottom; | 
|---|
| 97 | GradientDirection direction; | 
|---|
| 98 | Rectf region; | 
|---|
| 99 | }; | 
|---|
| 100 |  | 
|---|
| 101 | struct FillRectRequest : public DrawingRequest | 
|---|
| 102 | { | 
|---|
| 103 | FillRectRequest() : | 
|---|
| 104 | DrawingRequest(FILLRECT), | 
|---|
| 105 | rect(), | 
|---|
| 106 | color(), | 
|---|
| 107 | radius() | 
|---|
| 108 | {} | 
|---|
| 109 |  | 
|---|
| 110 | Rectf rect; | 
|---|
| 111 | Color color; | 
|---|
| 112 | float radius; | 
|---|
| 113 | }; | 
|---|
| 114 |  | 
|---|
| 115 | struct InverseEllipseRequest : public DrawingRequest | 
|---|
| 116 | { | 
|---|
| 117 | InverseEllipseRequest() : | 
|---|
| 118 | DrawingRequest(INVERSEELLIPSE), | 
|---|
| 119 | pos(), | 
|---|
| 120 | size(), | 
|---|
| 121 | color() | 
|---|
| 122 | {} | 
|---|
| 123 |  | 
|---|
| 124 | Vector pos; | 
|---|
| 125 | Vector size; | 
|---|
| 126 | Color color; | 
|---|
| 127 | }; | 
|---|
| 128 |  | 
|---|
| 129 | struct LineRequest : public DrawingRequest | 
|---|
| 130 | { | 
|---|
| 131 | LineRequest() : | 
|---|
| 132 | DrawingRequest(LINE), | 
|---|
| 133 | pos(), | 
|---|
| 134 | dest_pos(), | 
|---|
| 135 | color() | 
|---|
| 136 | {} | 
|---|
| 137 |  | 
|---|
| 138 | Vector pos; | 
|---|
| 139 | Vector dest_pos; | 
|---|
| 140 | Color color; | 
|---|
| 141 | }; | 
|---|
| 142 |  | 
|---|
| 143 | struct TriangleRequest : public DrawingRequest | 
|---|
| 144 | { | 
|---|
| 145 | TriangleRequest() : | 
|---|
| 146 | DrawingRequest(TRIANGLE), | 
|---|
| 147 | pos1(), | 
|---|
| 148 | pos2(), | 
|---|
| 149 | pos3(), | 
|---|
| 150 | color() | 
|---|
| 151 | {} | 
|---|
| 152 |  | 
|---|
| 153 | Vector pos1, pos2, pos3; | 
|---|
| 154 | Color  color; | 
|---|
| 155 | }; | 
|---|
| 156 |  | 
|---|
| 157 | struct GetPixelRequest : public DrawingRequest | 
|---|
| 158 | { | 
|---|
| 159 | GetPixelRequest() : | 
|---|
| 160 | DrawingRequest(GETPIXEL), | 
|---|
| 161 | pos(), | 
|---|
| 162 | color_ptr() {} | 
|---|
| 163 |  | 
|---|
| 164 | Vector pos; | 
|---|
| 165 | std::shared_ptr<Color> color_ptr; | 
|---|
| 166 |  | 
|---|
| 167 | private: | 
|---|
| 168 | GetPixelRequest(const GetPixelRequest&) = delete; | 
|---|
| 169 | GetPixelRequest& operator=(const GetPixelRequest&) = delete; | 
|---|
| 170 | }; | 
|---|
| 171 |  | 
|---|
| 172 | #endif | 
|---|
| 173 |  | 
|---|
| 174 | /* EOF */ | 
|---|
| 175 |  | 
|---|