grab_XXX functions are temporarily removed

This commit is contained in:
2019-07-23 05:35:08 +07:00
parent 010da6e620
commit 22f88a7bdd
5 changed files with 8 additions and 325 deletions

View File

@@ -198,12 +198,7 @@ TEST_CASE("render"){
for ( auto& c : src ) {
c = rand() % 255;
}
r.update_texture(tex, src, b2u(0, 0, 128, 128));
image dst;
r.grab_texture(tex, b2u(0, 0, 128, 128), dst);
REQUIRE(dst.format() == image_data_format::rgba8);
REQUIRE(src == dst.data());
REQUIRE_NOTHROW(r.update_texture(tex, src, b2u(0, 0, 128, 128)));
}
{
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::g8);
@@ -214,22 +209,7 @@ TEST_CASE("render"){
for ( auto& c : src ) {
c = rand() % 255;
}
r.update_texture(tex, src, b2u(0, 0, 128, 128));
image dst;
r.grab_texture(tex, b2u(0, 0, 128, 128), dst);
if ( dst.format() == image_data_format::g8 ) {
REQUIRE(src == dst.data());
} else {
// OpenGL ES 2 may not support Alpha8 format
REQUIRE(dst.format() == image_data_format::rgba8);
REQUIRE(dst.data().size() == src.size()*4);
bool equal = true;
for ( size_t i = 0; i < src.size(); ++i ) {
equal &= (src.data()[i] == dst.data().data()[i*4+3]);
}
REQUIRE(equal);
}
REQUIRE_NOTHROW(r.update_texture(tex, src, b2u(0, 0, 128, 128)));
}
{
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgb8);
@@ -240,24 +220,7 @@ TEST_CASE("render"){
for ( auto& c : src ) {
c = rand() % 255;
}
r.update_texture(tex, src, b2u(0, 0, 128, 128));
image dst;
r.grab_texture(tex, b2u(0, 0, 128, 128), dst);
if ( dst.format() == image_data_format::rgb8 ) {
REQUIRE(src == dst.data());
} else {
// OpenGL ES 2 may not support RGB8 format
REQUIRE(dst.format() == image_data_format::rgba8);
REQUIRE(dst.data().size() == src.size()*4/3);
bool equal = true;
for ( size_t i = 0, j = 0; i < src.size(); i += 3, j += 4 ) {
equal &= (src.data()[i+0] == dst.data().data()[j+0]);
equal &= (src.data()[i+1] == dst.data().data()[j+1]);
equal &= (src.data()[i+2] == dst.data().data()[j+2]);
}
REQUIRE(equal);
}
REQUIRE_NOTHROW(r.update_texture(tex, src, b2u(0, 0, 128, 128)));
}
{
texture_ptr tex = r.create_texture(v2u(57,31), pixel_declaration::pixel_type::rgba8);
@@ -268,12 +231,7 @@ TEST_CASE("render"){
for ( auto& c : src ) {
c = rand() % 255;
}
r.update_texture(tex, src, b2u(0, 0, 57, 31));
image dst;
r.grab_texture(tex, b2u(0, 0, 57, 31), dst);
REQUIRE(dst.format() == image_data_format::rgba8);
REQUIRE(src == dst.data());
REQUIRE_NOTHROW(r.update_texture(tex, src, b2u(0, 0, 57, 31)));
}
{
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgba8);
@@ -284,25 +242,7 @@ TEST_CASE("render"){
for ( auto& c : src ) {
c = rand() % 255;
}
r.update_texture(tex, src, b2u(22, 17, 31, 44));
image dst;
r.grab_texture(tex, b2u(0, 0, 128, 128), dst);
REQUIRE(dst.format() == image_data_format::rgba8);
const size_t data_size = ((tex->size().x * tex->decl().bits_per_pixel()) / 8u) * tex->size().y;
REQUIRE(data_size == dst.data().size());
bool equal = true;
const size_t bpp = tex->decl().bits_per_pixel() / 8;
for ( u32 y = 0; y < 44; ++y ) {
const u8* dst_row = dst.data().data() + ((y + 17) * 128 + 22) * bpp;
const u8* src_row = src.data() + (y * 31 * bpp);
for ( u32 x = 0; x < 31 * bpp; ++x ) {
equal &= (src_row[x] == dst_row[x]);
}
}
REQUIRE(equal);
REQUIRE_NOTHROW(r.update_texture(tex, src, b2u(22, 17, 31, 44)));
}
{
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgba8);
@@ -332,12 +272,7 @@ TEST_CASE("render"){
texture_ptr tex = r.create_texture(src.size(), pixel_declaration::pixel_type::rgba_dxt5);
REQUIRE(tex != nullptr);
r.update_texture(tex, src, v2u(0,0));
image dst;
r.grab_texture(tex, b2u(src.size()), dst);
REQUIRE(dst.format() == image_data_format::rgba8);
REQUIRE(src.size() == dst.size());
REQUIRE_NOTHROW(r.update_texture(tex, src, v2u(0,0)));
}
}
}