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. 9896128cab365d44d08a


From: Rob Savoye
Subject: [Gnash-commit] [SCM] Gnash branch, openvg, updated. 9896128cab365d44d08a954a753b1d32ec7a3c77
Date: Sat, 05 Feb 2011 02:39:25 +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  9896128cab365d44d08a954a753b1d32ec7a3c77 (commit)
       via  9392ab75626a5361d95fa84325541a7ff0eb23eb (commit)
       via  a254163e87e09e5d0017d218562d4a57086cd2bd (commit)
       via  887054cb2026e4706a37df636a8cbe74dcd6d648 (commit)
       via  a4778ca2c3b1463cc45f92dbaa2026a18991b386 (commit)
      from  c0bc7552f2464c31781acd3a7d4c907c74089126 (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=9896128cab365d44d08a954a753b1d32ec7a3c77


commit 9896128cab365d44d08a954a753b1d32ec7a3c77
Author: Rob Savoye <address@hidden>
Date:   Tue Feb 1 08:21:07 2011 -0700

    add accesor to get the vector of Gradient Records.

diff --git a/libcore/FillStyle.h b/libcore/FillStyle.h
index f6c084c..c235553 100644
--- a/libcore/FillStyle.h
+++ b/libcore/FillStyle.h
@@ -157,7 +157,7 @@ public:
 
     /// The type of GradientFill
     //
-    /// A Focal fill is a gradient fill with a focal point.
+    /// A Radial fill is a gradient fill with a focal point.
     enum Type {
         LINEAR,
         RADIAL
@@ -196,6 +196,10 @@ public:
         _gradients = recs;
     }
 
+    const GradientRecords &getRecords() const {
+        return _gradients;
+    }
+
     /// Get the number of records in this GradientFill
     size_t recordCount() const {
         return _gradients.size();

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


commit 9392ab75626a5361d95fa84325541a7ff0eb23eb
Author: Rob Savoye <address@hidden>
Date:   Mon Jan 31 21:28:23 2011 -0700

    get the ramp data from gnash to do hardware accelerated gradient correctly

diff --git a/librender/openvg/OpenVGBitmap.cpp 
b/librender/openvg/OpenVGBitmap.cpp
index 51c478b..e06ea56 100644
--- a/librender/openvg/OpenVGBitmap.cpp
+++ b/librender/openvg/OpenVGBitmap.cpp
@@ -15,10 +15,13 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
+#include <boost/scoped_ptr.hpp>
+
 #include "Geometry.h"
 #include "CachedBitmap.h"
 #include "GnashImage.h"
 #include "Renderer.h"
+#include "FillStyle.h"
 #include "openvg/OpenVGRenderer.h"
 #include "openvg/OpenVGBitmap.h"
 #include "VG/openvg.h"
@@ -57,7 +60,7 @@ OpenVGBitmap::OpenVGBitmap(CachedBitmap *bitmap, VGPaint 
vgpaint)
 #endif
        _vgpaint(vgpaint)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
 
     // extract a reference to the image from the cached bitmap
     image::GnashImage &im = bitmap->image();
@@ -110,7 +113,7 @@ OpenVGBitmap::OpenVGBitmap(image::GnashImage *image, 
VGPaint vgpaint)
 #endif
     _vgpaint(vgpaint)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
 } 
 
 OpenVGBitmap::~OpenVGBitmap()
@@ -151,10 +154,20 @@ OpenVGBitmap::image()
 OpenVGBitmap *
 OpenVGBitmap::createRadialBitmap(float cx, float cy, float fx, float fy,
                                  float radial, const rgba &incolor,
+                                 const GradientFill::GradientRecords &records,
                                  VGPaint paint)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
 
+    VGfloat color[] = {
+        incolor.m_r / 255.0f,
+        incolor.m_g / 255.0f,
+        incolor.m_b / 255.0f,
+        incolor.m_a / 255.0f
+    };
+    vgSetParameteri (paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+    vgSetParameterfv (paint, VG_PAINT_COLOR, 4, color);
+    
     VGfloat rgParams[] = { cx, cy, fx, fy, radial };
     
     // Paint Type 
@@ -163,13 +176,24 @@ OpenVGBitmap::createRadialBitmap(float cx, float cy, 
float fx, float fy,
     // Gradient Parameters
     vgSetParameterfv(paint, VG_PAINT_RADIAL_GRADIENT, 5, rgParams);
 
-    VGfloat rampStop[] = {0.00f, 1.0f, 1.0f, 1.0f, 1.0f,
-                          0.33f, 1.0f, 0.0f, 0.0f, 1.0f,
-                          0.66f, 0.0f, 1.0f, 0.0f, 1.0f,
-                          1.00f, 0.0f, 0.0f,  1.0f, 1.0f};
-    vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, 20, rampStop);    
-
     // Color Ramp is the same as for linear gradient
+    size_t entries = records.size() * 5;
+    VGfloat ramps[entries];
+    int j = 0;
+    for (size_t i=0; i!= records.size(); ++i) {
+        // std::cerr << "The record is: " << records[i].ratio/255.0f;
+        rgba c = records[i].color;
+        // std::cerr << ", " << c.m_r/255.0f << ", " << c.m_g/255.0f << ", "
+        //           << c.m_b/255.0f << ", " << c.m_a/255.0f << std::endl;
+        // The set of 5 for each record is simply: { Offset, R, G, B, A }
+        ramps[j++] = records[i].ratio/255.0f;
+        ramps[j++] = c.m_r / 255.0f;
+        ramps[j++] = c.m_g / 255.0f;
+        ramps[j++] = c.m_b / 255.0f;
+        ramps[j++] = c.m_a / 255.0f;
+    }
+    vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, entries, ramps);
+
     return this;
 }
 
