GIL_FORCEINLINE F transform_pixels_locator(const View1& src1, const Rect<std::ptrdiff_t>& src1Rod, const View2& src2,
                                           const Rect<std::ptrdiff_t>& src2Rod, const View2& src3,
                                           const Rect<std::ptrdiff_t>& src3Rod, const ViewDst& dst,
                                           const Rect<std::ptrdiff_t>& dstRod, const Rect<std::ptrdiff_t>& renderWin,
                                           const F& fun)
{
    const std::ptrdiff_t renderWidth = renderWin.x2 - renderWin.x1;
    typename View1::xy_locator s1loc = src1.xy_at(renderWin.x1 - src1Rod.x1, renderWin.y1 - src1Rod.y1);
    typename View2::xy_locator s2loc = src2.xy_at(renderWin.x1 - src2Rod.x1, renderWin.y1 - src2Rod.y1);
    typename View3::xy_locator s3loc = src3.xy_at(renderWin.x1 - src3Rod.x1, renderWin.y1 - src3Rod.y1);
    for(std::ptrdiff_t y = renderWin.y1; y < renderWin.y2; ++y)
    {
        typename ViewDst::x_iterator dstIt = dst.x_at(dstRod.x1, y - dstRod.y1);
        for(std::ptrdiff_t x = renderWin.x1; x < renderWin.x2; ++x, ++s1loc.x(), ++s2loc.x(), ++s3loc.x(), ++dstIt)
        {
            *dstIt = fun(s1loc, s2loc, s3loc);
        }
        s1loc.x() -= renderWidth;
        ++s1loc.y();
        s2loc.x() -= renderWidth;
        ++s2loc.y();
        s3loc.x() -= renderWidth;
        ++s3loc.y();
    }
    return fun;
}
Exemple #2
0
 void operator () (View1 to, View2 from)
 {
     auto w = std::min(to.GetWidth(), from.GetWidth());
     auto h = std::min(to.GetHeight(), from.GetHeight());
     for (size_t i = 0; i < h; i++)
     {
         auto p1 = to.BeginRow(i);
         auto p2 = from.BeginRow(i);
         for (size_t j = 0; j < w; j++, p1++, p2++)
         {
             *p1 = *p2;
         }
     }
 }
