1 // GnashTexture.h: GnashImage class used for OpenGL rendering
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc.
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef GNASH_GNASHTEXTURE_H
22 #define GNASH_GNASHTEXTURE_H
24 #include "GnashImage.h"
30 GNASH_TEXTURE_VAAPI
= 1 << 0
33 /// OpenGL texture format
34 class DSOEXPORT GnashTextureFormat
{
35 unsigned int _internal_format
;
39 GnashTextureFormat(image::ImageType type
);
41 /// Return GL internal format
42 unsigned int internal_format() const
43 { return _internal_format
; }
46 unsigned int format() const
50 /// OpenGL texture abstraction
51 class DSOEXPORT GnashTexture
{
54 unsigned int _texture
;
55 GnashTextureFormat _format
;
57 /// OpenGL texture state
59 unsigned int old_texture
;
60 unsigned int was_enabled
: 1;
61 unsigned int was_bound
: 1;
71 GnashTexture(unsigned int width
, unsigned int height
,
72 image::ImageType type
);
73 virtual ~GnashTexture();
75 /// Return texture flags
76 unsigned int flags() const
79 /// Return texture width
80 unsigned int width() const
83 /// Return texture height
84 unsigned int height() const
88 unsigned int texture() const
91 /// Return GL internal format
92 unsigned int internal_format() const
93 { return _format
.internal_format(); }
96 unsigned int format() const
97 { return _format
.format(); }
99 /// Bind texture to a texturing target
105 /// Copy texture data from a buffer.
107 /// Note that this buffer MUST have the same _pitch, or unexpected things
108 /// will happen. In general, it is only safe to copy from another GnashImage
109 /// (or derivative thereof) or unexpected things will happen.
111 /// @param data buffer to copy data from.
112 void update(const std::uint8_t *data
);
117 #endif /* GNASH_GNASHTEXTURE_H */