1 /* === S I N F G =========================================================== */
2 /*! \file layer_composite.cpp
3 ** \brief Template File
5 ** $Id: layer_composite.cpp,v 1.2 2005/01/24 03:08:18 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_composite.h"
39 #include "layer_bitmap.h"
43 #include "paramdesc.h"
47 /* === U S I N G =========================================================== */
51 using namespace sinfg;
53 /* === M A C R O S ========================================================= */
55 /* === G L O B A L S ======================================================= */
57 /* === P R O C E D U R E S ================================================= */
59 /* === M E T H O D S ======================================================= */
62 Layer_Composite::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc_, ProgressCallback *cb) const
64 RendDesc renddesc(renddesc_);
67 return context.accelerated_render(surface,quality,renddesc,cb);
71 SuperCallback stageone(cb,0,50000,100000);
72 SuperCallback stagetwo(cb,50000,100000,100000);
74 Layer_Bitmap::Handle surfacelayer(new class Layer_Bitmap());
78 for(iter=context;*iter;iter++)
79 image.push_back(*iter);
81 image.push_front(surfacelayer.get());
83 // We want to go ahead and schedule any other
85 // while(dynamic_cast<Layer_Composite*>(context->get()))
86 // while(context->get() &&
87 // &context->get()->AcceleratedRender==
88 // &Layer_Composite::AcceleratedRender)
89 // image.push_back(*(context++));
91 image.push_back(0); // Alpha black
93 // Render the backdrop
94 if(!context.accelerated_render(&surfacelayer->surface,quality,renddesc,&stageone))
97 if(quality<=4)surfacelayer->c=3;else
98 if(quality<=5)surfacelayer->c=2;
99 else if(quality<=6)surfacelayer->c=1;
100 else surfacelayer->c=0;
101 surfacelayer->tl=renddesc.get_tl();
102 surfacelayer->br=renddesc.get_br();
103 surfacelayer->set_blend_method(Color::BLEND_STRAIGHT);
105 image.push_front(const_cast<sinfg::Layer_Composite*>(this));
107 // Set up a surface target
108 Target::Handle target(surface_target(surface));
112 if(cb)cb->error(_("Unable to create surface target"));
116 RendDesc desc(renddesc);
118 target->set_rend_desc(&desc);
121 return render(Context(image.begin()),target,desc,&stagetwo);
122 //return render_threaded(Context(image.begin()),target,desc,&stagetwo,2);
126 Layer_Composite::get_full_bounding_rect(Context context)const
128 if(is_disabled() || Color::is_onto(get_blend_method()))
129 return context.get_full_bounding_rect();
131 return context.get_full_bounding_rect()|get_bounding_rect();
135 Layer_Composite::get_param_vocab()const
137 Layer::Vocab ret(Layer::get_param_vocab());
139 ret.push_back(ParamDesc(amount_,"amount")
140 .set_local_name(_("Amount"))
142 ret.push_back(ParamDesc(blend_method_,"blend_method")
143 .set_local_name(_("Blend Method"))
150 Layer_Composite::set_param(const String & param, const ValueBase &value)
152 if(param=="amount" && value.same_as(amount_))
153 amount_=value.get(amount_);
155 if(param=="blend_method" && value.same_as(int()))
156 blend_method_=static_cast<Color::BlendMethod>(value.get(int()));
158 return Layer::set_param(param,value);
163 Layer_Composite::get_param(const String & param)const
167 if(param=="blend_method")
168 return static_cast<int>(get_blend_method());
169 return Layer::get_param(param);