1 // Copyright 2015-2016 the openage authors. See copying.md for legal info.
2 
3 #include "gui_texture_factory.h"
4 
5 #include "gui_game_spec_image_provider_impl.h"
6 #include "../../../texture.h"
7 #include "gui_texture.h"
8 #include "gui_filled_texture_handles.h"
9 
10 namespace openage {
11 namespace gui {
12 
GuiTextureFactory(GuiGameSpecImageProviderImpl * provider,const QString & id,const QSize & requested_size)13 GuiTextureFactory::GuiTextureFactory(GuiGameSpecImageProviderImpl *provider, const QString &id, const QSize &requested_size)
14 	:
15 	texture_handle(),
16 	texture_handle_user{provider->fill_texture_handle(id, requested_size, &this->texture_handle)} {
17 }
18 
~GuiTextureFactory()19 GuiTextureFactory::~GuiTextureFactory() {
20 }
21 
createTexture(QQuickWindow * window) const22 QSGTexture* GuiTextureFactory::createTexture(QQuickWindow *window) const {
23 	Q_UNUSED(window);
24 	return new GuiTexture{this->texture_handle};
25 }
26 
textureByteCount() const27 int GuiTextureFactory::textureByteCount() const {
28 	// assume 32bit textures
29 	return this->texture_handle.texture->w * this->texture_handle.texture->h * 4;
30 }
31 
textureSize() const32 QSize GuiTextureFactory::textureSize() const {
33 	return openage::gui::textureSize(this->texture_handle);
34 }
35 
36 }} // namespace openage::gui
37