コード例 #1
0
void
LayerManagerD3D9::Render()
{
  if (mSwapChain->PrepareForRendering() != DeviceOK) {
    return;
  }

  deviceManager()->SetupRenderState();

  SetupPipeline();

  if (CompositingDisabled()) {
    static_cast<LayerD3D9*>(mRoot->ImplData())->RenderLayer();
    return;
  }

  nsIntRect rect;
  mWidget->GetClientBounds(rect);

  device()->Clear(0, nullptr, D3DCLEAR_TARGET, 0x00000000, 0, 0);

  device()->BeginScene();

  const nsIntRect *clipRect = mRoot->GetClipRect();
  RECT r;
  if (clipRect) {
    r.left = (LONG)clipRect->x;
    r.top = (LONG)clipRect->y;
    r.right = (LONG)(clipRect->x + clipRect->width);
    r.bottom = (LONG)(clipRect->y + clipRect->height);
  } else {
    r.left = r.top = 0;
    r.right = rect.width;
    r.bottom = rect.height;
  }
  device()->SetScissorRect(&r);

  static_cast<LayerD3D9*>(mRoot->ImplData())->RenderLayer();

  device()->EndScene();

  if (!mTarget) {
    const nsIntRect *r;
    for (nsIntRegionRectIterator iter(mClippingRegion);
         (r = iter.Next()) != nullptr;) {
      mSwapChain->Present(*r);
    }
    RecordFrame();
    PostPresent();
  } else {
    PaintToTarget();
  }
}
コード例 #2
0
void
CompositorD3D11::EndFrame()
{
  nsIntSize oldSize = mSize;
  EnsureSize();
  UINT presentInterval = 0;

  if (gfxWindowsPlatform::GetPlatform()->IsWARP()) {
    // When we're using WARP we cannot present immediately as it causes us
    // to tear when rendering. When not using WARP it appears the DWM takes
    // care of tearing for us.
    presentInterval = 1;
  }

  if (oldSize == mSize) {
    RefPtr<IDXGISwapChain1> chain;
    HRESULT hr = mSwapChain->QueryInterface((IDXGISwapChain1**)byRef(chain));
    if (SUCCEEDED(hr) && chain) {
      DXGI_PRESENT_PARAMETERS params;
      PodZero(&params);
      params.DirtyRectsCount = mInvalidRegion.GetNumRects();
      std::vector<RECT> rects;
      rects.reserve(params.DirtyRectsCount);

      nsIntRegionRectIterator iter(mInvalidRegion);
      const nsIntRect* r;
      uint32_t i = 0;
      while ((r = iter.Next()) != nullptr) {
        RECT rect;
        rect.left = r->x;
        rect.top = r->y;
        rect.bottom = r->YMost();
        rect.right = r->XMost();

        rects.push_back(rect);
      }

      params.pDirtyRects = &rects.front();
      chain->Present1(presentInterval, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0, &params);
    } else {
      mSwapChain->Present(presentInterval, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0);
    }
    mDisableSequenceForNextFrame = false;
    if (mTarget) {
      PaintToTarget();
    }
  }

  mCurrentRT = nullptr;
}
コード例 #3
0
ファイル: CompositorD3D11.cpp プロジェクト: msliu/gecko-dev
void
CompositorD3D11::EndFrame()
{
  mContext->Flush();

  nsIntSize oldSize = mSize;
  EnsureSize();
  if (oldSize == mSize) {
    mSwapChain->Present(0, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0);
    mDisableSequenceForNextFrame = false;
    if (mTarget) {
      PaintToTarget();
    }
  }

  mCurrentRT = nullptr;
}
コード例 #4
0
void
CompositorD3D11::EndFrame()
{
  mContext->Flush();

  nsIntSize oldSize = mSize;
  EnsureSize();
  if (oldSize == mSize) {
    mSwapChain->Present(0, 0);

    if (mTarget) {
      PaintToTarget();
    }
  }

  mCurrentRT = nullptr;
}
コード例 #5
0
void
CompositorD3D9::EndFrame()
{
  device()->EndScene();

  nsIntSize oldSize = mSize;
  EnsureSize();
  if (oldSize == mSize) {
    if (mTarget) {
      PaintToTarget();
    } else {
      mSwapChain->Present();
    }
  }

  mCurrentRT = nullptr;
}
コード例 #6
0
void
LayerManagerD3D10::Render()
{
  static_cast<LayerD3D10*>(mRoot->ImplData())->Validate();

  SetupPipeline();

  float black[] = { 0, 0, 0, 0 };
  device()->ClearRenderTargetView(mRTView, black);

  nsIntRect rect;
  mWidget->GetClientBounds(rect);

  const nsIntRect *clipRect = mRoot->GetClipRect();
  D3D10_RECT r;
  if (clipRect) {
    r.left = (LONG)clipRect->x;
    r.top = (LONG)clipRect->y;
    r.right = (LONG)(clipRect->x + clipRect->width);
    r.bottom = (LONG)(clipRect->y + clipRect->height);
  } else {
    r.left = r.top = 0;
    r.right = rect.width;
    r.bottom = rect.height;
  }
  device()->RSSetScissorRects(1, &r);

  static_cast<LayerD3D10*>(mRoot->ImplData())->RenderLayer();

  if (mTarget) {
    PaintToTarget();
  } else if (mBackBuffer) {
    ShadowLayerForwarder::BeginTransaction();
    
    nsIntRect contentRect = nsIntRect(0, 0, rect.width, rect.height);
    if (!mRootForShadowTree) {
        mRootForShadowTree = new DummyRoot(this);
        mRootForShadowTree->SetShadow(ConstructShadowFor(mRootForShadowTree));
        CreatedContainerLayer(mRootForShadowTree);
        ShadowLayerForwarder::SetRoot(mRootForShadowTree);
    }

    nsRefPtr<WindowLayer> windowLayer =
        static_cast<WindowLayer*>(mRootForShadowTree->GetFirstChild());
    if (!windowLayer) {
        windowLayer = new WindowLayer(this);
        windowLayer->SetShadow(ConstructShadowFor(windowLayer));
        CreatedThebesLayer(windowLayer);
        mRootForShadowTree->InsertAfter(windowLayer, nsnull);
        ShadowLayerForwarder::InsertAfter(mRootForShadowTree, windowLayer);
    }

    if (!mRootForShadowTree->GetVisibleRegion().IsEqual(contentRect)) {
        mRootForShadowTree->SetVisibleRegion(contentRect);
        windowLayer->SetVisibleRegion(contentRect);

        ShadowLayerForwarder::Mutated(mRootForShadowTree);
        ShadowLayerForwarder::Mutated(windowLayer);
    }

    FrameMetrics m;
    if (ContainerLayer* cl = mRoot->AsContainerLayer()) {
        m = cl->GetFrameMetrics();
    } else {
        m.mScrollId = FrameMetrics::ROOT_SCROLL_ID;
    }
    if (m != mRootForShadowTree->GetFrameMetrics()) {
        mRootForShadowTree->SetFrameMetrics(m);
        ShadowLayerForwarder::Mutated(mRootForShadowTree);
    }

    SurfaceDescriptorD3D10 sd;
    GetDescriptor(mBackBuffer, &sd);
    ShadowLayerForwarder::PaintedThebesBuffer(windowLayer,
                                              contentRect,
                                              contentRect, nsIntPoint(),
                                              sd);

    // A source in the graphics pipeline can't also be a target.  So
    // unbind here to avoid racing with the chrome process sourcing
    // the back texture.
    mDevice->OMSetRenderTargets(0, NULL, NULL);

    // XXX revisit this Flush() in bug 662109.  It's not clear it's
    // needed.
    mDevice->Flush();

    mRTView = NULL;

    AutoInfallibleTArray<EditReply, 10> replies;
    ShadowLayerForwarder::EndTransaction(&replies);
    // We expect only 1 reply, but might get none if the parent
    // process crashed

    swap(mBackBuffer, mRemoteFrontBuffer);
  } else {
    mSwapChain->Present(0, 0);
  }
}