gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, openvg, updated. 53cd49b0a21cbc2f9ff8


From: Rob Savoye
Subject: [Gnash-commit] [SCM] Gnash branch, openvg, updated. 53cd49b0a21cbc2f9ff887a076e61e0efc5b247e
Date: Wed, 12 Jan 2011 18:04:08 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, openvg has been updated
       via  53cd49b0a21cbc2f9ff887a076e61e0efc5b247e (commit)
       via  e7657ca77ac516421a7a7fd2093067353276e5c5 (commit)
       via  7e8b4cf85ad4db0c073d2b1593e490e4b18a8ca2 (commit)
       via  cd4c1e2ef473e64a722644b49ba1d4088d187166 (commit)
       via  0e936356b7997957906af8244ce256582b332534 (commit)
       via  bbe2140e0ac171891733a2a539e0a49d3ad20fe1 (commit)
       via  ac2716870f2f9ca2eb91c18ee75d76f1c5046d14 (commit)
       via  2150b590a75a169bc31271d25b233c729ec170df (commit)
      from  e50904482fc2f1fdc4633181e442fda2be9ad4a6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=53cd49b0a21cbc2f9ff887a076e61e0efc5b247e


commit 53cd49b0a21cbc2f9ff887a076e61e0efc5b247e
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 1 21:45:51 2011 -0700

    openvg/Renderer_ovg.h is now openvg/OpenVGRenderer.h

diff --git a/librender/testr.cpp b/librender/testr.cpp
index 424f717..a71764c 100644
--- a/librender/testr.cpp
+++ b/librender/testr.cpp
@@ -53,7 +53,7 @@
 #include "opengl/Renderer_ogl.h"
 #endif
 #ifdef RENDERER_OPENVG
-#include "openvg/Renderer_ovg.h"
+#include "openvg/OpenVGRenderer.h"
 #include <VG/vgu.h>
 #ifdef HAVE_VG_VGEXT_H
 # include <VG/vgext.h>

http://git.savannah.gnu.org/cgit//commit/?id=e7657ca77ac516421a7a7fd2093067353276e5c5


commit e7657ca77ac516421a7a7fd2093067353276e5c5
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 1 21:44:44 2011 -0700

    add support for hardware gradients

diff --git a/librender/openvg/OpenVGBitmap.cpp 
b/librender/openvg/OpenVGBitmap.cpp
index 524db20..8b4582b 100644
--- a/librender/openvg/OpenVGBitmap.cpp
+++ b/librender/openvg/OpenVGBitmap.cpp
@@ -21,6 +21,7 @@
 #include "Renderer.h"
 #include "openvg/OpenVGRenderer.h"
 #include "openvg/OpenVGBitmap.h"
