Bug 969388 - Fix locking in textures gtest. r=kats
authorNicolas Silva <nical@mozilla.com>
Wed, 19 Feb 2014 17:34:49 +0100
changeset 169879 1a5dbdd480ffda4087b2c829f125f3b9487ce1f0
parent 169878 98d81d6422dd19e8799871144b8d05d2f27b279c
child 169880 e42874936c101388c8a887aa66eda092d7701c08
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerskats
bugs969388
milestone30.0a1
Bug 969388 - Fix locking in textures gtest. r=kats
gfx/tests/gtest/TestTextures.cpp
--- a/gfx/tests/gtest/TestTextures.cpp
+++ b/gfx/tests/gtest/TestTextures.cpp
@@ -103,23 +103,23 @@ void AssertYCbCrSurfacesEqual(PlanarYCbC
 void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface) {
 
   // client allocation
   ASSERT_TRUE(texture->AsTextureClientSurface() != nullptr);
   TextureClientSurface* client = texture->AsTextureClientSurface();
   client->AllocateForSurface(ToIntSize(surface->GetSize()));
   ASSERT_TRUE(texture->IsAllocated());
 
+  ASSERT_TRUE(texture->Lock(OPEN_READ_WRITE));
   // client painting
   client->UpdateSurface(surface);
 
   nsRefPtr<gfxASurface> aSurface = client->GetAsSurface();
   nsRefPtr<gfxImageSurface> clientSurface = aSurface->GetAsImageSurface();
 
-  ASSERT_TRUE(texture->Lock(OPEN_READ_ONLY));
   AssertSurfacesEqual(surface, clientSurface);
   texture->Unlock();
 
   // client serialization
   SurfaceDescriptor descriptor;
   ASSERT_TRUE(texture->ToSurfaceDescriptor(descriptor));
 
   ASSERT_NE(descriptor.type(), SurfaceDescriptor::Tnull_t);
@@ -150,20 +150,19 @@ void TestTextureClientYCbCr(TextureClien
   // client allocation
   ASSERT_TRUE(client->AsTextureClientYCbCr() != nullptr);
   TextureClientYCbCr* texture = client->AsTextureClientYCbCr();
   texture->AllocateForYCbCr(ycbcrData.mYSize,
                             ycbcrData.mCbCrSize,
                             ycbcrData.mStereoMode);
   ASSERT_TRUE(client->IsAllocated());
 
+  ASSERT_TRUE(client->Lock(OPEN_READ_WRITE));
   // client painting
   texture->UpdateYCbCr(ycbcrData);
-
-  ASSERT_TRUE(client->Lock(OPEN_READ_ONLY));
   client->Unlock();
 
   // client serialization
   SurfaceDescriptor descriptor;
   ASSERT_TRUE(client->ToSurfaceDescriptor(descriptor));
 
   ASSERT_NE(descriptor.type(), SurfaceDescriptor::Tnull_t);
 
@@ -171,23 +170,21 @@ void TestTextureClientYCbCr(TextureClien
   RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(descriptor, nullptr,
                                                                         client->GetFlags());
 
   RefPtr<BufferTextureHost> host = static_cast<BufferTextureHost*>(textureHost.get());
 
   ASSERT_TRUE(host.get() != nullptr);
   ASSERT_EQ(host->GetFlags(), client->GetFlags());
 
-  // This will work iff the compositor is not BasicCompositor
-  ASSERT_EQ(host->GetFormat(), mozilla::gfx::SurfaceFormat::YUV);
-
   // host read
   ASSERT_TRUE(host->Lock());
 
-  ASSERT_TRUE(host->GetFormat() == mozilla::gfx::SurfaceFormat::YUV);
+  // This will work iff the compositor is not BasicCompositor
+  ASSERT_EQ(host->GetFormat(), mozilla::gfx::SurfaceFormat::YUV);
 
   YCbCrImageDataDeserializer yuvDeserializer(host->GetBuffer());
   ASSERT_TRUE(yuvDeserializer.IsValid());
   PlanarYCbCrData data;
   data.mYChannel = yuvDeserializer.GetYData();
   data.mCbChannel = yuvDeserializer.GetCbData();
   data.mCrChannel = yuvDeserializer.GetCrData();
   data.mYStride = yuvDeserializer.GetYStride();