void OptimizerBlendZero::apply_zero(const RunParams ¶ms, const TaskBlend::Handle &blend, const Task::Handle &task) const { if (!task || !task->valid_target()) { Task::Handle empty = new TaskSurfaceEmpty(); empty->target_surface = params.ref_task->target_surface; apply(params, empty); return; } if (task->target_surface == blend->target_surface) { apply(params, task); return; } apply(params, task->clone()); params.ref_task->target_surface = blend->target_surface; params.ref_task->move_target_rect( blend->get_target_offset() - task->get_target_offset() + (task == blend->sub_task_a() ? blend->offset_a : blend->offset_b) ); assert( params.ref_task->check() ); }
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())); } }