+#include "VG/openvg.h"
 
 namespace gnash {
 
@@ -28,28 +29,37 @@ namespace renderer {
 
 namespace openvg {
 
-OpenVGBitmap::OpenVGBitmap(std::auto_ptr<image::GnashImage> im)
-    : _image(im.release())
+static const int NUM_STOPS = 10;
+
+OpenVGBitmap::OpenVGBitmap(VGPaint paint)
 {
     GNASH_REPORT_FUNCTION;
+    if (paint) {
+        _vgpaint = paint;
+    }
 }
 
-OpenVGBitmap::OpenVGBitmap(std::auto_ptr<image::GnashImage> im,
-                           VGImageFormat pixelformat, VGPaint vgpaint)
-    : _image(im.release()),
-      _pixel_format(pixelformat),
-      _vgpaint(vgpaint)
+// 
+// VG_sRGB_565
+// VG_sRGBA_5551
+// VG_sRGBA_4444
+// VG_A_8
+OpenVGBitmap::OpenVGBitmap(std::auto_ptr<image::GnashImage> image, VGPaint 
paint)
+    :
+    _image(image),
+    _pixel_format(VG_A_4), // was VG_sARGB_8888  VG_sRGB_565
+    _vgpaint(paint)
 {
     GNASH_REPORT_FUNCTION;
-    
+
     size_t width = _image->width();
     size_t height = _image->height();
 
     // Create a VG image, and copy the GnashImage data into it
-    _vgimage = vgCreateImage(VG_sRGB_565, width, height,
+    _vgimage = vgCreateImage(_pixel_format, width, height,
                              VG_IMAGE_QUALITY_FASTER);    
     
-    vgImageSubData(_vgimage, _image->begin(), width * 4, VG_sRGB_565,
+    vgImageSubData(_vgimage, _image->begin(), width * 4, _pixel_format,
                    0, 0, width, height);
     
     _tex_size += width * height * 4;
@@ -67,7 +77,8 @@ OpenVGBitmap::~OpenVGBitmap()
               _image->width() * _image->height() * 4,
               _image->width(), _image->height(), 4);
     log_debug(_("Current Texture size: %d"), _tex_size);
-    
+
+//    vgDestroyPaint(_vgpaint);
     vgDestroyImage(_vgimage);
 }
 
@@ -80,18 +91,20 @@ OpenVGBitmap::image()
     }
 }    
 
+// 
 void
 OpenVGBitmap::apply(const gnash::SWFMatrix& bitmap_matrix,
-                    bitmap_wrap_mode wrap_mode) const
+                    bitmap_wrap_mode wrap_mode, VGPaint paint) const
 {
     GNASH_REPORT_FUNCTION;
+    
     gnash::SWFMatrix mat;
     VGfloat     vmat[9];
     
     mat = bitmap_matrix;
     
-    vgSetParameteri (_vgpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
-    vgPaintPattern (_vgpaint, _vgimage);
+    vgSetParameteri (paint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
+    vgPaintPattern (paint, _vgimage);
     
     mat.invert();
     memset(vmat, 0, sizeof(vmat));
@@ -109,12 +122,75 @@ OpenVGBitmap::apply(const gnash::SWFMatrix& bitmap_matrix,
     vgSeti (VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
     
     if (wrap_mode == WRAP_CLAMP) {  
-        vgSetParameteri (_vgpaint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_PAD);
+        vgSetParameteri (paint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_PAD);
     } else {
-        vgSetParameteri (_vgpaint, VG_PAINT_PATTERN_TILING_MODE, 
VG_TILE_REPEAT);
+        vgSetParameteri (paint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_REPEAT);
     }
 }
 
+/// OpenVG supports creating linear and gradient fills in hardware, so
+/// we want to use that instead of the existing way of calculating the
+/// gradient in software.
+OpenVGBitmap *
+OpenVGBitmap::createRadialBitmap(float cx, float cy, float fx, float fy, float 
radial,
+                                 VGPaint paint)
+{
+    GNASH_REPORT_FUNCTION;
+
+    VGfloat rgParams[] = { cx, cy, fx, fy, radial };
+    VGfloat stops[5*NUM_STOPS];
+    
+    // Paint Type 
+    vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_RADIAL_GRADIENT);
+
+    // Gradient Parameters
+    vgSetParameterfv(paint, VG_PAINT_RADIAL_GRADIENT, 4, rgParams);
+
+    // Color Ramp is the same as for linear gradient
+    return this;
+}
+
+OpenVGBitmap *
+OpenVGBitmap::createLinearBitmap(float x0, float y0, float x1, float y1, 
VGPaint paint)
+{
+    GNASH_REPORT_FUNCTION;
+
+    VGfloat lgParams[] = { x0, y0, x1, y1 };
+    VGfloat stops[] = { 0.0, 0.33, 0.66, 1.0};
+    
+    // Paint Type
+    vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
+    // Gradient Parameters
+    vgSetParameterfv(paint, VG_PAINT_LINEAR_GRADIENT, 4, lgParams);
+    // Color Ramp
+    vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, 5*NUM_STOPS, stops);
+    vgSetParameteri(paint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, 
VG_COLOR_RAMP_SPREAD_PAD);
+
+    return this;
+}
+
+    // Create and fill pattern image
+OpenVGBitmap *
+OpenVGBitmap::createPatternBitmap(std::auto_ptr<image::GnashImage> im, VGPaint 
paint)
+{
+    GNASH_REPORT_FUNCTION;
+
+    if (paint != VG_INVALID_HANDLE) {
+        _vgimage = vgCreateImage(_pixel_format, im->width(), im->height(),
+                                 VG_IMAGE_QUALITY_FASTER);
+        vgImageSubData(_vgimage, im->begin(), 4*im->width(), /* stride */
+                       _pixel_format, 0, 0, im->width(), im->height());
+        
+        vgSetParameteri(_vgpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
+        vgSetParameteri(_vgpaint, VG_PAINT_PATTERN_TILING_MODE, 
VG_TILE_REPEAT);
+        vgPaintPattern(_vgpaint, _vgimage);
+        vgDrawImage(_vgimage);
+        vgFlush();
+    }
+
+    return this;
+}
+
 } // namespace gnash::renderer::openvg
 } // namespace gnash::renderer
 } // namespace gnash
diff --git a/librender/openvg/OpenVGBitmap.h b/librender/openvg/OpenVGBitmap.h
index 14d27ce..c3ebc31 100644
--- a/librender/openvg/OpenVGBitmap.h
+++ b/librender/openvg/OpenVGBitmap.h
@@ -38,10 +38,9 @@ public:
     /// Set line and fill styles for mesh & line_strip rendering.
     enum bitmap_wrap_mode { WRAP_REPEAT, WRAP_CLAMP };
     
-    OpenVGBitmap(std::auto_ptr<image::GnashImage> im);
-  
-    OpenVGBitmap(std::auto_ptr<image::GnashImage> im,
-                 VGImageFormat pixelformat, VGPaint vgpaint);
+    OpenVGBitmap(VGPaint paint);
+    OpenVGBitmap(const CachedBitmap *bitmap, VGPaint vgpaint);
+    OpenVGBitmap(std::auto_ptr<image::GnashImage> im, VGPaint vgpaint);
     ~OpenVGBitmap();
 
     void dispose()  { _image.reset(); }
@@ -50,13 +49,24 @@ public:
     image::GnashImage& image();
     
     void apply(const gnash::SWFMatrix& bitmap_matrix,
-               bitmap_wrap_mode wrap_mode) const;
+               bitmap_wrap_mode wrap_mode, VGPaint paint) const;
     // Accessors for the GnashImage internal data
-    int getWidth() { return _image->width(); };
-    int getHeight() { return _image->height(); };
-    boost::uint8_t *getData() const { return _image->begin(); };
+    VGPaint getFillPaint() const { return _vgpaint; }
+    int getWidth() { return _image->width(); }
+    int getHeight() { return _image->height(); }
+    boost::uint8_t *getData() const { return _image->begin(); }
 
-private:    
+    /// OpenVG supports creating linear and gradient fills in hardware, so
+    /// we want to use that instead of the existing way of calculating the
+    /// gradient in software.
+    OpenVGBitmap *createRadialBitmap(float x0, float y0, float x1,
+                                     float y1, float radial, VGPaint paint);
+    OpenVGBitmap *createLinearBitmap(float x0, float y0, float x1,
+                                     float y1, VGPaint paint);
+    OpenVGBitmap *createPatternBitmap(std::auto_ptr<image::GnashImage> im,
+                                      VGPaint paint);
+
+private:
     boost::scoped_ptr<image::GnashImage> _image;
     VGImageFormat   _pixel_format;
     mutable VGImage _vgimage;
diff --git a/librender/openvg/OpenVGRenderer.h 
b/librender/openvg/OpenVGRenderer.h
index c855c83..9e9e6dd 100644
--- a/librender/openvg/OpenVGRenderer.h
+++ b/librender/openvg/OpenVGRenderer.h
@@ -100,8 +100,7 @@ public:
                   const rgba& fill, const rgba& outline,
                   const SWFMatrix& mat, bool masked);
     // this is in master
-    void drawShape(const gnash::SWF::ShapeRecord&,
-                                    const gnash::Transform&);
+    void drawShape(const gnash::SWF::ShapeRecord&, const gnash::Transform&);
     // This is from the patch
     void drawGlyph(const SWF::ShapeRecord& rec, const rgba& c,
                    const SWFMatrix& mat);
@@ -115,19 +114,18 @@ public:
     void set_scale(float xscale, float yscale);
     void set_invalidated_regions(const InvalidatedRanges &ranges);
 
-    // These weren't in the patch
+    // These weren't in the patch, and do nothing anyway
     Renderer *startInternalRender(gnash::image::GnashImage&);
     void endInternalRender();
 
     unsigned int getBitsPerPixel();
-    bool initTestBuffer(unsigned width, unsigned height);
-    void init_buffer(unsigned char *mem, int size, int x, int y, int 
rowstride);
+
+    void setFillPaint(const VGPaint paint) { _fillpaint = paint; }
 
     // These methods are only for debugging and development
     void printVGParams();
     void printVGHardware();
-    void printVGPath();
-    
+    void printVGPath();    
 #if 0
     // These are all required by the Render class
     void draw_poly(const point* corners, size_t corner_count,
@@ -142,12 +140,12 @@ public:
     void begin_submit_mask();
 #endif
   private:
-    void draw_mask(const PathVec& path_vec);
     void add_paths(const PathVec& path_vec);
     Path reverse_path(const Path& cur_path);
     const Path* find_connecting_path(const Path& to_connect,
                                      std::list<const Path*> path_refs);
     PathVec normalize_paths(const PathVec &paths);
+    
     /// Analyzes a set of paths to detect real presence of fills and/or 
outlines
     /// TODO: This should be something the character tells us and should be 
     /// cached. 
@@ -164,36 +162,35 @@ public:
     PathPtrVec paths_by_style(const PathVec& path_vec, unsigned int style);
     std::vector<PathVec::const_iterator> find_subshapes(const PathVec& 
path_vec);
     void apply_matrix_to_paths(std::vector<Path>& paths, const SWFMatrix& mat);
+    
     void draw_subshape(const PathVec& path_vec, const SWFMatrix& mat,
                        const SWFCxForm& cx,
                        const std::vector<FillStyle>& fill_styles,
                        const std::vector<LineStyle>& line_styles);
+    void draw_mask(const PathVec& path_vec);    
     void draw_submask(const PathVec& path_vec, const SWFMatrix& mat,
                       const SWFCxForm& cx, const FillStyle& f_style);
-    
-    float _xscale;
-    float _yscale;
-    float _width; // Width of the movie, in world coordinates.
-    float _height;
+
+    float       _xscale;
+    float       _yscale;
+    float       _width; // Width of the movie, in world coordinates.
+    float       _height;
   
     // Output size.
-    float _display_width;
-    float _display_height;
+    float       _display_width;
+    float       _display_height;
   
     std::vector<PathVec> _masks;
-    bool _drawing_mask;
+    bool        _drawing_mask;
   
     gnash::SWFMatrix stage_matrix;  // conversion from TWIPS to pixels
     
-    VGPaint     m_fillpaint;
-    VGPaint     m_strokepaint;
+    VGPaint     _fillpaint;
+    VGPaint     _strokepaint;
 
-#ifdef OPENVG_VERSION_1_1    
-    VGMaskLayer m_mask;
+#ifdef OPENVG_VERSION_1_1
+    VGMaskLayer _mask;
 #endif
-    unsigned char *_testBuffer; // buffer used by initTestBuffer() only
-    
-    boost::scoped_ptr<renderer::GnashDevice> _device;
 };
 
 namespace {
diff --git a/librender/openvg/OpenVGStyle.h b/librender/openvg/OpenVGStyle.h
index 6d8fa48..2127a3b 100644
--- a/librender/openvg/OpenVGStyle.h
+++ b/librender/openvg/OpenVGStyle.h
@@ -97,17 +97,17 @@ public:
 };
 
 /// Get the bitmap data of a style from the variant
