Gnash  0.8.11dev
Renderer_gles1.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_RENDER_HANDLER_GLES1_H
20 #define GNASH_RENDER_HANDLER_GLES1_H
21 
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
25 
26 #include <vector>
27 
28 // gles-1.0c for Linux
29 #ifdef HAVE_GLES1_GL_H
30 # include <GLES/gl.h>
31 #endif
32 #ifdef HAVE_GLES1_EGL_H
33 #include <GLES/egl.h>
34 #endif
35 
36 #include "Renderer.h"
37 #include "Geometry.h"
38 #include "egl/eglDevice.h"
39 
40 #include <map>
41 
42 namespace gnash {
43 
44 class GnashImage;
45 class SWFCxForm;
46 
47 namespace renderer {
48 
49 namespace gles1 {
50 
51 typedef std::vector<const Path*> PathRefs;
52 
53 struct oglVertex {
54  oglVertex(GLfloat x, GLfloat y, GLfloat z = 0.0)
55  : _x(x), _y(y), _z(z)
56  {
57  }
58 
59  oglVertex(const point& p)
60  : _x(p.x), _y(p.y), _z(0.0)
61  {
62  }
63 
64  GLfloat _x;
65  GLfloat _y;
66  GLfloat _z;
67 };
68 
69 typedef std::map<const Path*, std::vector<oglVertex> > PathPointMap;
70 
72 {
73 public:
74  void newPath(const Path& new_path)
75  {
76  PathRefs refs;
77  refs.push_back(&new_path);
78  shape.push_back(refs);
79  }
80 
81  void addPath(const Path& add_path)
82  {
83  PathRefs& refs = shape.back();
84  refs.push_back(&add_path);
85  }
86 
87  void addPathRefs(const PathRefs& pathrefs)
88  {
89  PathRefs new_refs(pathrefs.begin(), pathrefs.end());
90  shape.push_back(new_refs);
91  }
92 
93  const std::vector<PathRefs>& get() const
94  {
95  return shape;
96  }
97 private:
98  std::vector<PathRefs> shape;
99 };
100 
101  class bitmap_info_ogl //: public BitmapInfo
102 {
103 public:
104 
107  {
109  WRAP_CLAMP
110  };
111 
112  bitmap_info_ogl(GnashImage* image, GLenum pixelformat,
113  bool ogl_accessible);
114  ~bitmap_info_ogl();
115 
116  void apply(const gnash::SWFMatrix& bitmap_matrix,
117  bitmap_wrap_mode wrap_mode) const;
118 private:
119  inline bool ogl_accessible() const;
120  void setup() const;
121  void upload(std::uint8_t* data, size_t width, size_t height) const;
122 
123  mutable std::unique_ptr<GnashImage> _img;
124  GLenum _pixel_format;
125  GLenum _ogl_img_type;
126  mutable bool _ogl_accessible;
127  mutable GLuint _texture_id;
128  size_t _orig_width;
129  size_t _orig_height;
130 };
131 
133 {
134 public:
135  std::string description() const { return "OpenGLES1"; }
136  Renderer_gles1();
138 
139  ~Renderer_gles1();
140 
141  void init(float x, float y);
142  CachedBitmap *createCachedBitmap(std::unique_ptr<image::GnashImage> im);
143 
144  void world_to_pixel(int& x, int& y, float world_x, float world_y) const;
145  gnash::geometry::Range2d<int> world_to_pixel(const gnash::SWFRect& wb) const;
146  geometry::Range2d<int> world_to_pixel(const geometry::Range2d<float>& wb) const;
147  gnash::point pixel_to_world(int, int) const;
148 
149  void begin_display(const gnash::rgba&, int, int, float,
150  float, float, float);
151  // // This is from the patch
152  // void begin_display(const rgba& bg_color, int viewport_x0,
153  // int viewport_y0, int viewport_width,
154  // int viewport_height, float x0, float x1,
155  // float y0, float y1);
156  void end_display();
157  void drawLine(const std::vector<point>& coords, const rgba& fill,
158  const SWFMatrix& mat);
159  void drawVideoFrame(gnash::image::GnashImage *frame, const gnash::Transform& tx,
160  const gnash::SWFRect *bounds, bool smooth);
161  void draw_poly(const std::vector<point>& corners,
162  const rgba& fill, const rgba& outline,
163  const SWFMatrix& mat, bool masked);
164  void drawShape(const gnash::SWF::ShapeRecord&, const gnash::Transform&);
165  void drawGlyph(const SWF::ShapeRecord& rec, const rgba& c,
166  const SWFMatrix& mat);
167 
168  void set_antialiased(bool enable);
169  void begin_submit_mask();
170  void end_submit_mask();
171  void apply_mask();
172  void disable_mask();
173 
174  void set_scale(float xscale, float yscale);
175  void set_invalidated_regions(const InvalidatedRanges &ranges);
176 
177  // These weren't in the patch
178  Renderer *startInternalRender(gnash::image::GnashImage&);
179  void endInternalRender();
180 
181  unsigned int getBitsPerPixel();
182  bool initTestBuffer(unsigned width, unsigned height);
183 
184  // These methods are only for debugging and development
185  void printVGParams();
186  void printVGHardware();
187  void printVGPath();
188  private:
189  unsigned char *_testBuffer; // buffer used by initTestBuffer() only
190 };
191 
192 DSOEXPORT Renderer* create_handler(const char *pixelformat);
193 
194 } // namespace gnash::renderer::gles1
195 } // namespace gnash::renderer
196 } // namespace gnash
197 
198 #endif // __RENDER_HANDLER_GLES1_H__
199 
200 // local Variables:
201 // mode: C++
202 // indent-tabs-mode: nil
203 // End:
GLfloat _x
Definition: Renderer_gles1.h:64
Definition: Renderer_gles1.h:53
Definition: Renderer_gles1.h:101
VGPaint fill
Definition: testr_gtk.cpp:86
GLfloat _y
Definition: Renderer_gles1.h:65
Definition: SWFMatrix.h:53
void newPath(const Path &new_path)
Definition: Renderer_gles1.h:74
void addPathRefs(const PathRefs &pathrefs)
Definition: Renderer_gles1.h:87
GLfloat _z
Definition: Renderer_gles1.h:66
Definition: Renderer_gles1.h:132
bitmap_wrap_mode
Set line and fill styles for mesh & line_strip rendering.
Definition: Renderer_gles1.h:106
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
dtype_t
The list of supported device types.
Definition: GnashDevice.h:48
Definition: klash_part.cpp:329
2D Point class
Definition: Point2d.h:38
Definition: GnashKey.h:149
Base class for render handlers.
Definition: Renderer.h:188
Definition: klash_part.cpp:329
void addPath(const Path &add_path)
Definition: Renderer_gles1.h:81
std::string description() const
Return a description of this renderer.
Definition: Renderer_gles1.h:135
std::map< const Path *, std::vector< oglVertex > > PathPointMap
Definition: Renderer_gles1.h:69
Renderer * create_handler(const char *)
Definition: Renderer_gles1.cpp:315
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:166
std::int32_t x
Definition: BitmapData_as.cpp:434
#define DSOEXPORT
Definition: dsodefs.h:55
Definition: Renderer_gles1.h:71
Definition: eglDevice.h:56
std::vector< const Path * > PathRefs
Definition: Renderer_gles1.h:51
std::int32_t y
Definition: BitmapData_as.cpp:435
Base class for different types of bitmaps.
Definition: GnashImage.h:77
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
Definition: GnashKey.h:162
Definition: GnashKey.h:172
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:37
Holds information needed to draw a shape.
Definition: ShapeRecord.h:126
The Transform class expresses a stage in a cumulative transformation.
Definition: Transform.h:33
oglVertex(GLfloat x, GLfloat y, GLfloat z=0.0)
Definition: Renderer_gles1.h:54
oglVertex(const point &p)
Definition: Renderer_gles1.h:59
A basic RGBA type.
Definition: RGBA.h:35