@@ -189,7 +213,9 @@ OpenVGBitmap::createRadialBitmap(float cx, float cy, float 
fx, float fy,
 /// clipped at the boundary instead of x1,y1.
 OpenVGBitmap *
 OpenVGBitmap::createLinearBitmap(float x0, float y0, float x1, float y1,
-                                 const rgba &incolor, const VGPaint paint)
+                                 const rgba &incolor,
+                                 const GradientFill::GradientRecords &records,
+                                 const VGPaint paint)
 {
     // GNASH_REPORT_FUNCTION;
     VGfloat color[] = {
@@ -205,20 +231,37 @@ OpenVGBitmap::createLinearBitmap(float x0, float y0, 
float x1, float y1,
     vgSetParameteri(paint, VG_PAINT_COLOR_RAMP_SPREAD_MODE,
                     VG_COLOR_RAMP_SPREAD_PAD);
 
-    //    VGfloat linearGradient[4] = { x0, y0, 10000, 10000 };
+    // This is the origin and size of the gradient
     VGfloat linearGradient[4] = { x0, y0, x1, y1 };
     vgSetParameterfv(paint, VG_PAINT_LINEAR_GRADIENT, 4, linearGradient);
 
-#if 0
-    VGfloat stops[] = { 0.0, 0.33, 0.66, 1.0};
-    vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, 4, stops);
-#else
-    VGfloat rampStop[] = {0.00f, 1.0f, 1.0f, 1.0f, 1.0f,
-                          0.33f, 1.0f, 0.0f, 0.0f, 1.0f,
-                          0.66f, 0.0f, 1.0f, 0.0f, 1.0f,
-                          1.00f, 0.0f, 0.0f,  1.0f, 1.0f};
-    vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, 20, rampStop);    
-#endif
+    // The application defines the non-premultiplied sRGBA color and alpha 
value
+    // associated with each of a number of values, called stops.
+    // A stop is defined by an offset between 0 and 1, inclusive, and a color 
value.
+    
+    // an array of floating-point values giving the offsets and colors
+    // of the stops. Each stop is defined by a floating-point offset
+    // value and four floating-point values containing the sRGBA color
+    // and alpha value associated with each stop, in the form of a
+    // non-premultiplied (R, G, B, α) quad. The vgSetParameter
+    // function will generate an error if the number of values
+    // submitted is not a multiple of 5 (zero is acceptable)
+    size_t entries = records.size() * 5;
+    VGfloat ramps[entries];
+    int j = 0;
+    for (size_t i=0; i!= records.size(); ++i) {
+        std::cerr << "The record is: " << records[i].ratio/255.0f;
+        rgba c = records[i].color;
+        std::cerr << ", " << c.m_r/255.0f << ", " << c.m_g/255.0f << ", "
+                  << c.m_b/255.0f << ", " << c.m_a/255.0f << std::endl;
+        // The set of 5 for each record is simply: { Offset, R, G, B, A }
+        ramps[j++] = records[i].ratio/255.0f;
+        ramps[j++] = c.m_r / 255.0f;
+        ramps[j++] = c.m_g / 255.0f;
+        ramps[j++] = c.m_b / 255.0f;
+        ramps[j++] = c.m_a / 255.0f;
+    }
+    vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, entries, ramps);
     
     return this;
 }
