void Resize::process2d(const ImagePlane<const void> &src, const ImagePlane<void> &dst, void *tmp) const
{
	PixelType type = src.format().type;
	LinearAllocator alloc{ tmp };
	ResizeContext ctx = get_context(alloc, type);

	LineBuffer<void> src_buf{ (void *)src.data(), 0, (unsigned)src.width(), (unsigned)src.stride() * pixel_size(type), UINT_MAX };
	LineBuffer<void> dst_buf{ dst.data(), 0, (unsigned)dst.width(), (unsigned)dst.stride() * pixel_size(type), UINT_MAX };

	bool overflow_flag = false;
	unsigned buffer_pos = 0;
	unsigned src_linesize = m_src_width * pixel_size(type);
	unsigned dst_linesize = m_dst_width * pixel_size(type);

	for (unsigned i = 0; i < m_dst_height; i += ctx.out_buffering2) {
		const LineBuffer<void> *in_buf = &src_buf;
		LineBuffer<void> *out_buf = &dst_buf;

		unsigned dep2_first = ctx.impl2->dependent_line(i);
		unsigned dep2_last = std::min(dep2_first + ctx.in_buffering2, ctx.tmp_height);

		for (; buffer_pos < dep2_last; buffer_pos += ctx.out_buffering1) {
			unsigned dep1_first = ctx.impl1->dependent_line(buffer_pos);
			unsigned dep1_last = dep1_first + ctx.in_buffering1;

			if (dep1_last > m_src_height) {
				if (!overflow_flag) {
					copy_buffer_lines(src_buf, ctx.src_border_buf, src_linesize, dep1_first, m_src_height);
					overflow_flag = true;
				}
				in_buf = &ctx.src_border_buf;
			}

			invoke_impl(ctx.impl1, type, *in_buf, ctx.tmp_buf, buffer_pos, ctx.tmp_data);
		}

		if (i + ctx.out_buffering2 > m_dst_height)
			out_buf = &ctx.dst_border_buf;

		invoke_impl(ctx.impl2, type, ctx.tmp_buf, *out_buf, i, ctx.tmp_data);

		if (i + ctx.out_buffering2 > m_dst_height)
			copy_buffer_lines(ctx.dst_border_buf, dst_buf, dst_linesize, i, m_dst_height);
	}
}
Exemple #2
0
		static void invoke_impl( type_tuple< Message, Rest... >, message_handler<MH...> const& mh, DWORD id )
		{
			if( id == Message::id ) {
				mh.invoke( Message() );
				return;
			}

			invoke_impl( type_tuple< Rest... >(), mh, id );
		}
Exemple #3
0
    void invoke_task(index_tuple<Indecies...>)
    {
		try {
			invoke_impl(
				promise_,
				std::move(std::get<0>(bound_)),
				std::move(std::get<Indecies+1>(bound_))... );
		} catch(...) {
			promise_.set_exception(std::current_exception());
		}
    }
Exemple #4
0
		static void invoke( message_handler< Messages... > const& mh, DWORD id )
		{
			invoke_impl( type_tuple< Messages... >(), mh, id );
		}
Exemple #5
0
 typename GeneratorT::result_type
 invoke(const ArgumentListT& arguments, GeneratorT const& generator = nullptr)
 {
     return invoke_impl(arguments, generator, std::make_index_sequence<arity>{});
 }