Exemple #3
0
GIL_FORCEINLINE
F transform_pixels_progress( const View1& src, const View2& dst, const F& fun, IProgress& p )
{
	assert( src.dimensions() == dst.dimensions() );
	for( std::ptrdiff_t y = 0; y < src.height(); ++y )
	{
		typename View1::x_iterator srcIt = src.row_begin( y );
		typename View2::x_iterator dstIt = dst.row_begin( y );
		for( std::ptrdiff_t x = 0; x < src.width(); ++x )
			dstIt[x] = fun( srcIt[x] );
		if( p.progressForward( dst.width() ) )
			return fun;
	}
	return fun;
}
Exemple #4
0
void
apply_ukernel(View0 in0,
	      View1 in1,
	      View2 in2,
	      View3 out)
{
  dda::Data<typename View0::block_type, dda::in> data0(in0.block());
  dda::Data<typename View1::block_type, dda::in> data1(in1.block());
  dda::Data<typename View2::block_type, dda::in> data2(in2.block());
  dda::Data<typename View3::block_type, dda::out> data3(out.block());

  assert(data0.stride(1) == 1);
  assert(data1.stride(1) == 1);
  assert(data2.stride(1) == 1);
  assert(data3.stride(1) == 1);

  example::Cblock kernel((uintptr_t)data0.ptr(), data0.stride(0),
			 (uintptr_t)data1.ptr(), data1.stride(0),
			 (uintptr_t)data2.ptr(), data2.stride(0),
			 (uintptr_t)data3.ptr(), data3.stride(0),
			 out.size(0), out.size(1));
  
  vsip_csl::ukernel::Ukernel<example::Cblock> uk(kernel);

  uk();
}
Exemple #5
0
GIL_FORCEINLINE void tbb_copy_pixels( const View1& src, const View2& dst)
{ 
    assert(src.dimensions()==dst.dimensions());
    tbb::parallel_for( tbb::blocked_range<std::size_t>( 0, src.height()),
                        detail::make_tbb_copy_pixels_fun( src, dst),
                        GIL_TBB_ALGORITHMS_DEFAULT_PARTITIONER());
}
Exemple #6
0
GIL_FORCEINLINE
F transform_pixels_locator_progress( const View1& src1, const OfxRectI& src1Rod,
									 const View2& src2, const OfxRectI& src2Rod,
									 const ViewDst& dst, const OfxRectI& dstRod,
									 const OfxRectI& renderWin, const F& fun, IProgress& p )
{
	const std::ptrdiff_t renderWidth = renderWin.x2 - renderWin.x1;
	typename View1::xy_locator s1loc = src1.xy_at( renderWin.x1-src1Rod.x1, renderWin.y1-src1Rod.y1 );
	typename View2::xy_locator s2loc = src2.xy_at( renderWin.x1-src2Rod.x1, renderWin.y1-src2Rod.y1 );
	for( std::ptrdiff_t y = renderWin.y1; y < renderWin.y2; ++y )
	{
		typename ViewDst::x_iterator dstIt = dst.x_at( dstRod.x1, y-dstRod.y1 );
		for( std::ptrdiff_t x = renderWin.x1;
		     x < renderWin.x2;
		     ++x, ++s1loc.x(), ++s2loc.x(), ++dstIt )
		{
			*dstIt = fun( s1loc, s2loc );
		}
		s1loc.x() -= renderWidth; ++s1loc.y();
		s2loc.x() -= renderWidth; ++s2loc.y();
		if( p.progressForward( renderWidth ) )
			return fun;
	}
	return fun;
}
void
apply_ukernel(View0 in0,
	      View1 in1,
	      View2 in2,
	      View3 out)
{
  dda::Ext_data<typename View0::block_type> ext0(in0.block());
  dda::Ext_data<typename View1::block_type> ext1(in1.block());
  dda::Ext_data<typename View2::block_type> ext2(in2.block());
  dda::Ext_data<typename View3::block_type> ext3(out.block());

  assert(ext0.stride(1) == 1);
  assert(ext1.stride(1) == 1);
  assert(ext2.stride(1) == 1);
  assert(ext3.stride(1) == 1);

  example::Cblock kernel((uintptr_t)ext0.data(), ext0.stride(0),
			 (uintptr_t)ext1.data(), ext1.stride(0),
			 (uintptr_t)ext2.data(), ext2.stride(0),
			 (uintptr_t)ext3.data(), ext3.stride(0),
			 out.size(0), out.size(1));
  
  vsip_csl::ukernel::Ukernel<example::Cblock> uk(kernel);

  uk();
}
Exemple #8
0
GIL_FORCEINLINE
F transform_pixels_progress( const View1& src1, const View2& src2, const View3& src3, const View4& dst, const F& fun, IProgress& p )
{
	assert( src1.dimensions() == dst.dimensions() );
	assert( src2.dimensions() == dst.dimensions() );
	assert( src3.dimensions() == dst.dimensions() );
	for( std::ptrdiff_t y = 0; y < dst.height(); ++y )
	{
		typename View1::x_iterator srcIt1 = src1.row_begin( y );
		typename View2::x_iterator srcIt2 = src2.row_begin( y );
		typename View3::x_iterator srcIt3 = src3.row_begin( y );
		typename View4::x_iterator dstIt  = dst.row_begin( y );
		for( std::ptrdiff_t x = 0; x < dst.width(); ++x )
			dstIt[x] = fun( srcIt1[x], srcIt2[x], srcIt3[x] );
		if( p.progressForward( dst.width() ) )
			return fun;
	}
	return fun;
}
inline void checkNewViewWasAllocated( View1 const &v1, View2 const &v2 )
{
    BOOST_TEST( v1.data() != v2.data() );

    BOOST_TEST( (int)View1::rank == (int)View2::rank );
    BOOST_TEST( ( std::is_same<typename View1::const_value_type,
                               typename View2::const_value_type>::value ) );

    BOOST_TEST( v1.dimension_0() == v2.dimension_0() );
    BOOST_TEST( v1.dimension_1() == v2.dimension_1() );
    BOOST_TEST( v1.dimension_2() == v2.dimension_2() );
    BOOST_TEST( v1.dimension_3() == v2.dimension_3() );
    BOOST_TEST( v1.dimension_4() == v2.dimension_4() );
    BOOST_TEST( v1.dimension_5() == v2.dimension_5() );
    BOOST_TEST( v1.dimension_6() == v2.dimension_6() );
    BOOST_TEST( v1.dimension_7() == v2.dimension_7() );
}
Exemple #10
0
void
check_alias(
  View1<T1, Block1>& vec1,
  View2<T2, Block2>& vec2)
{
  fill_block(vec1.block(), 2);
  test_assert(check_vector(vec1, 2));
  test_assert(check_vector(vec2, 2));

  fill_block(vec2.block(), 3);
  test_assert(check_vector(vec1, 3));
  test_assert(check_vector(vec2, 3));
}
inline void checkViewWasNotAllocated( View1 const &v1, View2 const &v2 )
{
    // NOTE: cannot use operator== here because array layout may "change" for
    // rank-1 views
    BOOST_TEST( v1.data() == v2.data() );
    BOOST_TEST( v1.span() == v2.span() );

    BOOST_TEST( (int)View1::rank == (int)View2::rank );
    BOOST_TEST( ( std::is_same<typename View1::const_value_type,
                               typename View2::const_value_type>::value ) );
    BOOST_TEST( ( std::is_same<typename View1::memory_space,
                               typename View2::memory_space>::value ) );

    BOOST_TEST( v1.dimension_0() == v2.dimension_0() );
    BOOST_TEST( v1.dimension_1() == v2.dimension_1() );
    BOOST_TEST( v1.dimension_2() == v2.dimension_2() );
    BOOST_TEST( v1.dimension_3() == v2.dimension_3() );
    BOOST_TEST( v1.dimension_4() == v2.dimension_4() );
    BOOST_TEST( v1.dimension_5() == v2.dimension_5() );
    BOOST_TEST( v1.dimension_6() == v2.dimension_6() );
    BOOST_TEST( v1.dimension_7() == v2.dimension_7() );
}
inline void checkNewViewWasAllocated( View1 const &v1, View2 const &v2,
                                      bool &success,
                                      Teuchos::FancyOStream &out )
{
    TEST_INEQUALITY( v1.data(), v2.data() );

    TEST_EQUALITY( (int)View1::rank, (int)View2::rank );
    TEST_ASSERT( ( std::is_same<typename View1::const_value_type,
                                typename View2::const_value_type>::value ) );

    TEST_EQUALITY( v1.dimension_0(), v2.dimension_0() );
    TEST_EQUALITY( v1.dimension_1(), v2.dimension_1() );
    TEST_EQUALITY( v1.dimension_2(), v2.dimension_2() );
    TEST_EQUALITY( v1.dimension_3(), v2.dimension_3() );
    TEST_EQUALITY( v1.dimension_4(), v2.dimension_4() );
    TEST_EQUALITY( v1.dimension_5(), v2.dimension_5() );
    TEST_EQUALITY( v1.dimension_6(), v2.dimension_6() );
    TEST_EQUALITY( v1.dimension_7(), v2.dimension_7() );
}
Exemple #13
0
void
check_not_alias(
  View1<T1, Block1>& vec1,
  View2<T2, Block2>& vec2)
{
  fill_block(vec1.block(), 2);
  fill_block(vec2.block(), 3);

  // Make sure that updates to vec2 do not affect vec1.
  test_assert(check_vector(vec1, 2));

  // And visa-versa.
  fill_block(vec1.block(), 4);
  test_assert(check_vector(vec2, 3));
}
inline void checkViewWasNotAllocated( View1 const &v1, View2 const &v2,
                                      bool &success,
                                      Teuchos::FancyOStream &out )
{
    // NOTE: cannot use operator== here because array layout may "change" for
    // rank-1 views
    TEST_EQUALITY( v1.data(), v2.data() );
    TEST_EQUALITY( v1.span(), v2.span() );

    TEST_EQUALITY( (int)View1::rank, (int)View2::rank );
    TEST_ASSERT( ( std::is_same<typename View1::const_value_type,
                                typename View2::const_value_type>::value ) );
    TEST_ASSERT( ( std::is_same<typename View1::memory_space,
                                typename View2::memory_space>::value ) );

    TEST_EQUALITY( v1.dimension_0(), v2.dimension_0() );
    TEST_EQUALITY( v1.dimension_1(), v2.dimension_1() );
    TEST_EQUALITY( v1.dimension_2(), v2.dimension_2() );
    TEST_EQUALITY( v1.dimension_3(), v2.dimension_3() );
    TEST_EQUALITY( v1.dimension_4(), v2.dimension_4() );
    TEST_EQUALITY( v1.dimension_5(), v2.dimension_5() );
    TEST_EQUALITY( v1.dimension_6(), v2.dimension_6() );
    TEST_EQUALITY( v1.dimension_7(), v2.dimension_7() );
}
 AssignFunctor( const View1 view_1, View2 view_2 )
     : _view_1( view_1 )
     , _view_2( view_2 )
 {
     static_assert( std::is_same<typename View1::traits::value_type,
                                 typename View2::traits::value_type>::value,
                    "View data types must be the same" );
     static_assert( std::is_same<typename View1::traits::device_type,
                                 typename View2::traits::device_type>::value,
                    "View device types must be the same" );
     static_assert( static_cast<unsigned>( View1::Rank ) == 2,
                    "View ranks must be 2" );
     static_assert( static_cast<unsigned>( View2::Rank ) == 2,
                    "View ranks must be 2" );
     DTK_REQUIRE( view_1.extent( 0 ) == view_2.extent( 0 ) );
     DTK_REQUIRE( view_1.extent( 1 ) == view_2.extent( 1 ) );
 }
