1 // ColorTransform_as.h: ActionScript "ColorTransform" class, for Gnash. 2 // 3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 4 // Free Software Foundation, Inc 5 // 6 // This program is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation; either version 3 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 // 20 21 #ifndef GNASH_ASOBJ_COLORTRANSFORM_H 22 #define GNASH_ASOBJ_COLORTRANSFORM_H 23 24 #include "Relay.h" 25 26 namespace gnash { 27 class as_object; 28 struct ObjectURI; 29 } 30 31 namespace gnash { 32 33 // This is used directly by flash.geom.Transform, as it is 34 // much more efficient than a pseudo-ActionScript implementation. 35 class ColorTransform_as : public Relay 36 { 37 38 public: 39 40 ColorTransform_as(double rm, double gm, double bm, double am, 41 double ro, double go, double bo, double ao); 42 43 // Tests show that the ColorTransform 44 // object has its own properties on initialization, so they have 45 // getter-setters and are *not* simple properties. Storing and 46 // manipulating as doubles (they cannot be anything else - see ctor) is 47 // better for speed and memory than using as_value. setAlphaMultiplier(double am)48 void setAlphaMultiplier(double am) { _alphaMultiplier = am; } setRedMultiplier(double rm)49 void setRedMultiplier(double rm) { _redMultiplier = rm; } setBlueMultiplier(double bm)50 void setBlueMultiplier(double bm) { _blueMultiplier = bm; } setGreenMultiplier(double gm)51 void setGreenMultiplier(double gm) { _greenMultiplier = gm; } 52 setAlphaOffset(double ao)53 void setAlphaOffset(double ao) { _alphaOffset = ao; } setRedOffset(double ro)54 void setRedOffset(double ro) { _redOffset = ro; } setBlueOffset(double bo)55 void setBlueOffset(double bo) { _blueOffset = bo; } setGreenOffset(double go)56 void setGreenOffset(double go) { _greenOffset = go; } 57 getAlphaMultiplier()58 double getAlphaMultiplier() const { return _alphaMultiplier; } getRedMultiplier()59 double getRedMultiplier() const { return _redMultiplier; } getBlueMultiplier()60 double getBlueMultiplier() const { return _blueMultiplier; } getGreenMultiplier()61 double getGreenMultiplier() const { return _greenMultiplier; } 62 getAlphaOffset()63 double getAlphaOffset() const { return _alphaOffset; } getRedOffset()64 double getRedOffset() const { return _redOffset; } getBlueOffset()65 double getBlueOffset() const { return _blueOffset; } getGreenOffset()66 double getGreenOffset() const { return _greenOffset; } 67 68 void concat(const ColorTransform_as& other); 69 70 private: 71 72 double _alphaMultiplier; 73 double _alphaOffset; 74 double _blueMultiplier; 75 double _blueOffset; 76 double _greenMultiplier; 77 double _greenOffset; 78 double _redMultiplier; 79 double _redOffset; 80 81 }; 82 83 /// Initialize the global ColorTransform class 84 void colortransform_class_init(as_object& where, const ObjectURI& uri); 85 86 void registerColorTransformNative(as_object& global); 87 88 } // end of gnash namespace 89 90 #endif 91