1 /* === S I N F G =========================================================== */
2 /*! \file layer_solidcolor.cpp
3 ** \brief Template Header
5 ** $Id: layer_solidcolor.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "layer_solidcolor.h"
35 #include "paramdesc.h"
39 #include "valuenode.h"
43 /* === U S I N G =========================================================== */
47 using namespace sinfg;
49 /* === G L O B A L S ======================================================= */
51 SINFG_LAYER_INIT(Layer_SolidColor);
52 SINFG_LAYER_SET_NAME(Layer_SolidColor,"SolidColor");
53 SINFG_LAYER_SET_LOCAL_NAME(Layer_SolidColor,_("Solid Color"));
54 SINFG_LAYER_SET_CATEGORY(Layer_SolidColor,_("Geometry"));
55 SINFG_LAYER_SET_VERSION(Layer_SolidColor,"0.1");
56 SINFG_LAYER_SET_CVS_ID(Layer_SolidColor,"$Id: layer_solidcolor.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $");
58 /* === P R O C E D U R E S ================================================= */
60 /* === M E T H O D S ======================================================= */
62 /* === E N T R Y P O I N T ================================================= */
64 Layer_SolidColor::Layer_SolidColor():
65 Layer_Composite(1.0,Color::BLEND_STRAIGHT),
71 Layer_SolidColor::set_param(const String & param, const ValueBase &value)
75 return Layer_Composite::set_param(param,value);
79 Layer_SolidColor::get_param(const String ¶m)const
86 return Layer_Composite::get_param(param);
90 Layer_SolidColor::get_param_vocab()const
92 Layer::Vocab ret(Layer_Composite::get_param_vocab());
94 ret.push_back(ParamDesc("color")
95 .set_local_name(_("Color"))
102 Layer_SolidColor::hit_check(sinfg::Context context, const sinfg::Point &point)const
104 if(get_blend_method()==Color::BLEND_STRAIGHT && get_amount()>=0.5)
105 return const_cast<Layer_SolidColor*>(this);
107 if(get_blend_method()==Color::BLEND_COMPOSITE && get_amount()*color.get_a()>=0.5)
108 return const_cast<Layer_SolidColor*>(this);
110 Layer::Handle layer(context.hit_check(point));
112 return layer?layer:const_cast<Layer_SolidColor*>(this);
116 Layer_SolidColor::get_color(Context context, const Point &pos)const
118 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
121 return Color::blend(color,context.get_color(pos),get_amount(),get_blend_method());
125 Layer_SolidColor::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
127 if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
129 // Mark our progress as starting
130 if(cb && !cb->amount_complete(0,1000))
133 surface->set_wh(renddesc.get_w(),renddesc.get_h());
134 surface->fill(color);
136 // Mark our progress as finished
137 if(cb && !cb->amount_complete(1000,1000))
143 SuperCallback supercb(cb,0,9500,10000);
145 if(!context.accelerated_render(surface,quality,renddesc,&supercb))
150 Surface::alpha_pen apen(surface->begin());
152 apen.set_value(color);
153 apen.set_alpha(get_amount());
154 apen.set_blend_method(get_blend_method());
156 for(y=0;y<renddesc.get_h();y++,apen.inc_y(),apen.dec_x(x))
157 for(x=0;x<renddesc.get_w();x++,apen.inc_x())
160 // Mark our progress as finished
161 if(cb && !cb->amount_complete(10000,10000))