Bug 1176363 - Part 1: Stop using DrawTargets off the main thread. r=mattwoodrow

This commit is contained in:
Bas Schouten
2015-07-27 15:47:29 +00:00
parent 3a3a2fb4b3
commit dfa16d7d10
15 changed files with 260 additions and 64 deletions

View File

@@ -214,6 +214,40 @@ GrallocTextureClientOGL::BorrowDrawTarget()
return mDrawTarget;
}
void
GrallocTextureClientOGL::UpdateFromSurface(gfx::DataSourceSurface* aSurface)
{
MOZ_ASSERT(IsValid());
MOZ_ASSERT(mMappedBuffer, "Calling TextureClient::BorrowDrawTarget without locking :(");
if (!IsValid() || !IsAllocated() || !mMappedBuffer) {
return;
}
gfx::SurfaceFormat format = SurfaceFormatForPixelFormat(mGraphicBuffer->getPixelFormat());
if (mSize != aSurface->GetSize() || mFormat != aSurface->GetFormat()) {
gfxCriticalError() << "Attempt to update texture client from a surface with a different size or format! This: " << mSize << " " << format << " Other: " << aSurface->GetSize() << " " << aSurface->GetFormat();
return;
}
long pixelStride = mGraphicBuffer->getStride();
long byteStride = pixelStride * BytesPerPixel(format);
DataSourceSurface::MappedSurface sourceMap;
aSurface->Map(DataSourceSurface::READ, &sourceMap);
uint8_t* buffer = GetBuffer();
for (int y = 0; y < aSurface->GetSize().height; y++) {
memcpy(buffer + byteStride * y,
sourceMap.mData + sourceMap.mStride * y,
aSurface->GetSize().width * BytesPerPixel(aSurface->GetFormat()));
}
aSurface->Unmap();
}
bool
GrallocTextureClientOGL::AllocateForSurface(gfx::IntSize aSize,
TextureAllocationFlags)