Ejemplo n.º 1
0
FenceHandle
Compositor::GetReleaseFence()
{
  if (!mReleaseFenceHandle.IsValid()) {
    return FenceHandle();
  }

  RefPtr<FenceHandle::FdObj> fdObj = mReleaseFenceHandle.GetDupFdObj();
  return FenceHandle(fdObj);
}
void
CompositableParentManager::ReturnTextureDataIfNecessary(CompositableHost* aCompositable,
                                                        EditReplyVector& replyv,
                                                        PCompositableParent* aParent)
{
  if (!aCompositable || !aCompositable->GetCompositableBackendSpecificData()) {
    return;
  }

  const std::vector< RefPtr<TextureHost> > textureList =
        aCompositable->GetCompositableBackendSpecificData()->GetPendingReleaseFenceTextureList();
  // Return pending Texture data
  for (size_t i = 0; i < textureList.size(); i++) {
    // File descriptor number is limited to 4 per IPC message.
    // See Bug 986253
    if (mPrevFenceHandles.size() >= 4) {
      break;
    }
    TextureHostOGL* hostOGL = textureList[i]->AsHostOGL();
    PTextureParent* actor = textureList[i]->GetIPDLActor();
    if (!hostOGL || !actor) {
      continue;
    }
    android::sp<android::Fence> fence = hostOGL->GetAndResetReleaseFence();
    if (fence.get() && fence->isValid()) {
      FenceHandle handle = FenceHandle(fence);
      replyv.push_back(ReturnReleaseFence(aParent, nullptr, actor, nullptr, handle));
      // Hold fence handle to prevent fence's file descriptor is closed before IPC happens.
      mPrevFenceHandles.push_back(handle);
    }
  }
  aCompositable->GetCompositableBackendSpecificData()->ClearPendingReleaseFenceTextureList();
}
Ejemplo n.º 3
0
FenceHandle
TextureHost::GetAndResetReleaseFenceHandle()
{
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
  TextureHostOGL* hostOGL = this->AsHostOGL();
  if (!hostOGL) {
    return FenceHandle();
  }

  android::sp<android::Fence> fence = hostOGL->GetAndResetReleaseFence();
  if (fence.get() && fence->isValid()) {
    FenceHandle handle = FenceHandle(fence);
    return handle;
  }
#endif
  return FenceHandle();
}
Ejemplo n.º 4
0
bool
ParamTraits<FenceHandle>::Read(const Message* aMsg,
                               void** aIter, paramType* aResult)
{
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
  base::FileDescriptor fd;
  if (aMsg->ReadFileDescriptor(aIter, &fd)) {
    aResult->Merge(FenceHandle(new FenceHandle::FdObj(fd.fd)));
  }
#endif
  return true;
}
Ejemplo n.º 5
0
bool
HwcComposer2D::Commit(nsScreenGonk* aScreen)
{
    for (uint32_t j=0; j < (mList->numHwLayers - 1); j++) {
        mList->hwLayers[j].acquireFenceFd = -1;
        if (mHwcLayerMap.IsEmpty() ||
                (mList->hwLayers[j].compositionType == HWC_FRAMEBUFFER)) {
            continue;
        }
        LayerRenderState state = mHwcLayerMap[j]->GetLayer()->GetRenderState();
        if (!state.mTexture) {
            continue;
        }
        FenceHandle fence = state.mTexture->GetAndResetAcquireFenceHandle();
        if (fence.IsValid()) {
            nsRefPtr<FenceHandle::FdObj> fdObj = fence.GetAndResetFdObj();
            mList->hwLayers[j].acquireFenceFd = fdObj->GetAndResetFd();
        }
    }

    int err = mHal->Set(mList, aScreen->GetDisplayType());

    mPrevRetireFence.TransferToAnotherFenceHandle(mPrevDisplayFence);

    for (uint32_t j=0; j < (mList->numHwLayers - 1); j++) {
        if (mList->hwLayers[j].releaseFenceFd >= 0) {
            int fd = mList->hwLayers[j].releaseFenceFd;
            mList->hwLayers[j].releaseFenceFd = -1;
            nsRefPtr<FenceHandle::FdObj> fdObj = new FenceHandle::FdObj(fd);
            FenceHandle fence(fdObj);

            LayerRenderState state = mHwcLayerMap[j]->GetLayer()->GetRenderState();
            if (!state.mTexture) {
                continue;
            }
            state.mTexture->SetReleaseFenceHandle(fence);
        }
    }

    if (mList->retireFenceFd >= 0) {
        mPrevRetireFence = FenceHandle(new FenceHandle::FdObj(mList->retireFenceFd));
    }

    // Set DisplaySurface layer fence
    DisplaySurface* displaySurface = aScreen->GetDisplaySurface();
    displaySurface->setReleaseFenceFd(mList->hwLayers[mList->numHwLayers - 1].releaseFenceFd);
    mList->hwLayers[mList->numHwLayers - 1].releaseFenceFd = -1;

    mPrepared = false;
    return !err;
}
Ejemplo n.º 6
0
void
Compositor::SetDispAcquireFence(Layer* aLayer)
{
  // OpenGL does not provide ReleaseFence for rendering.
  // Instead use DispAcquireFence as layer buffer's ReleaseFence
  // to prevent flickering and tearing.
  // DispAcquireFence is DisplaySurface's AcquireFence.
  // AcquireFence will be signaled when a buffer's content is available.
  // See Bug 974152.
  if (!aLayer || !mWidget) {
    return;
  }
  nsWindow* window = static_cast<nsWindow*>(mWidget->RealWidget());
  RefPtr<FenceHandle::FdObj> fence = new FenceHandle::FdObj(
      window->GetScreen()->GetPrevDispAcquireFd());
  mReleaseFenceHandle.Merge(FenceHandle(fence));
}
Ejemplo n.º 7
0
void
TextureParent::SendFenceHandleIfPresent()
{
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
  if (mTextureHost) {
    TextureHostOGL* hostOGL = mTextureHost->AsHostOGL();
    if (!hostOGL) {
      return;
    }
    android::sp<android::Fence> fence = hostOGL->GetAndResetReleaseFence();
    if (fence.get() && fence->isValid()) {
      // HWC might not provide Fence.
      // In this case, HWC implicitly handles buffer's fence.

      FenceHandle handle = FenceHandle(fence);
      RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(handle);
      mCompositableManager->SendFenceHandle(tracker, this, handle);
    }
  }
#endif
}
Ejemplo n.º 8
0
bool
LayerTransactionParent::RecvChildAsyncMessages(const InfallibleTArray<AsyncChildMessageData>& aMessages)
{
  for (AsyncChildMessageArray::index_type i = 0; i < aMessages.Length(); ++i) {
    const AsyncChildMessageData& message = aMessages[i];

    switch (message.type()) {
      case AsyncChildMessageData::TOpDeliverFenceFromChild: {
        const OpDeliverFenceFromChild& op = message.get_OpDeliverFenceFromChild();
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
        FenceHandle fence = FenceHandle(op.fence());
        PTextureParent* parent = op.textureParent();

        TextureHostOGL* hostOGL = nullptr;
        RefPtr<TextureHost> texture = TextureHost::AsTextureHost(parent);
        if (texture) {
          hostOGL = texture->AsHostOGL();
        }
        if (hostOGL) {
          hostOGL->SetAcquireFence(fence.mFence);
        }
#endif
        // Send back a response.
        InfallibleTArray<AsyncParentMessageData> replies;
        replies.AppendElement(OpReplyDeliverFence(op.transactionId()));
        mozilla::unused << SendParentAsyncMessages(replies);
        break;
      }
      case AsyncChildMessageData::TOpReplyDeliverFence: {
        const OpReplyDeliverFence& op = message.get_OpReplyDeliverFence();
        TransactionCompleteted(op.transactionId());
        break;
      }
      default:
        NS_ERROR("unknown AsyncChildMessageData type");
        return false;
    }
  }
  return true;
}
Ejemplo n.º 9
0
void
TextureParent::CompositorRecycle()
{
  mTextureHost->ClearRecycleCallback();

  MaybeFenceHandle handle = null_t();
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
  if (mTextureHost) {
    TextureHostOGL* hostOGL = mTextureHost->AsHostOGL();
    android::sp<android::Fence> fence = hostOGL->GetAndResetReleaseFence();
    if (fence.get() && fence->isValid()) {
      handle = FenceHandle(fence);
      // HWC might not provide Fence.
      // In this case, HWC implicitly handles buffer's fence.
    }
  }
#endif
  mozilla::unused << SendCompositorRecycle(handle);

  // Don't forget to prepare for the next reycle
  mWaitForClientRecycle = mTextureHost;
}
Ejemplo n.º 10
0
FenceHandle
Compositor::GetReleaseFence()
{
  return FenceHandle();
}
Ejemplo n.º 11
0
FenceHandle
TextureHost::GetAndResetAcquireFenceHandle()
{
  RefPtr<FenceHandle::FdObj> fdObj = mAcquireFenceHandle.GetAndResetFdObj();
  return FenceHandle(fdObj);
}