@@ -251,9 +294,11 @@ OpenVGBitmap::applyPatternBitmap(const gnash::SWFMatrix& 
matrix,
     // Paint the cached VG image into the VG paint surface
     mat = matrix;
     mat.invert();
-//    Renderer_ovg::printVGMatrix(mat);
+    Renderer_ovg::printVGMatrix(matrix);
+    Renderer_ovg::printVGMatrix(mat);
     
     memset(vmat, 0, sizeof(vmat));
+    // Convert from fixed point to floating point
     vmat[0] = mat.sx  / 65536.0f;
     vmat[1] = mat.shx / 65536.0f;
     vmat[3] = mat.shy / 65536.0f;
diff --git a/librender/openvg/OpenVGBitmap.h b/librender/openvg/OpenVGBitmap.h
index d0eeabb..24a9d7a 100644
--- a/librender/openvg/OpenVGBitmap.h
+++ b/librender/openvg/OpenVGBitmap.h
@@ -22,6 +22,7 @@
 #include "CachedBitmap.h"
 #include "GnashImage.h"
 #include "Renderer.h"
+#include "FillStyle.h"
 #include "openvg/OpenVGRenderer.h"
 
 namespace gnash {
@@ -55,21 +56,14 @@ public:
     int getHeight() { return _image->height(); }
     boost::uint8_t *getData() const { return _image->begin(); }
 
-    /// 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.
-    ///
-    /// @param x0 The X coordinate of the origin point
-    /// @param y0 The Y coordinate of the origin point
-    /// @param x1 The X coordinate of the opposite corner point
-    /// @param y1 The Y coordinate of the opposite corner point
-    /// @param incolor The base color of the gradient
-    /// @param paint The VG paint surface
-    OpenVGBitmap *createRadialBitmap(float x0, float y0, float x1,
-                                     float y1, float radial,
-                                     const rgba &incolor, VGPaint paint);
+    OpenVGBitmap *createRadialBitmap(float x0, float y0, float x1, float y1,
+                                     float radial, const rgba &incolor,
+                                     const GradientFill::GradientRecords 
&records,
+                                     VGPaint paint);
     OpenVGBitmap *createLinearBitmap(float x0, float y0, float x1, float y1,
-                                     const rgba &incolor, const VGPaint paint);
+                                     const rgba &incolor,
+                                     const GradientFill::GradientRecords 
&records,
+                                     const VGPaint paint);
 
     OpenVGBitmap *applyPatternBitmap(const gnash::SWFMatrix& matrix,
                                       bitmap_wrap_mode mode, VGPaint paint);
diff --git a/librender/openvg/OpenVGRenderer.cpp 
b/librender/openvg/OpenVGRenderer.cpp
index 84d9220..e76c4b1 100644
--- a/librender/openvg/OpenVGRenderer.cpp
+++ b/librender/openvg/OpenVGRenderer.cpp
@@ -87,9 +87,9 @@ class eglScopeMatrix : public boost::noncopyable
 public:
     eglScopeMatrix(const SWFMatrix& m)
         {
-            // GNASH_REPORT_FUNCTION;            
+            GNASH_REPORT_FUNCTION;            
             vgGetMatrix(_orig_mat);
-            //Renderer_ovg::printVGMatrix(_orig_mat);
+            Renderer_ovg::printVGMatrix(_orig_mat);
             
             float mat[9];
             memset(mat, 0, sizeof(mat));
@@ -99,6 +99,7 @@ public:
             mat[4] = m.sy  / 65536.0f;
             mat[6] = m.tx;
             mat[7] = m.ty;
+            Renderer_ovg::printVGMatrix(mat);
             vgMultMatrix(mat);
         }
   
@@ -297,17 +298,16 @@ Renderer_ovg::~Renderer_ovg()
 
 // 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. This unfortunately doesn't support
-// hardware acceleration libraries like OpenVG, which have their
-// own image type, which is what should be cached to avoid
-// recalculating it.
+// bitmap fill style. We only cache the GnashImage here, as a
+// VGImage can't be created yet until the renderer is initialized.
 CachedBitmap *
 Renderer_ovg::createCachedBitmap(std::auto_ptr<image::GnashImage> im)
 {
     // GNASH_REPORT_FUNCTION;
 
-    image::GnashImage *image = im.release();
-    return reinterpret_cast<CachedBitmap *>(new OpenVGBitmap(image, 
_fillpaint));
+    CachedBitmap *cbinfo = reinterpret_cast<CachedBitmap *>(new 
OpenVGBitmap(im.release(),
+                                                                             
_fillpaint));
+    return cbinfo;
 }
 
 // Since we store drawing operations in display lists, we take special care
@@ -829,7 +829,6 @@ Renderer_ovg::apply_fill_style(const FillStyle& style, 
const SWFMatrix& mat,
     SWF::FillType fill_type = boost::apply_visitor(GetType(), style.fill);
     SWFMatrix sm = boost::apply_visitor(GetMatrix(), style.fill);
     rgba incolor = boost::apply_visitor(GetColor(), style.fill);
-    
     switch (fill_type) {
         
       case SWF::FILL_LINEAR_GRADIENT:
@@ -840,10 +839,10 @@ Renderer_ovg::apply_fill_style(const FillStyle& style, 
const SWFMatrix& mat,
           log_error("Fill Style Type: Gradient, you shouldn't be here!");
           break;
       }
-      // FIXME: Bitmap cacheing needs to be improved. Currently the GnahInage
+      // FIXME: Bitmap cacheing needs to be improved. Currently the GnashInage
       // is cached, but the VG image is not. This forces the VG Image to be
       // recalculated all the time from the GnashImage. Ideally the VG Image
-      // should be cached instead.
+      // should be cached instead by the Renderer.
       case SWF::FILL_TILED_BITMAP_HARD:
       case SWF::FILL_TILED_BITMAP:
       {
@@ -860,17 +859,12 @@ Renderer_ovg::apply_fill_style(const FillStyle& style, 
const SWFMatrix& mat,
       case SWF::FILL_CLIPPED_BITMAP_HARD:
       {     
           log_debug("Fill Style Type: Clipped Bitmap");
-          CachedBitmap *cb = boost::apply_visitor(GetBitmap(), style.fill);
+          CachedBitmap *cb = boost::apply_visitor(GetBitmap(), style.fill);    
      
           // Convert the GnashImage to a VG Image
-#if 1
           OpenVGBitmap *binfo = new OpenVGBitmap(cb, _fillpaint);
           // Apply the transformation and paint
+          // sm.sx = 2450; // FIXME: debug hack
           binfo->applyPatternBitmap(sm, OpenVGBitmap::WRAP_FILL, _fillpaint);
-#else
-          OpenVGBitmap *binfo = reinterpret_cast<OpenVGBitmap *>(cb);
-          // Apply the transformation and paint
-          binfo->applyPatternBitmap(sm, OpenVGBitmap::WRAP_FILL, _fillpaint);
-#endif
           break;
       } 
       case SWF::FILL_SOLID:
@@ -1175,21 +1169,29 @@ Renderer_ovg::draw_subshape(const PathVec& path_vec,
                 // pixel. Use th display size for the extent of the shape, 
                 // as it'll get clipped by OpenVG at the end of the
                 // shape that is being filled with the gradient.
+                const std::vector<gnash::GradientRecord> &records =
+                    boost::apply_visitor(GetGradientRecords(), 
fill_styles[i].fill);
+                // log_debug("Fill Style Type: Linear Gradient, %d records", 
records.size());
                 binfo->createLinearBitmap((*(refs[0])).ap.x, (*(refs[0])).ap.y,
-                                          _display_width * 20.0f, 
_display_height * 20.0f,
-                                          incolor, _fillpaint);
+                                          _display_width * 20.0f, 
(_display_height * 20.0f)/2,
+                                          incolor, records, _fillpaint);
             }
             if (fill_type == SWF::FILL_RADIAL_GRADIENT) {
                 rgba incolor = boost::apply_visitor(GetColor(), 
fill_styles[i].fill);
+                double focalpt = boost::apply_visitor(GetFocalPoint(), 
fill_styles[i].fill);
+                const std::vector<gnash::GradientRecord> &records =
+                    boost::apply_visitor(GetGradientRecords(), 
fill_styles[i].fill);
+                // log_debug("Fill Style Type: Radial Gradient: focal is: %d, 
%d records",
+                //           focalpt, records.size());
                 OpenVGBitmap* binfo = new OpenVGBitmap(_fillpaint);
                 // All positions are specified in twips, which are 20 to the
-                // pixel. Use th display size for the extent of the shape, 
+                // pixel. Use the display size for the extent of the shape, 
                 // as it'll get clipped by OpenVG at the end of the
                 // shape that is being filled with the gradient.
                 binfo->createRadialBitmap((*(refs[0])).ap.x, (*(refs[0])).ap.y,
-                                          _display_width * 20.0f,
-                                          _display_height * 20.0f, 500,
-                                          incolor, _fillpaint);
+                                          (*(refs[0])).ap.x * 3,
+                                          (*(refs[0])).ap.y * 3, focalpt,
+                                          incolor, records, _fillpaint);
             }
             for (PathPtrVec::const_iterator it = refs.begin(), end = 
refs.end();
                  it != end; ++it) {
diff --git a/librender/openvg/OpenVGRenderer.h 
b/librender/openvg/OpenVGRenderer.h
index d1b91a4..e7c8a0c 100644
--- a/librender/openvg/OpenVGRenderer.h
+++ b/librender/openvg/OpenVGRenderer.h
@@ -125,6 +125,8 @@ public:
     static void printVGMatrix(const SWFMatrix &mat);
 
     static const char *getErrorString(VGErrorCode error);
+
+    // VGImage (CachedBitmap *x) { return _image_cache[x]; };
 #if 0
     // These are all required by the Render class
     void draw_poly(const point* corners, size_t corner_count,
@@ -193,13 +195,15 @@ public:
 #ifdef OPENVG_VERSION_1_1
     VGMaskLayer _mask;
 #endif
+    // FIXME: A cache for the VGImages might make some sense assuming it takes 
more time
+    // to render the cached GnashImage to a VGImage. Right now every ti;l a 
fill style is
+    // applied, the VGImage is rebuilt from the GnashImage. This appears to be 
relatively
+    // fast, and possibly faster than the lookup in a map as the size of the 
cache grows.
+    // The other issue would be when to clear the cache, as we have no 
knowledge from the VM
+    // when images are deleted, or unused.
+//    std::map<CachedBitmap *, VGImage > _image_cache;
 };
 
-namespace {
-    const CachedBitmap* createGradientBitmap(const GradientFill& gf,
-                                  renderer::openvg::Renderer_ovg *renderer);
-}
-
 DSOEXPORT Renderer* create_handler(const char *pixelformat);
 
 } // namespace gnash::renderer::openvg
diff --git a/librender/openvg/OpenVGStyle.h b/librender/openvg/OpenVGStyle.h
index c9fe171..2f662cb 100644
--- a/librender/openvg/OpenVGStyle.h
+++ b/librender/openvg/OpenVGStyle.h
@@ -143,6 +143,37 @@ public:
     }
 };
 
