Merge pull request #5292 from alalek:tapi_custom_ptr

pull/5317/head
Alexander Alekhin 10 years ago
commit cdfdf29eca
  1. 40
      modules/core/test/test_umat.cpp

@ -615,17 +615,14 @@ PARAM_TEST_CASE(getUMat, int, int, Size, bool)
cv::ocl::setUseOpenCL(isOpenCL_enabled);
}
private:
bool useOpenCL;
bool isOpenCL_enabled;
};
// UMat created from user allocated host memory (USE_HOST_PTR)
TEST_P(getUMat, custom_ptr)
{
void* pData = new unsigned char [size.area() * CV_ELEM_SIZE(type)];
// UMat created from user allocated host memory (USE_HOST_PTR)
void custom_ptr_test(size_t align_base, size_t align_offset)
{
void* pData_allocated = new unsigned char [size.area() * CV_ELEM_SIZE(type) + (align_base + align_offset)];
void* pData = (char*)alignPtr(pData_allocated, (int)align_base) + align_offset;
size_t step = size.width * CV_ELEM_SIZE(type);
{
Mat m = Mat(size, type, pData, step);
m.setTo(cv::Scalar::all(2));
@ -638,8 +635,29 @@ TEST_P(getUMat, custom_ptr)
double norm = cvtest::norm(d, expected, NORM_INF);
EXPECT_EQ(0, norm);
}
delete[] (unsigned char*)pData;
delete[] (unsigned char*)pData_allocated;
}
private:
bool useOpenCL;
bool isOpenCL_enabled;
};
TEST_P(getUMat, custom_ptr_align_4Kb)
{
custom_ptr_test(4096, 0);
}
TEST_P(getUMat, custom_ptr_align_64b)
{
custom_ptr_test(4096, 64);
}
TEST_P(getUMat, custom_ptr_align_none)
{
custom_ptr_test(4096, cv::alignSize(CV_ELEM_SIZE(type), 4));
}
TEST_P(getUMat, self_allocated)
@ -659,7 +677,7 @@ TEST_P(getUMat, self_allocated)
}
INSTANTIATE_TEST_CASE_P(UMat, getUMat, Combine(
Values(CV_8U), // depth
Values(CV_8U, CV_64F), // depth
Values(1, 3), // channels
Values(cv::Size(1, 1), cv::Size(255, 255), cv::Size(256, 256)), // Size
Bool() // useOpenCL

Loading…
Cancel
Save