예제 #1
0
void nsBaseWidget::CreateCompositor()
{
  mCompositorThread = new Thread("CompositorThread");
  if (mCompositorThread->Start()) {
    bool renderToEGLSurface = false;
#ifdef MOZ_JAVA_COMPOSITOR
    renderToEGLSurface = true;
#endif
    nsIntRect rect;
    GetBounds(rect);
    mCompositorParent =
      new CompositorParent(this, mCompositorThread->message_loop(), mCompositorThread->thread_id(),
                           renderToEGLSurface, rect.width, rect.height);
    LayerManager* lm = CreateBasicLayerManager();
    MessageLoop *childMessageLoop = mCompositorThread->message_loop();
    mCompositorChild = new CompositorChild(lm);
    AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel();
    AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child;
    mCompositorChild->Open(parentChannel, childMessageLoop, childSide);
    PRInt32 maxTextureSize;
    PLayersChild* shadowManager;
    if (mUseAcceleratedRendering) {
      shadowManager = mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL, &maxTextureSize);
    } else {
      shadowManager = mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_BASIC, &maxTextureSize);
    }

    if (shadowManager) {
      ShadowLayerForwarder* lf = lm->AsShadowForwarder();
      if (!lf) {
        delete lm;
        mCompositorChild = nsnull;
        return;
      }
      lf->SetShadowManager(shadowManager);
      if (mUseAcceleratedRendering)
        lf->SetParentBackendType(LayerManager::LAYERS_OPENGL);
      else
        lf->SetParentBackendType(LayerManager::LAYERS_BASIC);
      lf->SetMaxTextureSize(maxTextureSize);

      mLayerManager = lm;
    } else {
      // We don't currently want to support not having a LayersChild
      NS_RUNTIMEABORT("failed to construct LayersChild");
      delete lm;
      mCompositorChild = nsnull;
    }
  }
}
void nsBaseWidget::CreateCompositor()
{
  mCompositorThread = new Thread("CompositorThread");
  mCompositorParent = new CompositorParent(this, mCompositorThread);
  if (mCompositorThread->Start()) {
    LayerManager* lm = CreateBasicLayerManager();
    MessageLoop *childMessageLoop = mCompositorThread->message_loop();
    mCompositorChild = new CompositorChild(lm);
    AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel();
    AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child;
    mCompositorChild->Open(parentChannel, childMessageLoop, childSide);
    PLayersChild* shadowManager =
      mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL);

    if (shadowManager) {
      ShadowLayerForwarder* lf = lm->AsShadowForwarder();
      if (!lf) {
        delete lm;
        mCompositorChild = nsnull;
        return;
      }
      lf->SetShadowManager(shadowManager);
      lf->SetParentBackendType(LayerManager::LAYERS_OPENGL);

      mLayerManager = lm;
    } else {
      NS_WARNING("fail to construct LayersChild");
      delete lm;
      mCompositorChild = nsnull;
    }
  }
}
예제 #3
0
bool
TabChild::InitWidget(const nsIntSize& size)
{
    NS_ABORT_IF_FALSE(!mWidget && !mRemoteFrame, "CreateWidget twice?");

    mWidget = nsIWidget::CreatePuppetWidget(this);
    if (!mWidget) {
        NS_ERROR("couldn't create fake widget");
        return false;
    }
    mWidget->Create(
        nullptr, 0,              // no parents
        nsIntRect(nsIntPoint(0, 0), size),
        nullptr,                 // HandleWidgetEvent
        nullptr                  // nsDeviceContext
        );

    LayersBackend be;
    uint64_t id;
    int32_t maxTextureSize;
    RenderFrameChild* remoteFrame =
        static_cast<RenderFrameChild*>(SendPRenderFrameConstructor(
                                           &mScrolling, &be, &maxTextureSize, &id));
    if (!remoteFrame) {
      NS_WARNING("failed to construct RenderFrame");
      return false;
    }

    PLayersChild* shadowManager = nullptr;
    if (id != 0) {
        // Pushing layers transactions directly to a separate
        // compositor context.
        shadowManager =
            CompositorChild::Get()->SendPLayersConstructor(be, id,
                                                           &be,
                                                           &maxTextureSize);
    } else {
        // Pushing transactions to the parent content.
        shadowManager = remoteFrame->SendPLayersConstructor();
    }

    if (!shadowManager) {
      NS_WARNING("failed to construct LayersChild");
      // This results in |remoteFrame| being deleted.
      PRenderFrameChild::Send__delete__(remoteFrame);
      return false;
    }

    ShadowLayerForwarder* lf =
        mWidget->GetLayerManager(shadowManager, be)->AsShadowForwarder();
    NS_ABORT_IF_FALSE(lf && lf->HasShadowManager(),
                      "PuppetWidget should have shadow manager");
    lf->SetParentBackendType(be);
    lf->SetMaxTextureSize(maxTextureSize);

    mRemoteFrame = remoteFrame;
    return true;
}
예제 #4
0
bool
TabChild::InitWidget(const nsIntSize& size)
{
    NS_ABORT_IF_FALSE(!mWidget && !mRemoteFrame, "CreateWidget twice?");

    mWidget = nsIWidget::CreatePuppetWidget(this);
    if (!mWidget) {
        NS_ERROR("couldn't create fake widget");
        return false;
    }
    mWidget->Create(
        nsnull, 0,              // no parents
        nsIntRect(nsIntPoint(0, 0), size),
        nsnull,                 // HandleWidgetEvent
        nsnull                  // nsDeviceContext
    );

    RenderFrameChild* remoteFrame =
        static_cast<RenderFrameChild*>(SendPRenderFrameConstructor());
    if (!remoteFrame) {
        NS_WARNING("failed to construct RenderFrame");
        return false;
    }

    NS_ABORT_IF_FALSE(0 == remoteFrame->ManagedPLayersChild().Length(),
                      "shouldn't have a shadow manager yet");
    LayerManager::LayersBackend be;
    PRInt32 maxTextureSize;
    PLayersChild* shadowManager = remoteFrame->SendPLayersConstructor(&be, &maxTextureSize);
    if (!shadowManager) {
        NS_WARNING("failed to construct LayersChild");
        // This results in |remoteFrame| being deleted.
        PRenderFrameChild::Send__delete__(remoteFrame);
        return false;
    }

    ShadowLayerForwarder* lf =
        mWidget->GetLayerManager(shadowManager, be)->AsShadowForwarder();
    NS_ABORT_IF_FALSE(lf && lf->HasShadowManager(),
                      "PuppetWidget should have shadow manager");
    lf->SetParentBackendType(be);
    lf->SetMaxTextureSize(maxTextureSize);

    mRemoteFrame = remoteFrame;
    return true;
}
void nsBaseWidget::CreateCompositor()
{
  bool renderToEGLSurface = false;
#ifdef MOZ_ANDROID_OMTC
  renderToEGLSurface = true;
#endif
  nsIntRect rect;
  GetBounds(rect);
  mCompositorParent =
    new CompositorParent(this, renderToEGLSurface, rect.width, rect.height);
  LayerManager* lm = CreateBasicLayerManager();
  MessageLoop *childMessageLoop = CompositorParent::CompositorLoop();
  mCompositorChild = new CompositorChild(lm);
  AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel();
  AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child;
  mCompositorChild->Open(parentChannel, childMessageLoop, childSide);
  int32_t maxTextureSize;
  PLayersChild* shadowManager;
  mozilla::layers::LayersBackend backendHint =
    mUseLayersAcceleration ? mozilla::layers::LAYERS_OPENGL : mozilla::layers::LAYERS_BASIC;
  mozilla::layers::LayersBackend parentBackend;
  shadowManager = mCompositorChild->SendPLayersConstructor(
    backendHint, 0, &parentBackend, &maxTextureSize);

  if (shadowManager) {
    ShadowLayerForwarder* lf = lm->AsShadowForwarder();
    if (!lf) {
      delete lm;
      mCompositorChild = nullptr;
      return;
    }
    lf->SetShadowManager(shadowManager);
    lf->SetParentBackendType(parentBackend);
    lf->SetMaxTextureSize(maxTextureSize);

    mLayerManager = lm;
  } else {
    // We don't currently want to support not having a LayersChild
    NS_RUNTIMEABORT("failed to construct LayersChild");
    delete lm;
    mCompositorChild = nullptr;
  }
}
예제 #6
0
void nsBaseWidget::CreateCompositor()
{
  mCompositorThread = new Thread("CompositorThread");
  if (mCompositorThread->Start()) {
    bool renderToEGLSurface = false;
#ifdef MOZ_JAVA_COMPOSITOR
    renderToEGLSurface = true;
#endif
    nsIntRect rect;
    GetBounds(rect);
    mCompositorParent =
      new CompositorParent(this, mCompositorThread->message_loop(), mCompositorThread->thread_id(),
                           renderToEGLSurface, rect.width, rect.height);
    LayerManager* lm = CreateBasicLayerManager();
    MessageLoop *childMessageLoop = mCompositorThread->message_loop();
    mCompositorChild = new CompositorChild(lm);
    AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel();
    AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child;
    mCompositorChild->Open(parentChannel, childMessageLoop, childSide);
    PLayersChild* shadowManager =
      mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL);

    if (shadowManager) {
      ShadowLayerForwarder* lf = lm->AsShadowForwarder();
      if (!lf) {
        delete lm;
        mCompositorChild = nsnull;
        return;
      }
      lf->SetShadowManager(shadowManager);
      lf->SetParentBackendType(LayerManager::LAYERS_OPENGL);

      mLayerManager = lm;
    } else {
      NS_WARNING("fail to construct LayersChild");
      delete lm;
      mCompositorChild = nsnull;
    }
  }
}