/* Copyright (C) 2020 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 <gdkmm/texture.h>
#include <glibmm/bytes.h>
#include <gdk/gdk.h> // For GDK_MEMORY_DEFAULT

_DEFS(gdkmm,gdk)
_PINCLUDE(gdkmm/private/texture_p.h)

namespace Gdk
{
/** A Gdk::Texture representing image data in memory.
 *
 * @newin{3,98}
 */
class GDKMM_API MemoryTexture : public Gdk::Texture
{
  _CLASS_GOBJECT(MemoryTexture, GdkMemoryTexture, GDK_MEMORY_TEXTURE, Gdk::Texture, GdkTexture, , , GDKMM_API)
  _DO_NOT_DERIVE_GTYPE dnl// GdkMemoryTexture is an internal type
  _ABI_AS_WITH_DERIVED_GTYPE dnl// Remove when we can break ABI

protected:
  _CTOR_DEFAULT()

public:
  //TODO: When we can break API/ABI, remove MemoryTexture::Format and replace
  // it by MemoryFormat. MemoryTexture::Format became problematic when
  // Texture::get_format() was added to the base class.
  /** @enum Format
   * Prefer Gdk::MemoryFormat to %Gdk::MemoryTexture::Format where possible.
   *
   * %Gdk::MemoryFormat and %Gdk::MemoryTexture::Format are identical.
   * It's possible to convert between them with static_cast.
   */
  _WRAP_ENUM(Format, GdkMemoryFormat, decl_prefix GDKMM_API)

  /** Default memory format used by GTK.
   *
   * It is the format provided by Gdk::Texture::download().
   * It is equal to Cairo::Surface::Format::ARGB32.
   *
   * Be aware that unlike the Format values, this format is
   * different for different endianness.
   */
  static const Format DEFAULT_FORMAT = static_cast<Format>(GDK_MEMORY_DEFAULT);

  // gdk_memory_texture_new() does more than call g_object_new().
  _WRAP_METHOD(static Glib::RefPtr<Texture> create(int width, int height,
    Format format, const Glib::RefPtr<const Glib::Bytes>& bytes, gsize stride),
    gdk_memory_texture_new)

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

} // namespace Gdk