-class GetBitmap : public boost::static_visitor<const CachedBitmap *>
+class GetBitmap : public boost::static_visitor<CachedBitmap *>
 {
 public:
-    const CachedBitmap *operator()(const SolidFill&) const {
+    CachedBitmap *operator()(const SolidFill&) const {
         return 0;
     }
-    const CachedBitmap *operator()(const GradientFill&) const {
+    CachedBitmap *operator()(const GradientFill&) const {
         return 0;
     }
-    const CachedBitmap *operator()(const BitmapFill& b) const {
-        return b.bitmap();
+    CachedBitmap *operator()(const BitmapFill& b) const {
+        return const_cast<CachedBitmap *>(b.bitmap());
     }
 };
 

http://git.savannah.gnu.org/cgit//commit/?id=7e8b4cf85ad4db0c073d2b1593e490e4b18a8ca2


commit 7e8b4cf85ad4db0c073d2b1593e490e4b18a8ca2
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 1 21:43:13 2011 -0700

    initialize the surface, use hardware gradients instad of crappy software 
ones ripped off from OpenGL. Handle embedded bitmaps

diff --git a/librender/openvg/OpenVGRenderer.cpp 
b/librender/openvg/OpenVGRenderer.cpp
index 1669d62..557e7c3 100644
--- a/librender/openvg/OpenVGRenderer.cpp
+++ b/librender/openvg/OpenVGRenderer.cpp
@@ -179,7 +179,12 @@ for_each(C& container, R (T::*pmf)(const A&),const A& arg)
 Renderer_ovg::Renderer_ovg()
     : _display_width(0.0),
       _display_height(0.0),
-      _drawing_mask(false)
+      _drawing_mask(false),
+      _fillpaint(0),
+      _strokepaint(0)
+#ifdef OPENVG_VERSION_1_1    
+      , _mask(0)
+#endif
 {
     GNASH_REPORT_FUNCTION;
 }
@@ -188,15 +193,19 @@ Renderer_ovg::Renderer_ovg(renderer::GnashDevice::dtype_t 
/* dtype */)
     : _display_width(0.0),
       _display_height(0.0),
       _drawing_mask(false)
+#ifdef OPENVG_VERSION_1_1    
+      , _mask(0)
+#endif
 {
     GNASH_REPORT_FUNCTION;
 
     set_scale(1.0f, 1.0f);
-    m_fillpaint = vgCreatePaint();
-    m_strokepaint = vgCreatePaint();
+    _fillpaint = vgCreatePaint();
     
-    vgSetPaint (m_fillpaint,   VG_FILL_PATH);
-    vgSetPaint (m_strokepaint, VG_STROKE_PATH);
+    _strokepaint = vgCreatePaint();
+    
+    vgSetPaint (_fillpaint,   VG_FILL_PATH);
+    vgSetPaint (_strokepaint, VG_STROKE_PATH);
 }
 
 void
@@ -207,6 +216,14 @@ Renderer_ovg::init(float x, float y)
     _display_width = x;
     _display_height = y;
     
+    _fillpaint = vgCreatePaint();
+    
+    log_debug("FIXME: %s: %p", __FUNCTION__, _fillpaint);
+    _strokepaint = vgCreatePaint();
+    
+    vgSetPaint (_fillpaint,   VG_FILL_PATH);
+    vgSetPaint (_strokepaint, VG_STROKE_PATH);
+
     // Turn on alpha blending.
     vgSeti (VG_BLEND_MODE, VG_BLEND_SRC_OVER);
     
@@ -217,7 +234,7 @@ Renderer_ovg::init(float x, float y)
     vgSetfv( VG_CLEAR_COLOR, 4, clearColor );
     
 #ifdef OPENVG_VERSION_1_1    
-    m_mask = vgCreateMaskLayer(x, y);
+    _mask = vgCreateMaskLayer(x, y);
 #endif
 
     log_debug("VG Vendor is %s, VG Version is %s, VG Renderer is %s",
@@ -231,14 +248,14 @@ Renderer_ovg::~Renderer_ovg()
 {
     GNASH_REPORT_FUNCTION;
 
-    vgDestroyPaint(m_fillpaint);
-    vgDestroyPaint(m_strokepaint);
+    vgDestroyPaint(_fillpaint);
+    vgDestroyPaint(_strokepaint);
 #ifdef OPENVG_VERSION_1_1    
-    vgDestroyMaskLayer(m_mask);
+    vgDestroyMaskLayer(_mask);
 #endif
 }
 
-// Given an image, returns a pointer to a bitmap_info class
+// Given an image, returns a pointer to a CachedBitmap class
 // that can later be passed to fill_styleX_bitmap(), to set a
 // bitmap fill style.
 CachedBitmap *
@@ -246,8 +263,12 @@ 
Renderer_ovg::createCachedBitmap(std::auto_ptr<image::GnashImage> im)
 {
     GNASH_REPORT_FUNCTION;
 
-    // OpenVG don't support 24bit RGB, need translate colorspace
-    return reinterpret_cast<CachedBitmap *>(new OpenVGBitmap(im, VG_sRGB_565, 
0));
+    // OpenVG don't support 24bit RGB, so we need to translate
+    // the colorspace
+//    image::GnashImage &image = im.release();
+    return reinterpret_cast<CachedBitmap *>(new OpenVGBitmap(im, _fillpaint));
+
+    return 0;
 }
 
 // Since we store drawing operations in display lists, we take special care
@@ -318,7 +339,7 @@ Renderer_ovg::begin_display(const rgba& /* bg_color */, int 
/* viewport_x0 */,
                             int /* viewport_height */, float x0, float x1,
                             float y0, float y1)
 {
-//    GNASH_REPORT_FUNCTION;
+    GNASH_REPORT_FUNCTION;
     
     vgSeti (VG_MASKING, VG_FALSE);
     
@@ -332,6 +353,7 @@ Renderer_ovg::begin_display(const rgba& /* bg_color */, int 
/* viewport_x0 */,
     mat[7] = _display_height;   // shift ty
     
     vgSeti (VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+    vgLoadIdentity();
     vgLoadMatrix (mat);
  }
 
@@ -371,8 +393,8 @@ Renderer_ovg::drawLine(const std::vector<point>& coords, 
const rgba& fill,
                             1, 0, 0, 0,
                             VG_PATH_CAPABILITY_ALL);
     vgSetf (VG_FILL_RULE, VG_EVEN_ODD );
-    vgSetParameteri (m_strokepaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
-    vgSetParameterfv (m_strokepaint, VG_PAINT_COLOR, 4, color);
+    vgSetParameteri (_strokepaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+    vgSetParameterfv (_strokepaint, VG_PAINT_COLOR, 4, color);
     
     std::vector<point>::const_iterator  it = coords.begin();
     std::vector<point>::const_iterator end = coords.end();
@@ -437,8 +459,8 @@ Renderer_ovg::drawPoly(const point* corners, size_t 
corner_count,
                             VG_PATH_CAPABILITY_ALL);
     vgSetf (VG_FILL_RULE, VG_NON_ZERO );
     
-    vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
-    vgSetParameterfv (m_fillpaint, VG_PAINT_COLOR, 4, color);
+    vgSetParameteri (_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+    vgSetParameterfv (_fillpaint, VG_PAINT_COLOR, 4, color);
     
     const point *ptr = corners;
     gseg[scount++] = VG_MOVE_TO;
@@ -510,6 +532,7 @@ Renderer_ovg::apply_mask()
     float omat[9];
     
     vgSeti (VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+    vgLoadIdentity();
     vgGetMatrix (omat);
     
     memset(mat, 0, sizeof(mat));
@@ -522,7 +545,7 @@ Renderer_ovg::apply_mask()
     vgLoadMatrix(mat);
     
 #ifdef OPENVG_VERSION_1_1    
-    vgMask(m_mask, VG_FILL_MASK, 0, 0, _display_width, _display_height); // 
FIXME
+    vgMask(_mask, VG_FILL_MASK, 0, 0, _display_width, _display_height); // 
FIXME
 #endif
 // Call add_paths for each mask.
     std::for_each(_masks.begin(), _masks.end(),
@@ -537,11 +560,7 @@ Renderer_ovg::add_paths(const PathVec& path_vec)
     GNASH_REPORT_FUNCTION;
     SWFCxForm dummy_cx;
     
-#if 0                           // original
-    FillStyle coloring = SolidFill(rgba(0,255,0,255));
-#else
     FillStyle coloring = FillStyle(SolidFill(rgba(0, 255, 0, 255)));
-#endif
 
     draw_submask(path_vec, SWFMatrix(), dummy_cx, coloring);
 }
@@ -556,8 +575,7 @@ Renderer_ovg::disable_mask()
         vgSeti (VG_MASKING, VG_FALSE);
     } else {
         apply_mask();
-    }
-    
+    }    
 }
 
 Path
@@ -715,69 +733,73 @@ Renderer_ovg::apply_fill_style(const FillStyle& style, 
const SWFMatrix& mat,
     GNASH_REPORT_FUNCTION;
 
     SWF::FillType fill_type = boost::apply_visitor(GetType(), style.fill);
-    log_debug("Fill type is: %d", fill_type);
     switch (fill_type) {
         
       case SWF::FILL_LINEAR_GRADIENT:
       case SWF::FILL_RADIAL_GRADIENT:
       case SWF::FILL_FOCAL_GRADIENT:
       {
+          log_debug("Fill Style Type: Gradient");
+          OpenVGBitmap* binfo = new OpenVGBitmap(_fillpaint);
+          
           GradientFill::Type gt;
           switch (fill_type) {
           case SWF::FILL_LINEAR_GRADIENT:
-              gt = GradientFill::LINEAR;
+          {
+              binfo->createLinearBitmap(mat.sx, mat.sy, mat.tx, mat.ty,
+                                        _fillpaint);
               break;
+          }
           case SWF::FILL_RADIAL_GRADIENT:
           case SWF::FILL_FOCAL_GRADIENT:
-              gt = GradientFill::RADIAL;
+          {
+              float x0, y0, x1, y1, radial;
+              binfo->createRadialBitmap(x0, y0, x1, y1, radial, _fillpaint);
               break;
+          }
           default:
               std::abort();
           }
-          GradientFill gf(gt, mat);
-
-          const OpenVGBitmap* binfo = reinterpret_cast<const OpenVGBitmap *>(
-               createGradientBitmap(gf, this));
-
-          binfo->apply(gf.matrix(), OpenVGBitmap::WRAP_CLAMP); 
-          vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
+          SWFMatrix sm = boost::apply_visitor(GetMatrix(), style.fill);        
  
+          binfo->apply(sm, OpenVGBitmap::WRAP_CLAMP, _fillpaint);
+          vgSetParameteri (_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
           break;
       }
       case SWF::FILL_TILED_BITMAP_HARD:
       case SWF::FILL_TILED_BITMAP:
       {
-          const CachedBitmap *cb = boost::apply_visitor(GetBitmap(), 
style.fill);
-          const OpenVGBitmap* binfo = dynamic_cast<const OpenVGBitmap *>(cb);
           SWFMatrix sm = boost::apply_visitor(GetMatrix(), style.fill);        
  
-          binfo->apply(sm, OpenVGBitmap::WRAP_REPEAT);
-          vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
+          CachedBitmap *cb = boost::apply_visitor(GetBitmap(), style.fill);
+          std::auto_ptr<image::GnashImage> im(&cb->image());
+          OpenVGBitmap *binfo = new OpenVGBitmap(_fillpaint);
+          binfo->createPatternBitmap(im, _fillpaint);
+          binfo->apply(sm, OpenVGBitmap::WRAP_REPEAT, _fillpaint);
           break;
       }
       
       case SWF::FILL_CLIPPED_BITMAP:
       case SWF::FILL_CLIPPED_BITMAP_HARD:
       {     
-          const CachedBitmap *cb = boost::apply_visitor(GetBitmap(), 
style.fill);
-          const OpenVGBitmap* binfo = dynamic_cast<const OpenVGBitmap *>(cb);  
   
-
           SWFMatrix sm = boost::apply_visitor(GetMatrix(), style.fill);
-          binfo->apply(sm, OpenVGBitmap::WRAP_CLAMP);
-          vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
+          CachedBitmap *cb = boost::apply_visitor(GetBitmap(), style.fill);
+          std::auto_ptr<image::GnashImage> im(&cb->image());
+          OpenVGBitmap *binfo = new OpenVGBitmap(im, _fillpaint);
+          binfo->apply(sm, OpenVGBitmap::WRAP_CLAMP, _fillpaint);
           break;
       } 
       case SWF::FILL_SOLID:
       {
-          rgba fc = boost::apply_visitor(GetColor(), style.fill);
-          rgba c = cx.transform(fc);
+          rgba incolor = boost::apply_visitor(GetColor(), style.fill);
+          rgba c = cx.transform(incolor);
           VGfloat color[] = {
               c.m_r / 255.0f,
               c.m_g / 255.0f,
               c.m_b / 255.0f,
               c.m_a / 255.0f
           };
-          
-          vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
-          vgSetParameterfv (m_fillpaint, VG_PAINT_COLOR, 4, color);
+
+          vgSetParameteri (_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+          vgSetParameterfv (_fillpaint, VG_PAINT_COLOR, 4, color);
       }
       
     } // switch
@@ -854,8 +876,8 @@ Renderer_ovg::apply_line_style(const LineStyle& style, 
const SWFCxForm& cx,
     };
     
     
-    vgSetParameteri (m_strokepaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
-    vgSetParameterfv (m_strokepaint, VG_PAINT_COLOR, 4, color);
+    vgSetParameteri (_strokepaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+    vgSetParameterfv (_strokepaint, VG_PAINT_COLOR, 4, color);
     
     return rv;
 }
@@ -1079,8 +1101,8 @@ Renderer_ovg::draw_submask(const PathVec& path_vec,
     
     VGfloat color[] = {1.0f, 1.0f, 1.0f, 1.0f};
     
-    vgSetParameteri (m_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
-    vgSetParameterfv (m_fillpaint, VG_PAINT_COLOR, 4, color);
+    vgSetParameteri (_fillpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+    vgSetParameterfv (_fillpaint, VG_PAINT_COLOR, 4, color);
     
     
     VGPath      vg_path;
@@ -1204,6 +1226,8 @@ Renderer_ovg::set_scale(float xscale, float yscale) {
 void
 Renderer_ovg::set_invalidated_regions(const InvalidatedRanges& /* ranges */)
 {
+    // do nothing obviously. This method is required by the base class though,
+    // something has to be here.
 }
   
 DSOEXPORT Renderer *
@@ -1464,55 +1488,6 @@ Renderer_ovg::printVGParams()
     log_debug("VG_MAX_IMAGE_PIXELS is %d", vgGeti(VG_MAX_IMAGE_PIXELS));
     log_debug("VG_MAX_IMAGE_BYTES is %d", vgGeti(VG_MAX_IMAGE_BYTES));
 }
-
-bool
-Renderer_ovg::initTestBuffer(unsigned int width, unsigned int height)
-{
-    GNASH_REPORT_FUNCTION;
-    int size = width * height * getBitsPerPixel(); // FIXME was Bytes not bits
-
-#if 0
-    // _testBuffer = static_cast<unsigned char *>(realloc(_testBuffer, size));
-    _testBuffer = new unsigned char[size];
-    memset(_testBuffer, 0, size);
-    printf("\tRenderer Test memory at: %p\n", _testBuffer);
-
-    attachWindow(0);
-#endif
-    
-    init_buffer(_testBuffer, size, width, height, width * getBitsPerPixel());
-//    init(width, height);
-    
-    return true;
-}
-
-  /// Initializes the rendering buffer. The memory pointed by "mem" is not
-  /// owned by the renderer and init_buffer() may be called multiple times
-  /// when the buffer size changes, for example. However, bits_per_pixel must
-  /// remain the same. 
-  /// rowstride is the size, in bytes, of one row.
-  /// This method *must* be called prior to any other method of the class!
-void
-Renderer_ovg::init_buffer(unsigned char *mem, int size, int x, int y, int 
rowstride)
-{
-    GNASH_REPORT_FUNCTION;
-#if 0
-    assert(x > 0);
-    assert(y > 0);
-    
-    xres    = x;
-    yres    = y;
-    
-    m_rbuf.attach(mem, xres, yres, rowstride);
-    
-    // allocate pixel format accessor and renderer_base
-    m_pixf.reset(new PixelFormat(m_rbuf));
-    m_rbase.reset(new renderer_base(*m_pixf));  
-    
-    // by default allow drawing everywhere
-    set_invalidated_region_world();
-#endif
-}
   
 Renderer *
 Renderer_ovg::startInternalRender(gnash::image::GnashImage&)
@@ -1546,111 +1521,6 @@ Renderer_ovg::getBitsPerPixel()
     return 0;
 }
 
-namespace {
-
-// TODO: this function is rubbish and shouldn't survive a rewritten OGL
-// renderer.
-rgba
-sampleGradient(const GradientFill& fill, boost::uint8_t ratio)
-{
-
-    // By specs, first gradient should *always* be 0, 
-    // anyway a malformed SWF could break this,
-    // so we cannot rely on that information...
-    if (ratio < fill.record(0).ratio) {
-        return fill.record(0).color;
-    }
-
-    if (ratio >= fill.record(fill.recordCount() - 1).ratio) {
-        return fill.record(fill.recordCount() - 1).color;
-    }
-        
-    for (size_t i = 1, n = fill.recordCount(); i < n; ++i) {
-
-        const GradientRecord& gr1 = fill.record(i);
-        if (gr1.ratio < ratio) continue;
-
-        const GradientRecord& gr0 = fill.record(i - 1);
-        if (gr0.ratio > ratio) continue;
-
-        float f = 0.0f;
-
-        if (gr0.ratio != gr1.ratio) {
-            f = (ratio - gr0.ratio) / float(gr1.ratio - gr0.ratio);
-        }
-        else {
-            // Ratios are equal IFF first and second GradientRecord
-            // have the same ratio. This would be a malformed SWF.
-            IF_VERBOSE_MALFORMED_SWF(
-                log_swferror(_("two gradients in a FillStyle "
-                    "have the same position/ratio: %d"),
-                    gr0.ratio);
-            );
-        }
-
-        rgba result;
-        result.set_lerp(gr0.color, gr1.color, f);
-        return result;
-    }
-
-    // Assuming gradients are ordered by ratio? see start comment
-    return fill.record(fill.recordCount() - 1).color;
-}
-
-const CachedBitmap*
-createGradientBitmap(const GradientFill& gf, Renderer_ovg *renderer)
-{
-    GNASH_REPORT_FUNCTION;
-    
-    std::auto_ptr<image::ImageRGBA> im;
-
-    switch (gf.type())
-    {
-        case GradientFill::LINEAR:
-            // Linear gradient.
-            im.reset(new image::ImageRGBA(256, 1));
-
-            for (size_t i = 0; i < im->width(); i++) {
-
-                rgba sample = sampleGradient(gf, i);
-                im->setPixel(i, 0, sample.m_r, sample.m_g,
-                        sample.m_b, sample.m_a);
-            }
-            break;
-
-        case GradientFill::RADIAL:
-            // Focal gradient.
-            im.reset(new image::ImageRGBA(64, 64));
-
-            for (size_t j = 0; j < im->height(); j++)
-            {
-                for (size_t i = 0; i < im->width(); i++)
-                {
-                    float radiusy = (im->height() - 1) / 2.0f;
-                    float radiusx = radiusy + std::abs(radiusy * 
gf.focalPoint());
-                    float y = (j - radiusy) / radiusy;
-                    float x = (i - radiusx) / radiusx;
-                    int ratio = std::floor(255.5f * std::sqrt(x*x + y*y));
-                    
-                    if (ratio > 255) ratio = 255;
-
-                    rgba sample = sampleGradient(gf, ratio);
-                    im->setPixel(i, j, sample.m_r, sample.m_g,
-                            sample.m_b, sample.m_a);
-                }
-            }
-            break;
-        default:
-            break;
-    }
-
-    const CachedBitmap* bi = renderer->createCachedBitmap(
-                    static_cast<std::auto_ptr<image::GnashImage> >(im));
-
-    return bi;
-}
-}
-
 } // namespace gnash::renderer::gles1
 } // namespace gnash::renderer
 } // namespace gnash

http://git.savannah.gnu.org/cgit//commit/?id=cd4c1e2ef473e64a722644b49ba1d4088d187166


commit cd4c1e2ef473e64a722644b49ba1d4088d187166
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 1 21:39:57 2011 -0700

    openvg/Renderer_ovg.h is now openvg/OpenVGRenderer.h

diff --git a/gui/fb/fb.cpp b/gui/fb/fb.cpp
index 48babc8..472e22a 100644
--- a/gui/fb/fb.cpp
+++ b/gui/fb/fb.cpp
@@ -117,7 +117,8 @@
 #endif
 
 #ifdef RENDERER_OPENVG
-# include "openvg/Renderer_ovg.h"
+# include "VG/openvg.h"
+# include "openvg/OpenVGRenderer.h"
 # include "fb_glue_ovg.h"
 #endif
 
@@ -136,8 +137,6 @@ namespace gnash {
 
 namespace gui {
 
-//---------------
-
 int terminate_request = false;  // global scope to avoid GUI access
 
 std::auto_ptr<Gui> createFBGui(unsigned long windowid, float scale,
@@ -302,7 +301,10 @@ FBGui::run()
 
         // FIXME: process the input data
         // boost::shared_ptr<input_event_t> popData();
-        
+
+        draw_hack(_glue.get());
+        //_glue->render();
+
         // advance movie  
         Gui::advance_movie(this);
 
@@ -318,7 +320,7 @@ FBGui::run()
 void
 FBGui::renderBuffer()
 {
-    // GNASH_REPORT_FUNCTION;
+    GNASH_REPORT_FUNCTION;
 
 //    if ( _drawbounds.size() == 0 ) return; // nothing to do..
 
@@ -349,7 +351,7 @@ FBGui::renderBuffer()
        
 #endif
 
-    // FIXME: should call swapBuffer()
+    _glue->render();
 }
 
 bool

http://git.savannah.gnu.org/cgit//commit/?id=0e936356b7997957906af8244ce256582b332534


commit 0e936356b7997957906af8244ce256582b332534
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 1 21:39:39 2011 -0700

    openvg/Renderer_ovg.h is now openvg/OpenVGRenderer.h

diff --git a/gui/fb/fb_glue_ovg.h b/gui/fb/fb_glue_ovg.h
index aa60f51..94ae24b 100644
--- a/gui/fb/fb_glue_ovg.h
+++ b/gui/fb/fb_glue_ovg.h
@@ -24,7 +24,7 @@
 #endif
 
 #include <boost/cstdint.hpp>
-#include "openvg/Renderer_ovg.h"
+#include "openvg/OpenVGRenderer.h"
 #include "fbsup.h"
 #include "fb_glue.h"
 

http://git.savannah.gnu.org/cgit//commit/?id=bbe2140e0ac171891733a2a539e0a49d3ad20fe1


commit bbe2140e0ac171891733a2a539e0a49d3ad20fe1
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 1 21:38:41 2011 -0700

    openvg/Renderer_ovg.h is now openvg/OpenVGRenderer.h

diff --git a/gui/gtk/gtk_glue_ovg.cpp b/gui/gtk/gtk_glue_ovg.cpp
index e2de310..9f1ec94 100644
--- a/gui/gtk/gtk_glue_ovg.cpp
+++ b/gui/gtk/gtk_glue_ovg.cpp
@@ -201,7 +201,12 @@ GtkOvgGlue::setRenderHandlerSize(int width, int height)
     _offscreenbuf = gdk_image_new (GDK_IMAGE_FASTEST, visual, width,
                                    height);
 #endif
-    
+
+#if 1
+    // if (_renderer) {
+    //     vgScale(width, height);
+    // }
+#else
     // Attach the window to the low level device
     long xid = GDK_WINDOW_XID(gtk_widget_get_window(_drawing_area));
     _device->attachWindow(static_cast<renderer::GnashDevice::native_window_t>
@@ -212,28 +217,11 @@ GtkOvgGlue::setRenderHandlerSize(int width, int height)
     // Allow drawing everywhere by default
     InvalidatedRanges ranges;
     ranges.setWorld();
-    _renderer->set_invalidated_regions(ranges);
-    
-    float red_color[4] = {1.0, 0.0, 0.0, 1.0};
-    float blue_color[4] = {0.0, 0.0, 1.0, 1.0};
-    
-    VGint scissor[4] = {100, 100, 25, 25};
-    vgSetfv(VG_CLEAR_COLOR, 4, red_color);
-    vgClear(0, 0, 300, 300);
-
-    vgSetfv(VG_CLEAR_COLOR, 4, blue_color);
-    vgClear(50, 50, 50, 50);
-
-    //vgSetiv(VG_SCISSOR_RECTS, 4, scissor);
-    //vgSeti(VG_SCISSORING, VG_TRUE);
-    vgCopyPixels(100, 100, 50, 50, 50, 50);
-    vgClear(150, 150, 50, 50);
-
+    _renderer->set_invalidated_regions(ranges);    
 
     renderer::EGLDevice *egl = (renderer::EGLDevice*)_device.get();
     egl->swapBuffers();
-    
-    sleep(5);
+#endif    
 }
 
 void 
diff --git a/gui/gtk/gtk_glue_ovg.h b/gui/gtk/gtk_glue_ovg.h
index 6e4c4f2..f8c1a1d 100644
--- a/gui/gtk/gtk_glue_ovg.h
+++ b/gui/gtk/gtk_glue_ovg.h
@@ -27,7 +27,7 @@
 #include <gdk/gdk.h>
 #include <boost/scoped_array.hpp>
 #include <boost/scoped_ptr.hpp>
-#include "openvg/Renderer_ovg.h"
+#include "openvg/OpenVGRenderer.h"
 
 #ifdef HAVE_VG_OPENVG_H
 #include <VG/openvg.h>

http://git.savannah.gnu.org/cgit//commit/?id=ac2716870f2f9ca2eb91c18ee75d76f1c5046d14


commit ac2716870f2f9ca2eb91c18ee75d76f1c5046d14
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 1 21:37:57 2011 -0700

    use nil not t for emacs

diff --git a/libbase/CachedBitmap.h b/libbase/CachedBitmap.h
index 76f5991..0cf6750 100644
--- a/libbase/CachedBitmap.h
+++ b/libbase/CachedBitmap.h
@@ -66,5 +66,5 @@ public:
 
 // Local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:

http://git.savannah.gnu.org/cgit//commit/?id=2150b590a75a169bc31271d25b233c729ec170df


commit 2150b590a75a169bc31271d25b233c729ec170df
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 1 21:37:23 2011 -0700

    minor editing tweaks

diff --git a/libcore/FillStyle.h b/libcore/FillStyle.h
index 927a3c7..f6c084c 100644
--- a/libcore/FillStyle.h
+++ b/libcore/FillStyle.h
@@ -39,19 +39,17 @@ namespace gnash {
 class GradientRecord
 {
 public:
-
     GradientRecord(boost::uint8_t ratio, const rgba& color)
         :
         ratio(ratio),
         color(color)
-    {}
+    { }
     
     //data:
     boost::uint8_t ratio;
     rgba color;
 };
 
-
 /// A BitmapFill
 //
 /// BitmapFills can refer to a parsed bitmap tag or be constructed from
@@ -245,13 +243,13 @@ public:
     explicit SolidFill(const rgba& c)
         :
         _color(c)
-    {}
+    { }
 
     /// Copy a SolidFill.
     SolidFill(const SolidFill& other)
         :
         _color(other._color)
-    {}
+    { }
 
     /// Set this fill to a lerp of two other SolidFills.
     void setLerp(const SolidFill& a, const SolidFill& b, double ratio) {
@@ -288,7 +286,7 @@ public:
     FillStyle(const FillStyle& other)
         :
         fill(other.fill)
-    {}
+    { }
 
     Fill fill;
 
@@ -305,10 +303,9 @@ DSOEXPORT std::ostream& operator<<(std::ostream& os,
 
 } // namespace gnash
 
-#endif 
-
+#endif
 
 // Local Variables:
 // mode: C++
-// indent-tabs-mode: t
+// indent-tabs-mode: nil
 // End:

-----------------------------------------------------------------------

Summary of changes:
 gui/fb/fb.cpp                       |   14 +-
 gui/fb/fb_glue_ovg.h                |    2 +-
 gui/gtk/gtk_glue_ovg.cpp            |   28 +---
 gui/gtk/gtk_glue_ovg.h              |    2 +-
 libbase/CachedBitmap.h              |    2 +-
 libcore/FillStyle.h                 |   15 +-
 librender/openvg/OpenVGBitmap.cpp   |  108 ++++++++++++--
 librender/openvg/OpenVGBitmap.h     |   28 +++-
 librender/openvg/OpenVGRenderer.cpp |  282 ++++++++++-------------------------
 librender/openvg/OpenVGRenderer.h   |   43 +++---
 librender/openvg/OpenVGStyle.h      |   10 +-
 librender/testr.cpp                 |    2 +-
 12 files changed, 238 insertions(+), 298 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]