Gnash  0.8.10
OpenVGBitmap.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc.
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00018 
00019 #ifndef GNASH_OPENVG_BITMAP_H
00020 #define GNASH_OPENVG_BITMAP_H
00021 
00022 #include "Geometry.h"
00023 #include "CachedBitmap.h"
00024 #include "GnashImage.h"
00025 #include "Renderer.h"
00026 #include "FillStyle.h"
00027 #include "openvg/OpenVGRenderer.h"
00028 
00029 namespace gnash {
00030 
00031 class SWFCxForm;
00032 
00033 namespace renderer {
00034 
00035 namespace openvg {
00036 
00039 class OpenVGBitmap : public CachedBitmap
00040 {
00041 public:
00043     enum bitmap_wrap_mode { WRAP_REPEAT, WRAP_FILL, WRAP_PAD, WRAP_REFLECT };
00044     
00045     OpenVGBitmap(VGPaint paint);
00046     OpenVGBitmap(CachedBitmap *bitmap, VGPaint vgpaint);
00047     OpenVGBitmap(image::GnashImage *im, VGPaint vgpaint);
00048     ~OpenVGBitmap();
00049 
00050     void dispose()  { _image.reset(); }
00051     bool disposed() const { return !_image.get(); }
00052 
00053     image::GnashImage& image() {
00054         assert(!disposed());
00055         return *_image;
00056     };
00057     VGPaint &vgimage() { return _vgimage; };
00058     
00059     // Accessors for the GnashImage internal data
00060     VGPaint getFillPaint() const { return _vgpaint; }
00061     int getWidth() { return _image->width(); }
00062     int getHeight() { return _image->height(); }
00063     boost::uint8_t *getData() const { return _image->begin(); }
00064 
00065     OpenVGBitmap *createRadialBitmap(float x0, float y0, float x1, float y1,
00066                                      float radial, const SWFCxForm& cx,
00067                                      const GradientFill::GradientRecords &records,
00068                                      VGPaint paint);
00069     OpenVGBitmap *createLinearBitmap(float x0, float y0, float x1, float y1,
00070                                      const SWFCxForm& cx,
00071                                      const GradientFill::GradientRecords &records,
00072                                      const VGPaint paint);
00073 
00074     OpenVGBitmap *applyPatternBitmap(const gnash::SWFMatrix& matrix,
00075                                      bitmap_wrap_mode mode,
00076                                      CachedBitmap *bitmap, VGPaint paint);
00077     
00078 private:
00079     boost::scoped_ptr<image::GnashImage> _image;
00080     VGImageFormat   _pixel_format;
00081     VGImage         _vgimage;
00082     VGPaint         _vgpaint;
00083     double          _aspect_ratio;
00084 };
00085 
00086 } // namespace gnash::renderer::openvg
00087 } // namespace gnash::renderer
00088 } // namespace gnash
00089 
00090 #endif // __RENDER_OPENVG_BITMAP_H__
00091 
00092 // local Variables:
00093 // mode: C++
00094 // indent-tabs-mode: nil
00095 // End: