// fills the surface with values betwee 0 and 100. staticvoid SetupSurface(gfxImageSurface* surface) { int bpp = gfxASurface::BytePerPixelFromFormat(surface->Format()); int stride = surface->Stride();
uint8_t val = 0;
uint8_t* data = surface->Data(); for (int y = 0; y < surface->Height(); ++y) { for (int x = 0; x < surface->Height(); ++x) { for (int b = 0; b < bpp; ++b) {
data[y * stride + x * bpp + b] = val; if (val == 100) {
val = 0;
} else {
++val;
}
}
}
}
}
// return true if two surfaces contain the same data staticvoid AssertSurfacesEqual(gfxImageSurface* surface1,
gfxImageSurface* surface2) {
ASSERT_EQ(surface1->GetSize(), surface2->GetSize());
ASSERT_EQ(surface1->Format(), surface2->Format());
uint8_t* data1 = surface1->Data();
uint8_t* data2 = surface2->Data(); int stride1 = surface1->Stride(); int stride2 = surface2->Stride(); int bpp = gfxASurface::BytePerPixelFromFormat(surface1->Format());
for (int y = 0; y < surface1->Height(); ++y) { for (int x = 0; x < surface1->Width(); ++x) { for (int b = 0; b < bpp; ++b) {
ASSERT_EQ(data1[y * stride1 + x * bpp + b],
data2[y * stride2 + x * bpp + b]);
}
}
}
}
RefPtr<DataSourceSurface> dataSurface1 = surface1->GetDataSurface();
RefPtr<DataSourceSurface> dataSurface2 = surface2->GetDataSurface();
DataSourceSurface::MappedSurface map1;
DataSourceSurface::MappedSurface map2; if (!dataSurface1->Map(DataSourceSurface::READ, &map1)) { return;
} if (!dataSurface2->Map(DataSourceSurface::READ, &map2)) {
dataSurface1->Unmap(); return;
}
uint8_t* data1 = map1.mData;
uint8_t* data2 = map2.mData; int stride1 = map1.mStride; int stride2 = map2.mStride; int bpp = BytesPerPixel(surface1->GetFormat()); int width = surface1->GetSize().width; int height = surface1->GetSize().height;
for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { for (int b = 0; b < bpp; ++b) {
ASSERT_EQ(data1[y * stride1 + x * bpp + b],
data2[y * stride2 + x * bpp + b]);
}
}
}
dataSurface1->Unmap();
dataSurface2->Unmap();
}
// Run the test for a texture client and a surface void TestTextureClientSurface(TextureClient* texture,
gfxImageSurface* surface) { // client allocation
ASSERT_TRUE(texture->CanExposeDrawTarget());
TEST(Layers, TextureSerialization)
{ // the test is run on all the following image formats
gfxImageFormat formats[3] = {
SurfaceFormat::A8R8G8B8_UINT32,
SurfaceFormat::X8R8G8B8_UINT32,
SurfaceFormat::A8,
};
for (int f = 0; f < 3; ++f) {
RefPtr<gfxImageSurface> surface = new gfxImageSurface(IntSize(400, 300), formats[f]);
SetupSurface(surface.get());
AssertSurfacesEqual(surface, surface);
RefPtr<ImageBridgeChild> imageBridge = ImageBridgeChild::GetSingleton(); staticint retry = 5; while (!imageBridge->IPCOpen() && retry) { // IPDL connection takes time especially in slow testing environment, like // VM machines. Here we added retry mechanism to wait for IPDL connnection. #ifdef XP_WIN
Sleep(1); #else
sleep(1); #endif
retry--;
}
// Skip this testing if IPDL connection is not ready if (!retry && !imageBridge->IPCOpen()) { return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.