CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/11/23 13:58:40
Modified files: . : ChangeLog Added files: server/swf : SetBackgroundColorTag.h Log message: Oops, forgot this CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4938&r2=1.4939 http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/SetBackgroundColorTag.h?cvsroot=gnash&rev=1.1 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4938 retrieving revision 1.4939 diff -u -b -r1.4938 -r1.4939 --- ChangeLog 23 Nov 2007 13:25:04 -0000 1.4938 +++ ChangeLog 23 Nov 2007 13:58:39 -0000 1.4939 @@ -1,6 +1,7 @@ 2007-11-23 Sandro Santilli <[EMAIL PROTECTED]> - * server/: Makefile.am, impl.cpp, swf/tag_loaders.{cpp,h}: + * server/: Makefile.am, impl.cpp, swf/tag_loaders.{cpp,h}, + swf/SetBackgroundColorTag.h: Extrapolated a SetBackgroundColorTag class out of tag_loaders.cpp into its own header file, cleaned up. Index: server/swf/SetBackgroundColorTag.h =================================================================== RCS file: server/swf/SetBackgroundColorTag.h diff -N server/swf/SetBackgroundColorTag.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ server/swf/SetBackgroundColorTag.h 23 Nov 2007 13:58:39 -0000 1.1 @@ -0,0 +1,129 @@ +// +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +// +// +// + +#ifndef GNASH_SWF_SETBACKGROUNDCOLOR_TAG_H +#define GNASH_SWF_SETBACKGROUNDCOLOR_TAG_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ControlTag.h" // for inheritance +#include "swf.h" // for tag_type definition +#include "action_buffer.h" // for composition +#include "sprite_instance.h" // for inlines (execute) +#include "movie_definition.h" // for inlines (loader) +#include "log.h" // for log_parse +#include "types.h" // for rgba class +#include "utility.h" // for frnd + +// Forward declarations +namespace gnash { + class stream; + class movie_definition; +} + +namespace gnash { +namespace SWF { + +/// SWF Tag SetBackgroundColor (9) +// +class SetBackgroundColorTag : public ControlTag +{ + +private: + + /// Actual color. So far only RGB values are used, + /// as alpha is not encoded in the tag itself + rgba m_color; + + /// Read SetBackgroundColorTag from the given stream + // + /// Tag header is assumed to have been read already + /// + /// Can throw ParserException on premature end of input stream + /// + void read(stream& in) + { + // may throw ParserException + m_color.read_rgb(&in); + + IF_VERBOSE_PARSE ( + log_parse(_(" SetBackgroundColor: %s"), m_color.toString().c_str()); + ); + } + + +public: + + /// \brief + /// Construct a SetBackgroundColorTag by reading it + /// from the given SWF stream. + // + /// Tag header is assumed to have been read already + /// + /// Can throw ParserException on premature end of input stream + /// + SetBackgroundColorTag(stream& in) + { + read(in); + } + + void execute(sprite_instance* m) const + { + float current_alpha = m->get_background_alpha(); + rgba newcolor = m_color; // to avoid making m_color mutable + newcolor.m_a = frnd(current_alpha * 255.0f); + m->set_background_color(newcolor); + } + + void execute_state(sprite_instance* m) const + { + execute(m); + } + + /// Set background color tag loader (SWF::SETBACKGROUNDCOLOR) + static void loader(stream* in, tag_type tag, movie_definition* m) + { + assert(tag == SWF::SETBACKGROUNDCOLOR); // 9 + assert(m); + assert(in); + + // this one may throw, we'll let caller catch it + SetBackgroundColorTag* t = new SetBackgroundColorTag(*in); + m->addControlTag(t); // takes ownership + } +}; + + + + +} // namespace gnash::SWF +} // namespace gnash + + +#endif // GNASH_SWF_SETBACKGROUNDCOLOR_TAG_H + + +// Local Variables: +// mode: C++ +// indent-tabs-mode: t +// End: _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit