bool BufferTextureClient::UpdateYCbCr(const PlanarYCbCrData& aData) { MOZ_ASSERT(mFormat == gfx::FORMAT_YUV, "This textureClient can only use YCbCr data"); MOZ_ASSERT(!IsImmutable()); MOZ_ASSERT(IsValid()); MOZ_ASSERT(aData.mCbSkip == aData.mCrSkip); YCbCrImageDataSerializer serializer(GetBuffer()); MOZ_ASSERT(serializer.IsValid()); if (!serializer.CopyData(aData.mYChannel, aData.mCbChannel, aData.mCrChannel, aData.mYSize, aData.mYStride, aData.mCbCrSize, aData.mCbCrStride, aData.mYSkip, aData.mCbSkip)) { NS_WARNING("Failed to copy image data!"); return false; } if (TextureRequiresLocking(mFlags)) { // We don't have support for proper locking yet, so we'll // have to be immutable instead. MarkImmutable(); } return true; }
bool BufferTextureClient::UpdateSurface(gfxASurface* aSurface) { MOZ_ASSERT(aSurface); MOZ_ASSERT(!IsImmutable()); MOZ_ASSERT(IsValid()); ImageDataSerializer serializer(GetBuffer()); if (!serializer.IsValid()) { return false; } RefPtr<gfxImageSurface> surf = serializer.GetAsThebesSurface(); if (!surf) { return false; } nsRefPtr<gfxContext> tmpCtx = new gfxContext(surf.get()); tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE); tmpCtx->DrawSurface(aSurface, gfxSize(serializer.GetSize().width, serializer.GetSize().height)); if (TextureRequiresLocking(mFlags) && !ImplementsLocking()) { // We don't have support for proper locking yet, so we'll // have to be immutable instead. MarkImmutable(); } return true; }
bool BufferTextureClient::UpdateSurface(gfxASurface* aSurface) { MOZ_ASSERT(aSurface); MOZ_ASSERT(!IsImmutable()); MOZ_ASSERT(IsValid()); ImageDataSerializer serializer(GetBuffer()); if (!serializer.IsValid()) { return false; } if (gfxPlatform::GetPlatform()->SupportsAzureContent()) { RefPtr<DrawTarget> dt = serializer.GetAsDrawTarget(); RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface); dt->CopySurface(source, IntRect(IntPoint(), serializer.GetSize()), IntPoint()); } else { RefPtr<gfxImageSurface> surf = serializer.GetAsThebesSurface(); if (!surf) { return false; } nsRefPtr<gfxContext> tmpCtx = new gfxContext(surf.get()); tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE); tmpCtx->DrawSurface(aSurface, gfxSize(serializer.GetSize().width, serializer.GetSize().height)); } if (TextureRequiresLocking(mFlags) && !ImplementsLocking()) { // We don't have support for proper locking yet, so we'll // have to be immutable instead. MarkImmutable(); } return true; }