MapEditorForm::MapEditorForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MapEditorForm)
{
    ui->setupUi(this);

    is_turf_selected_ = false;

    InitSettersForTypes();

    scene_ = new GraphicsScene;
    map_editor_ = new MapEditor(scene_);

    connect(scene_, &GraphicsScene::mousePressed, map_editor_, &MapEditor::mousePressedEvent);
    connect(scene_, &GraphicsScene::keyboardPressed, map_editor_, &MapEditor::keyPressedEvent);
    connect(scene_, &GraphicsScene::rightClick, this, &MapEditorForm::mapClicked);
    connect(map_editor_, &MapEditor::newSelectionSetted, this, &MapEditorForm::newSelectionSetted);

    map_editor_->Resize(100, 100, 1);

    map_editor_->SetPointer(2, 2);

    ui->graphicsView->setScene(scene_);

    SetSpriter(new SpriteHolder);

    for (auto it = (*itemList()).begin(); it != (*itemList()).end(); ++it)
    {
        IMainObject* loc = it->second(0);
        IOnMapObject* bloc = castTo<IOnMapObject>(loc);
        if (!bloc)
        {
            //delete loc;
            continue;
        }
        bool is_turf = false;
        if (castTo<ITurf>(loc))
        {
            is_turf = true;
        }

        ViewInfo* view_info = bloc->GetView();

        if (   view_info->GetBaseFrameset().GetSprite() == ""
            || view_info->GetBaseFrameset().GetState() == "")
        {
            continue;
        }

        QVector<QPixmap> images;

        View2 view;
        view.LoadViewInfo(*view_info);

        if (view.GetBaseFrameset().GetMetadata() == nullptr)
        {
            continue;
        }

        for (size_t dir = 0; dir < view.GetBaseFrameset().GetMetadata()->dirs; ++dir)
        {
            int current_frame_pos = view.GetBaseFrameset().GetMetadata()->first_frame_pos + dir;

            int image_state_h_ = current_frame_pos / view.GetBaseFrameset().GetSprite()->FrameW();
            int image_state_w_ = current_frame_pos % view.GetBaseFrameset().GetSprite()->FrameW();

            SDL_Surface* s = view.GetBaseFrameset().GetSprite()->GetSDLSprite()->frames
                    [image_state_w_ * view.GetBaseFrameset().GetSprite()->FrameH() + image_state_h_];
            QImage img(static_cast<uchar*>(s->pixels),
                                   s->w, s->h, QImage::Format_ARGB32);

            images.push_back(QPixmap::fromImage(img));
        }
        map_editor_->AddItemType(it->first, images);

        QListWidgetItem* new_item
                = new QListWidgetItem(QIcon(images[0]), bloc->T_ITEM().c_str());

        if (!is_turf)
        {
            types_.push_back(it->first);
            ui->listWidget->addItem(new_item);
        }
        else
        {
            turf_types_.push_back(it->first);
            map_editor_->AddTurfType(it->first);
            ui->listWidgetTurf->addItem(new_item);
        }
    }
}