+/// GradientFills have more data we need to construct the gradient.
+
+/// Return the focal point of a radial gradient
+class GetFocalPoint : public boost::static_visitor<double>
+{
+public:
+    double operator()(const SolidFill&) const {
+        return 0.0f;
+    }
+    double operator()(const GradientFill& g) const {
+        return g.focalPoint();
+    }
+    double operator()(const BitmapFill&) const {
+        return 0.0f;
+    }
+};
+
+/// Return the records in the gradient
+class GetGradientRecords : public boost::static_visitor<const 
GradientFill::GradientRecords &>
+{
+public:
+    const GradientFill::GradientRecords &operator()(const SolidFill&) const {
+    }
+    const GradientFill::GradientRecords &operator()(const GradientFill& fs) 
const {
+        return fs.getRecords();
+    }
+    const GradientFill::GradientRecords &operator()(const BitmapFill&) const {
+    }
+};
+
+
 } // namespace gnash::renderer::openvg
 } // namespace gnash::renderer
 } // namespace gnash

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


commit a254163e87e09e5d0017d218562d4a57086cd2bd
Author: Rob Savoye <address@hidden>
Date:   Mon Jan 31 21:27:03 2011 -0700

    fix comment

diff --git a/librender/cairo/Renderer_cairo.cpp 
b/librender/cairo/Renderer_cairo.cpp
index 9dfbe8a..9a19dae 100644
--- a/librender/cairo/Renderer_cairo.cpp
+++ b/librender/cairo/Renderer_cairo.cpp
@@ -220,7 +220,7 @@ class bitmap_info_cairo : public CachedBitmap, 
boost::noncopyable
 
 /// Style handler
 //
-/// Transfer FillStyles to agg styles.
+/// Transfer FillStyles to cairo styles.
 struct StyleHandler : boost::static_visitor<cairo_pattern_t*>
 {
     StyleHandler(const SWFCxForm& c)

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


commit 887054cb2026e4706a37df636a8cbe74dcd6d648
Author: Rob Savoye <address@hidden>
Date:   Mon Jan 31 21:26:36 2011 -0700

    improve formatting

diff --git a/librender/agg/Renderer_agg_style.h 
b/librender/agg/Renderer_agg_style.h
index 0f7f471..fbdef28 100644
--- a/librender/agg/Renderer_agg_style.h
+++ b/librender/agg/Renderer_agg_style.h
@@ -252,7 +252,9 @@ public:
         for (size_t i = 0; i != size; ++i) { 
             const GradientRecord& gr = fs.record(i); 
             const rgba tr = m_cx.transform(gr.color);
-            if (tr.m_a < 255) m_need_premultiply = true;    
+            if (tr.m_a < 255) {
+              m_need_premultiply = true;
+            }
             m_gradient_lut.add_color(gr.ratio/255.0,
                     agg::rgba8(tr.m_r, tr.m_g, tr.m_b, tr.m_a));
         } 

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


commit a4778ca2c3b1463cc45f92dbaa2026a18991b386
Author: Rob Savoye <address@hidden>
Date:   Sat Jan 29 17:12:27 2011 -0700

    add doxygen comments

diff --git a/librender/openvg/OpenVGBitmap.cpp 
b/librender/openvg/OpenVGBitmap.cpp
index d214299..51c478b 100644
--- a/librender/openvg/OpenVGBitmap.cpp
+++ b/librender/openvg/OpenVGBitmap.cpp
@@ -31,6 +31,7 @@ namespace openvg {
 
 static const int NUM_STOPS = 10;
 
+/// @param vgpaint the VG paint context
 OpenVGBitmap::OpenVGBitmap(VGPaint paint)
     : _vgimage(VG_INVALID_HANDLE),
 #ifdef BUILD_X11_DEVICE
@@ -43,6 +44,10 @@ OpenVGBitmap::OpenVGBitmap(VGPaint paint)
     // GNASH_REPORT_FUNCTION;
 }
 
+/// Construct a new bitmap
+///
+/// @param bitmap A CachedBitmap
+/// @param vgpaint the VG paint context
 OpenVGBitmap::OpenVGBitmap(CachedBitmap *bitmap, VGPaint vgpaint)
     : _vgimage(VG_INVALID_HANDLE),
 #ifdef BUILD_X11_DEVICE
@@ -57,7 +62,7 @@ OpenVGBitmap::OpenVGBitmap(CachedBitmap *bitmap, VGPaint 
vgpaint)
     // extract a reference to the image from the cached bitmap
     image::GnashImage &im = bitmap->image();
 
-    // Store the reference so so it's available to createPatternBitmap()
+    // Store the reference so it's available to applyPatternBitmap()
     _image.reset(&im);
 
     // Create a VG image
@@ -70,14 +75,14 @@ OpenVGBitmap::OpenVGBitmap(CachedBitmap *bitmap, VGPaint 
vgpaint)
     
     switch (im.type()) {
     case image::TYPE_RGB:
-        log_debug("Image has RGB Pixel Format, Stride is %d",
-                  im.stride());
-        vgImageSubData(_vgimage, im.begin(), im.stride(), VG_sRGBA_8888,
+        log_debug("Image has RGB Pixel Format, Stride is %d, width is %d, 
height is %d",
+                  im.stride(), im.width(), im.height());
+        vgImageSubData(_vgimage, im.begin(), im.stride(), VG_sRGBX_8888,
                    0, 0, im.width(), im.height());
         break;
     case image::TYPE_RGBA:
-        log_debug("Image has RGBA Pixel Format, Stride is %d",
-                  im.stride());
+        log_debug("Image has RGBA Pixel Format, Stride is %d, width is %d, 
height is %d",
+                  im.stride(), im.width(), im.height());
         // Copy the image data into the VG image container
         vgImageSubData(_vgimage, im.begin(), im.stride(), VG_sRGBA_8888,
                    0, 0, im.width(), im.height());
@@ -87,7 +92,14 @@ OpenVGBitmap::OpenVGBitmap(CachedBitmap *bitmap, VGPaint 
vgpaint)
     }
 }
 
-// FIXME: this caches the GnashImage, but we should really cache the VG Image.
+/// Construct a new bitmap
+///
+/// @param A pointer to a GnashImage
+/// @param vgpaint the VG paint context
+
+/// @note This is usually only called by createCachedBitmap() when a bitmap
+/// is loaded from a swf file. As the renderer isn't initialized yet,
+/// only the GnashImage is cached.
 OpenVGBitmap::OpenVGBitmap(image::GnashImage *image, VGPaint vgpaint)
     : _image(image),
       _vgimage(VG_INVALID_HANDLE),
@@ -99,31 +111,6 @@ OpenVGBitmap::OpenVGBitmap(image::GnashImage *image, 
VGPaint vgpaint)
     _vgpaint(vgpaint)
 {
     GNASH_REPORT_FUNCTION;
-    // Create a VG image
-    _vgimage = vgCreateImage(_pixel_format, image->width(), image->height(),
-                             VG_IMAGE_QUALITY_FASTER);    
-    if (_vgimage == VG_INVALID_HANDLE) {
-        log_error("Failed to create VG image! %s",
-                  Renderer_ovg::getErrorString(vgGetError()));
-    }
-    
-    switch (image->type()) {
-    case image::TYPE_RGB:
-        log_debug("Image has RGB Pixel Format, Stride is %d",
-                  image->stride());
-        vgImageSubData(_vgimage, image->begin(), image->stride(), 
VG_sRGBA_8888,
-                   0, 0, image->width(), image->height());
-        break;
-    case image::TYPE_RGBA:
-        log_debug("Image has RGBA Pixel Format, Stride is %d",
-                  image->stride());
-        // Copy the image data into the VG image container
-        vgImageSubData(_vgimage, image->begin(), image->stride(), 
VG_sRGBA_8888,
-                   0, 0, image->width(), image->height());
-        break;
-    default:
-        std::abort();
-    }
 } 
 
 OpenVGBitmap::~OpenVGBitmap()
@@ -138,12 +125,22 @@ image::GnashImage&
 OpenVGBitmap::image()
 {
     // GNASH_REPORT_FUNCTION;
-
     if (_image) {
         return *_image;
     }
 }    
 
+/// Create a radial gradient and paint it to the context
+///
+/// @param x0 The X coordinate of the origin point
+/// @param y0 The Y coordinate of the origin point
+/// @param x1 The X coordinate of the opposite corner point
+/// @param y1 The Y coordinate of the opposite corner point
+/// @param incolor The base color of the gradient
+/// @param paint The VG paint context
+/// @return A pointer to the new Bitmap
+
+/// @note
 /// 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.
@@ -176,10 +173,20 @@ OpenVGBitmap::createRadialBitmap(float cx, float cy, 
float fx, float fy,
     return this;
 }
 
-// A Linear Gradient Bitmap uses two points, x0,y0 and x1,y1 in the paint
-// coordinate system. The gradient starts at x0,y0 and goes to x1,y1. If
-// x1 and y1 are outside the boundaries of the shape, then the gradient gets
-// clipped at the boundary instead of x1,y1.
+/// Create a linear gradient and paint it to the context
+///
+/// @param x0 The X coordinate of the origin point
+/// @param y0 The Y coordinate of the origin point
+/// @param x1 The X coordinate of the opposite corner point
+/// @param y1 The Y coordinate of the opposite corner point
+/// @param incolor The base color of the gradient
+/// @param paint The VG paint context
+/// @return A pointer to the new Bitmap
+///
+/// @note A Linear Gradient Bitmap uses two points, x0,y0 and x1,y1 in the 
paint
+/// coordinate system. The gradient starts at x0,y0 and goes to x1,y1. If
+/// x1 and y1 are outside the boundaries of the shape, then the gradient gets
+/// clipped at the boundary instead of x1,y1.
 OpenVGBitmap *
 OpenVGBitmap::createLinearBitmap(float x0, float y0, float x1, float y1,
                                  const rgba &incolor, const VGPaint paint)
@@ -216,12 +223,17 @@ OpenVGBitmap::createLinearBitmap(float x0, float y0, 
float x1, float y1,
     return this;
 }
 
-// Create and fill pattern image
+/// Create and fill pattern image
+///
+/// @param matrix The transformation matrix
+/// @param mode The mode used to pain the image
+/// @param paint The VG paint context
+/// @return A pointer to the new Bitmap
 OpenVGBitmap *
 OpenVGBitmap::applyPatternBitmap(const gnash::SWFMatrix& matrix,
                                  bitmap_wrap_mode mode, VGPaint paint)
 {
-    GNASH_REPORT_FUNCTION;
+    // GNASH_REPORT_FUNCTION;
 
     if (_vgimage == VG_INVALID_HANDLE) {
         log_error("No VG image to paint! %s",

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

Summary of changes:
 libcore/FillStyle.h                 |    6 +-
 librender/agg/Renderer_agg_style.h  |    4 +-
 librender/cairo/Renderer_cairo.cpp  |    2 +-
 librender/openvg/OpenVGBitmap.cpp   |  179 +++++++++++++++++++++++------------
 librender/openvg/OpenVGBitmap.h     |   22 ++---
 librender/openvg/OpenVGRenderer.cpp |   50 +++++-----
 librender/openvg/OpenVGRenderer.h   |   14 ++-
 librender/openvg/OpenVGStyle.h      |   31 ++++++
 8 files changed, 201 insertions(+), 107 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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