1 //
2 //   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3 //   Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 
19 #include <boost/intrusive_ptr.hpp>
20 
21 #include "ColorMatrixFilter_as.h"
22 
23 #include "as_object.h"
24 #include "VM.h"
25 #include "Global_as.h"
26 #include "BitmapFilter_as.h"
27 #include "Filters.h"
28 
29 namespace gnash {
30 
31 namespace {
32     as_value colormatrixfilter_new(const fn_call& fn);
33     as_value colormatrixfilter_matrix(const fn_call& fn);
34 
35     void attachColorMatrixFilterInterface(as_object& o);
36 }
37 
38 /// TODO: should this inherit from BitmapFilter_as (relay)? This might
39 /// make cloning easier, but needs some testing first.
40 class ColorMatrixFilter_as : public Relay, public ColorMatrixFilter
41 {
42 public:
ColorMatrixFilter_as()43     ColorMatrixFilter_as() {}
44 };
45 
46 /// The prototype of flash.filters.ColorMatrixFilter is a new BitmapFilter.
47 void
colormatrixfilter_class_init(as_object & where,const ObjectURI & uri)48 colormatrixfilter_class_init(as_object& where, const ObjectURI& uri)
49 {
50     registerBitmapClass(where, colormatrixfilter_new,
51             attachColorMatrixFilterInterface, uri);
52 }
53 
54 namespace {
55 
56 void
attachColorMatrixFilterInterface(as_object & o)57 attachColorMatrixFilterInterface(as_object& o)
58 {
59     const int flags = PropFlags::onlySWF8Up;
60     o.init_property("matrix", colormatrixfilter_matrix,
61         colormatrixfilter_matrix, flags);
62 }
63 
64 as_value
colormatrixfilter_matrix(const fn_call & fn)65 colormatrixfilter_matrix(const fn_call& fn)
66 {
67     ColorMatrixFilter_as* ptr = ensure<ThisIsNative<ColorMatrixFilter_as> >(fn);
68     UNUSED(ptr);
69     return as_value();
70 }
71 
72 as_value
colormatrixfilter_new(const fn_call & fn)73 colormatrixfilter_new(const fn_call& fn)
74 {
75     as_object* obj = ensure<ValidThis>(fn);
76     obj->setRelay(new ColorMatrixFilter_as);
77     return as_value();
78 }
79 
80 }
81 }
82 
83