1 //
2 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 //   2011 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 
20 #ifdef HAVE_CONFIG_H
21 #include "gnashconfig.h"
22 #endif
23 
24 #include "gtk_glue.h"
25 
26 #include <gtk/gtk.h>
27 #include <gdk/gdk.h>
28 #include <memory>
29 #include "vaapi/VaapiImageFormat.h"
30 
31 namespace gnash
32 {
33 
34 // Forward declarations
35 class VaapiImage;
36 class VaapiSurface;
37 class VaapiSubpicture;
38 class VaapiRectangle;
39 class VaapiVideoWindow;
40 class Renderer_agg_base;
41 class movie_root;
42 
43 class GtkAggVaapiGlue : public GtkGlue
44 {
45 public:
46     GtkAggVaapiGlue();
47     ~GtkAggVaapiGlue();
48 
49     bool init(int argc, char **argv[]);
50     void prepDrawingArea(GtkWidget *drawing_area);
51     Renderer* createRenderHandler();
52     void setRenderHandlerSize(int width, int height);
53     virtual void beforeRendering(movie_root* stage);
54     void render();
55     void render(GdkRegion * const);
56     void configure(GtkWidget *const widget, GdkEventConfigure *const event);
57 
58 private:
59     VaapiVideoWindow *getVideoWindow(std::shared_ptr<VaapiSurface> surface,
60                                      GdkWindow *parent_window,
61                                      VaapiRectangle const & rect);
62 
63     void resetRenderSurface(unsigned int width, unsigned int height);
64 
65 private:
66     Renderer_agg_base                  *_agg_renderer;
67     VaapiImageFormat                    _vaapi_image_format;
68     std::shared_ptr<VaapiImage>       _vaapi_image;
69     unsigned int                        _vaapi_image_width;
70     unsigned int                        _vaapi_image_height;
71     std::shared_ptr<VaapiSubpicture>  _vaapi_subpicture;
72     std::unique_ptr<VaapiSurface>         _vaapi_surface;
73     unsigned int                        _window_width;
74     unsigned int                        _window_height;
75     bool                                _window_is_setup;
76 };
77 
78 } // namespace gnash
79