mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-11 11:24:30 +00:00
SDL_gpu implementation for ttext::render_as_texture.
This commit is contained in:
parent
6db593c623
commit
dde5c00d08
15
src/text.cpp
15
src/text.cpp
@ -94,6 +94,9 @@ ttext::ttext() :
|
||||
layout_(pango_layout_new(context_)),
|
||||
rect_(),
|
||||
surface_(),
|
||||
#ifdef SDL_GPU
|
||||
texture_(),
|
||||
#endif
|
||||
text_(),
|
||||
markedup_text_(false),
|
||||
font_size_(14),
|
||||
@ -165,6 +168,14 @@ sdl::ttexture ttext::render_as_texture() const
|
||||
rerender();
|
||||
return texture_;
|
||||
}
|
||||
#else
|
||||
#ifdef SDL_GPU
|
||||
sdl::ttexture ttext::render_as_texture() const
|
||||
{
|
||||
rerender();
|
||||
return texture_;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int ttext::get_width() const
|
||||
@ -699,6 +710,10 @@ void ttext::rerender(const bool force) const
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
texture_ = CVideo::get_window()->create_texture
|
||||
(SDL_TEXTUREACCESS_STATIC, surface_);
|
||||
#else
|
||||
#ifdef SDL_GPU
|
||||
texture_ = sdl::ttexture(surface_);
|
||||
#endif
|
||||
#endif
|
||||
cairo_destroy(cr);
|
||||
cairo_surface_destroy(cairo_surface);
|
||||
|
19
src/text.hpp
19
src/text.hpp
@ -29,6 +29,11 @@
|
||||
#include "sdl/texture.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef SDL_GPU
|
||||
#include "sdl/gpu.hpp"
|
||||
#include "sdl/texture.hpp"
|
||||
#endif
|
||||
|
||||
struct language_def;
|
||||
|
||||
namespace gui2 {
|
||||
@ -84,6 +89,16 @@ public:
|
||||
* redraws the texture before returning it.
|
||||
*/
|
||||
sdl::ttexture render_as_texture() const;
|
||||
#else
|
||||
#ifdef SDL_GPU
|
||||
/**
|
||||
* Returns the rendered text as a texture.
|
||||
*
|
||||
* Before rendering it tests whether a redraw is needed and if so it first
|
||||
* redraws the texture before returning it.
|
||||
*/
|
||||
sdl::ttexture render_as_texture() const;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Returns the width needed for the text. */
|
||||
@ -225,6 +240,10 @@ private:
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
/** The texture to render upon used as a cache. */
|
||||
mutable sdl::ttexture texture_;
|
||||
#else
|
||||
#ifdef SDL_GPU
|
||||
mutable sdl::ttexture texture_;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** The text to draw (stored as UTF-8). */
|
||||
|
Loading…
x
Reference in New Issue
Block a user