本文整理汇总了C++中RendDesc类的典型用法代码示例。如果您正苦于以下问题:C++ RendDesc类的具体用法?C++ RendDesc怎么用?C++ RendDesc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RendDesc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
synfig::Target_Tile::call_renderer(Context &context, const etl::handle<rendering::SurfaceSW> &surfacesw, int quality, const RendDesc &renddesc, ProgressCallback *cb)
{
surfacesw->set_size(renddesc.get_w(), renddesc.get_h());
if (get_engine().empty())
{
if(!context.accelerated_render(&surfacesw->get_surface(),quality,renddesc,0))
{
// For some reason, the accelerated renderer failed.
if(cb)cb->error(_("Accelerated Renderer Failure"));
return false;
}
}
else
{
rendering::Task::Handle task = context.build_rendering_task();
if (task)
{
rendering::Renderer::Handle renderer = rendering::Renderer::get_renderer(get_engine());
if (!renderer)
throw "Renderer '" + get_engine() + "' not found";
task->target_surface = surfacesw;
task->target_surface->create();
task->init_target_rect(RectInt(VectorInt::zero(), surfacesw->get_size()), renddesc.get_tl(), renddesc.get_br());
rendering::Task::List list;
list.push_back(task);
renderer->run(list);
}
}
return true;
}
示例2: supercb
bool
Metaballs::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__)
Gradient gradient=param_gradient.get(Gradient());
// Width and Height of a pixel
const Point /*br(renddesc.get_br()),*/ tl(renddesc.get_tl());
const int w(renddesc.get_w()), h(renddesc.get_h());
const Real pw(renddesc.get_pw()), ph(renddesc.get_ph());
SuperCallback supercb(cb,0,9000,10000);
Point pos(tl[0],tl[1]);
if(!context.accelerated_render(surface,quality,renddesc,&supercb))
{
if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__));
return false;
}
for(int y = 0; y < h; y++, pos[1] += ph)
{
pos[0] = tl[0];
for(int x = 0; x < w; x++, pos[0] += pw)
(*surface)[y][x] = Color::blend(gradient(totaldensity(pos)),(*surface)[y][x],get_amount(),get_blend_method());
}
// Mark our progress as finished
if(cb && !cb->amount_complete(10000,10000))
return false;
return true;
}
示例3: supercb
bool
Halftone2::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__)
SuperCallback supercb(cb,0,9500,10000);
if(!context.accelerated_render(surface,quality,renddesc,&supercb))
return false;
if(get_amount()==0)
return true;
const Real pw(renddesc.get_pw()),ph(renddesc.get_ph());
const Point tl(renddesc.get_tl());
const int w(surface->get_w());
const int h(surface->get_h());
const float supersample_size(abs(pw/(halftone.param_size.get(Vector())).mag()));
Surface::pen pen(surface->begin());
Point pos;
int x,y;
if(is_solid_color())
{
for(y=0,pos[1]=tl[1];y<h;y++,pen.inc_y(),pen.dec_x(x),pos[1]+=ph)
for(x=0,pos[0]=tl[0];x<w;x++,pen.inc_x(),pos[0]+=pw)
pen.put_value(
color_func(
pos,
supersample_size,
pen.get_value()
)
);
}
else
{
for(y=0,pos[1]=tl[1];y<h;y++,pen.inc_y(),pen.dec_x(x),pos[1]+=ph)
for(x=0,pos[0]=tl[0];x<w;x++,pen.inc_x(),pos[0]+=pw)
pen.put_value(
Color::blend(
color_func(
pos,
supersample_size,
pen.get_value()
),
pen.get_value(),
get_amount(),
get_blend_method()
)
);
}
// Mark our progress as finished
if(cb && !cb->amount_complete(10000,10000))
return false;
return true;
}
示例4: filename_extension
void Instance::save_surface(const synfig::Surface &surface, const synfig::String &filename)
{
if (surface.get_h() <= 0 || surface.get_w() <= 0) return;
String ext = filename_extension(filename);
if (ext.empty()) return;
ext.erase(0, 1);
String tmpfile = FileContainerTemporary::generate_temporary_filename();
etl::handle<Target_Scanline> target
= etl::handle<Target_Scanline>(Target::create(Target::ext_book()[ext],tmpfile,TargetParam()));
if (!target) return;
target->set_canvas(get_canvas());
RendDesc desc;
desc.set_w(surface.get_w());
desc.set_h(surface.get_h());
desc.set_x_res(1);
desc.set_y_res(1);
desc.set_frame_rate(1);
desc.set_frame(0);
desc.set_frame_start(0);
desc.set_frame_end(0);
target->set_rend_desc(&desc);
target->add_frame(&surface);
target = NULL;
FileSystem::copy(FileSystemNative::instance(), tmpfile, get_file_system(), filename);
FileSystemNative::instance()->file_remove(tmpfile);
}
示例5: sub_task
void
TaskLayer::set_coords_sub_tasks()
{
if (!sub_task())
return;
if (!is_valid_coords() || !layer)
{ sub_task()->set_coords_zero(); return; }
VectorInt size = target_rect.get_size();
RendDesc desc;
desc.set_wh(size[0], size[1]);
desc.set_tl(source_rect.get_min());
desc.set_br(source_rect.get_max());
std::vector<RendDesc> descs;
layer->get_sub_renddesc(desc, descs);
sort(descs.begin(), descs.end(), renddesc_less);
Task::Handle task = sub_task();
sub_tasks.clear();
for(std::vector<RendDesc>::const_iterator i = descs.begin(); i != descs.end(); ++i)
{
if (i->get_w() <= 0 || i->get_h() <= 0)
continue;
Point lt = i->get_tl(), rb = i->get_br();
Rect rect(lt, rb);
if (!rect.is_valid())
continue;
Matrix matrix;
if (approximate_less(rb[0], lt[0]))
{ matrix.m00 = -1.0; matrix.m20 = rb[0] - lt[0]; }
if (approximate_less(rb[1], lt[1]))
{ matrix.m11 = -1.0; matrix.m20 = rb[1] - lt[1]; }
matrix = i->get_transformation_matrix() * matrix;
if (!matrix.is_invertible())
continue;
Task::Handle t = task->clone();
if (!matrix.is_identity()) {
TaskTransformationAffine::Handle ta = new TaskTransformationAffine();
ta->transformation->matrix = matrix;
ta->sub_task() = t;
t = ta;
}
sub_tasks.push_back(t);
t->set_coords(rect, VectorInt(i->get_w(), i->get_h()));
}
}
示例6: supercb
bool
RadialGradient::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__)
SuperCallback supercb(cb,0,9500,10000);
if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
{
surface->set_wh(renddesc.get_w(),renddesc.get_h());
}
else
{
if(!context.accelerated_render(surface,quality,renddesc,&supercb))
return false;
if(get_amount()==0)
return true;
}
int x,y;
Surface::pen pen(surface->begin());
const Real pw(renddesc.get_pw()),ph(renddesc.get_ph());
Point pos;
Point tl(renddesc.get_tl());
const int w(surface->get_w());
const int h(surface->get_h());
if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT)
{
for(y=0,pos[1]=tl[1];y<h;y++,pen.inc_y(),pen.dec_x(x),pos[1]+=ph)
for(x=0,pos[0]=tl[0];x<w;x++,pen.inc_x(),pos[0]+=pw)
pen.put_value(color_func(pos,calc_supersample(pos,pw,ph)));
}
else
{
for(y=0,pos[1]=tl[1];y<h;y++,pen.inc_y(),pen.dec_x(x),pos[1]+=ph)
for(x=0,pos[0]=tl[0];x<w;x++,pen.inc_x(),pos[0]+=pw)
pen.put_value(Color::blend(color_func(pos,calc_supersample(pos,pw,ph)),pen.get_value(),get_amount(),get_blend_method()));
}
// Mark our progress as finished
if(cb && !cb->amount_complete(10000,10000))
return false;
return true;
}
示例7:
bool
TaskLayerSW::run(RunParams & /* params */) const
{
synfig::Surface &target =
SurfaceSW::Handle::cast_dynamic( target_surface )->get_surface();
// TODO: target_rect
RendDesc desc;
desc.set_tl(get_source_rect_lt());
desc.set_br(get_source_rect_rb());
desc.set_wh(target.get_w(), target.get_h());
desc.set_antialias(1);
Canvas::Handle canvas = Canvas::create();
return layer->accelerated_render(canvas->get_context(ContextParams()), &target, 4, desc, NULL);
}
示例8: units
Real
Distance::get(Distance::System target, const RendDesc& rend_desc)const
{
if(target==SYSTEM_UNITS)
return units(rend_desc);
if(target==SYSTEM_PIXELS)
return units(rend_desc)*METERS_PER_UNIT*rend_desc.get_x_res();
return meters_to_system(meters(rend_desc),target);
}
示例9: meters
Real
Distance::meters(const RendDesc& rend_desc)const
{
if(system_>SYSTEM_PIXELS)
return meters();
if(system_==SYSTEM_UNITS)
return value_*METERS_PER_UNIT;
if(system_==SYSTEM_PIXELS)
return value_/rend_desc.get_x_res();
throw BadSystem();
}
示例10: supercb
bool
Layer_Clamp::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
SuperCallback supercb(cb,0,9500,10000);
if(!context.accelerated_render(surface,quality,renddesc,&supercb))
return false;
int x,y;
Surface::pen pen(surface->begin());
for(y=0;y<renddesc.get_h();y++,pen.inc_y(),pen.dec_x(x))
for(x=0;x<renddesc.get_w();x++,pen.inc_x())
pen.put_value(clamp_color(pen.get_value()));
// Mark our progress as finished
if(cb && !cb->amount_complete(10000,10000))
return false;
return true;
}
示例11: sort
void
OptimizerLayerSW::run(const RunParams& params) const
{
TaskLayer::Handle layer = TaskLayer::Handle::cast_dynamic(params.ref_task);
if ( layer
&& layer->target_surface
&& layer.type_equal<TaskLayer>() )
{
if (!layer->layer) { apply(params, Task::Handle()); return; }
TaskLayerSW::Handle layer_sw = create_and_assign<TaskLayerSW>(layer);
layer_sw->sub_tasks.clear();
if (layer->sub_task())
{
VectorInt size = layer_sw->get_target_rect().get_size();
RendDesc desc;
desc.set_wh(size[0], size[1]);
desc.set_tl(layer_sw->get_source_rect_lt());
desc.set_br(layer_sw->get_source_rect_rb());
std::vector<RendDesc> descs;
layer_sw->layer->get_sub_renddesc(desc, descs);
sort(descs.begin(), descs.end(), renddesc_less);
for(std::vector<RendDesc>::const_iterator i = descs.begin(); i != descs.end(); ++i)
{
Task::Handle task = layer->sub_task()->clone();
assign_surface<SurfaceSW>(task, i->get_w(), i->get_h(), i->get_tl(), i->get_br(), RectInt(0, 0, i->get_w(), i->get_h()));
layer_sw->sub_tasks.push_back(task);
}
}
apply(params, layer_sw);
}
}
示例12: transformed_renddesc
bool
Layer_Stretch::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
Vector amount=param_amount.get(Vector());
Point center=param_center.get(Point());
if (amount[0] == 0 || amount[1] == 0)
{
surface->set_wh(renddesc.get_w(), renddesc.get_h());
surface->clear();
return true;
}
RendDesc transformed_renddesc(renddesc);
transformed_renddesc.clear_flags();
transformed_renddesc.set_transformation_matrix(
Matrix().set_translate(-center)
* Matrix().set_scale(amount)
* Matrix().set_translate(center)
* renddesc.get_transformation_matrix() );
// Render the scene
return context.accelerated_render(surface,quality,transformed_renddesc,cb);
}
示例13:
Real
Distance::units(const RendDesc& rend_desc)const
{
if(system_==SYSTEM_UNITS)
return value_;
Real ret;
if(system_>SYSTEM_PIXELS)
ret=meters();
else
ret=value_/rend_desc.get_x_res();
return ret/METERS_PER_UNIT;
}
示例14: transformed_renddesc
bool
Zoom::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
Vector center=param_center.get(Vector());
Real amount=param_amount.get(Real());
RendDesc transformed_renddesc(renddesc);
transformed_renddesc.clear_flags();
transformed_renddesc.set_transformation_matrix(
Matrix().set_translate(-center)
* Matrix().set_scale(exp(amount))
* Matrix().set_translate(center)
* renddesc.get_transformation_matrix() );
// Render the scene
return context.accelerated_render(surface,quality,transformed_renddesc,cb);
}
示例15: get_canvas_view
void studio::Widget_NavView::on_start_render()
{
if(dirty)
{
//this should set it to render a single frame
RendDesc r = get_canvas_view()->get_canvas()->rend_desc();
r.set_time(get_canvas_view()->canvas_interface()->get_time());
//this changes the size of the canvas to the closest thing we can find
int sw = r.get_w(), sh = r.get_h();
//resize so largest dimension is 128
int dw = sw > sh ? 128 : sw*128/sh,
dh = sh > sw ? 128 : sh*128/sw;
r.set_w(dw);
r.set_h(dh);
if(studio::App::navigator_uses_cairo)
{
// Create a cairo_image_target
etl::handle<Target_Cairo> targ = cairo_image_target(&cairo_surface);
// Fill the target with the proper information
targ->set_canvas(get_canvas_view()->get_canvas());
targ->set_alpha_mode(TARGET_ALPHA_MODE_FILL);
targ->set_avoid_time_sync();
targ->set_quality(get_canvas_view()->get_work_area()->get_quality());
targ->set_rend_desc(&r);
// Sets up a Asynchronous renderer
renderer = new AsyncRenderer(targ);
}
else
{
// Create a surface_target
etl::handle<Target_Scanline> targ = surface_target(surface.get());
// Fill the target with the proper information
targ->set_canvas(get_canvas_view()->get_canvas());
targ->set_alpha_mode(TARGET_ALPHA_MODE_FILL);
targ->set_avoid_time_sync();
targ->set_quality(get_canvas_view()->get_work_area()->get_quality());
targ->set_rend_desc(&r);
// Sets up a Asynchronous renderer
renderer = new AsyncRenderer(targ);
}
// connnect the renderer success to the finish render handler
renderer->signal_success().connect(sigc::mem_fun(*this,&Widget_NavView::on_finish_render));
// Mark it as clean since we are to start to render
dirty = false;
// start the asynchronous rendering
renderer->start();
}
}