/* Copyright (C) 2017 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include <glibmm/object.h>

_DEFS(gdkmm,gdk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gio
{
class File;
}

namespace Gdk
{
class GLContext;
class Pixbuf;

/** Pixel data.
 *
 * %Gdk::Texture is the basic element used to refer to pixel data.
 * It is primarily meant for pixel data that will not change over
 * multiple frames, and will be used for a long time.
 *
 * You cannot get your pixel data back once you've uploaded it.
 *
 * %Gdk::Texture is an immutable object: That means you cannot change
 * anything about it.
 *
 * @newin{3,94}
 */
class Texture : public Glib::Object
{
  _CLASS_GOBJECT(Texture, GdkTexture, GDK_TEXTURE, Glib::Object, GObject)

protected:
  _CTOR_DEFAULT()

public:
  // All gdk_texture_new_*() functions do more than call g_object_new().
  _WRAP_METHOD(static Glib::RefPtr<Texture> create_for_data(
    const guchar* data, int width, int height, int stride), gdk_texture_new_for_data)
  _WRAP_METHOD(static Glib::RefPtr<Texture> create_for_pixbuf(
    const Glib::RefPtr<Pixbuf>& pixbuf), gdk_texture_new_for_pixbuf)
  _WRAP_METHOD(static Glib::RefPtr<Texture> create_from_resource(
    const std::string& resource_path), gdk_texture_new_from_resource)
  _WRAP_METHOD(static Glib::RefPtr<Texture> create_from_file(
    const Glib::RefPtr<Gio::File>& file), gdk_texture_new_from_file, errthrow)

  /** For instance,
   * void on_gl_resources_released();
   */
  using SlotGLReleased = sigc::slot<void()>;

  _WRAP_METHOD(static Glib::RefPtr<Texture> create_for_gl(
    const Glib::RefPtr<GLContext>& context,
    guint id, int width, int height, const SlotGLReleased& slot{destroy} = {}),
    gdk_texture_new_for_gl, slot_name slot, slot_callback Texture_GL_destroy_callback)
  _WRAP_METHOD(void release_gl(), gdk_texture_release_gl)

  _WRAP_METHOD(int get_width() const, gdk_texture_get_width)
  _WRAP_METHOD(int get_height() const, gdk_texture_get_height)
  _WRAP_METHOD(void download(guchar* data, gsize stride) const, gdk_texture_download)

  _WRAP_PROPERTY("width", int)
  _WRAP_PROPERTY("height", int)

  // There are no public signals or vfuncs.
};

} // namespace Gdk
