Commit 7288d777 authored by Jeff Muizelaar's avatar Jeff Muizelaar
Browse files

Bug 1272778. Use IntRects for clip rects instead of Rects. r=mstange

Previously, we took an IntRect converted to Rect and then later wanted
ints in the backend. This avoids all of that.
parent 73f2ed80
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ Compositor::ShouldDrawDiagnostics(DiagnosticFlags aFlags)
void
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
                            const nsIntRegion& aVisibleRegion,
                            const gfx::Rect& aClipRect,
                            const gfx::IntRect& aClipRect,
                            const gfx::Matrix4x4& aTransform,
                            uint32_t aFlashCounter)
{
@@ -72,7 +72,7 @@ Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
void
Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
                            const gfx::Rect& aVisibleRect,
                            const gfx::Rect& aClipRect,
                            const gfx::IntRect& aClipRect,
                            const gfx::Matrix4x4& aTransform,
                            uint32_t aFlashCounter)
{
@@ -87,7 +87,7 @@ Compositor::DrawDiagnostics(DiagnosticFlags aFlags,
void
Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,
                                    const gfx::Rect& aVisibleRect,
                                    const gfx::Rect& aClipRect,
                                    const gfx::IntRect& aClipRect,
                                    const gfx::Matrix4x4& aTransform,
                                    uint32_t aFlashCounter)
{
@@ -145,7 +145,7 @@ Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,

void
Compositor::SlowDrawRect(const gfx::Rect& aRect, const gfx::Color& aColor,
                     const gfx::Rect& aClipRect,
                     const gfx::IntRect& aClipRect,
                     const gfx::Matrix4x4& aTransform, int aStrokeWidth)
{
  // TODO This should draw a rect using a single draw call but since
@@ -178,7 +178,7 @@ Compositor::SlowDrawRect(const gfx::Rect& aRect, const gfx::Color& aColor,

void
Compositor::FillRect(const gfx::Rect& aRect, const gfx::Color& aColor,
                     const gfx::Rect& aClipRect,
                     const gfx::IntRect& aClipRect,
                     const gfx::Matrix4x4& aTransform)
{
  float opacity = 1.0f;
@@ -356,7 +356,7 @@ DecomposeIntoNoRepeatRects(const gfx::Rect& aRect,

gfx::IntRect
Compositor::ComputeBackdropCopyRect(const gfx::Rect& aRect,
                                    const gfx::Rect& aClipRect,
                                    const gfx::IntRect& aClipRect,
                                    const gfx::Matrix4x4& aTransform,
                                    gfx::Matrix4x4* aOutTransform,
                                    gfx::Rect* aOutLayerQuad)
@@ -365,7 +365,7 @@ Compositor::ComputeBackdropCopyRect(const gfx::Rect& aRect,
  gfx::IntPoint rtOffset = GetCurrentRenderTarget()->GetOrigin();
  gfx::IntSize rtSize = GetCurrentRenderTarget()->GetSize();

  gfx::Rect renderBounds(0, 0, rtSize.width, rtSize.height);
  gfx::IntRect renderBounds(0, 0, rtSize.width, rtSize.height);
  renderBounds.IntersectRect(renderBounds, aClipRect);
  renderBounds.MoveBy(rtOffset);

+12 −12
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ public:
   * aVisibleRect is used to determine which edges should be antialiased,
   * without applying the effect to the inner edges of a tiled layer.
   */
  virtual void DrawQuad(const gfx::Rect& aRect, const gfx::Rect& aClipRect,
  virtual void DrawQuad(const gfx::Rect& aRect, const gfx::IntRect& aClipRect,
                        const EffectChain& aEffectChain,
                        gfx::Float aOpacity, const gfx::Matrix4x4& aTransform,
                        const gfx::Rect& aVisibleRect) = 0;
@@ -329,7 +329,7 @@ public:
   * Use this when you are drawing a single quad that is not part of a tiled
   * layer.
   */
  void DrawQuad(const gfx::Rect& aRect, const gfx::Rect& aClipRect,
  void DrawQuad(const gfx::Rect& aRect, const gfx::IntRect& aClipRect,
                        const EffectChain& aEffectChain,
                        gfx::Float aOpacity, const gfx::Matrix4x4& aTransform) {
      DrawQuad(aRect, aClipRect, aEffectChain, aOpacity, aTransform, aRect);
@@ -339,7 +339,7 @@ public:
   * Draw an unfilled solid color rect. Typically used for debugging overlays.
   */
  void SlowDrawRect(const gfx::Rect& aRect, const gfx::Color& color,
                const gfx::Rect& aClipRect = gfx::Rect(),
                const gfx::IntRect& aClipRect = gfx::IntRect(),
                const gfx::Matrix4x4& aTransform = gfx::Matrix4x4(),
                int aStrokeWidth = 1);

@@ -347,7 +347,7 @@ public:
   * Draw a solid color filled rect. This is a simple DrawQuad helper.
   */
  void FillRect(const gfx::Rect& aRect, const gfx::Color& color,
                    const gfx::Rect& aClipRect = gfx::Rect(),
                    const gfx::IntRect& aClipRect = gfx::IntRect(),
                    const gfx::Matrix4x4& aTransform = gfx::Matrix4x4());

  /*
@@ -378,11 +378,11 @@ public:
   * opaque content.
   */
  virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
                          const gfx::Rect* aClipRectIn,
                          const gfx::Rect& aRenderBounds,
                          const gfx::IntRect* aClipRectIn,
                          const gfx::IntRect& aRenderBounds,
                          const nsIntRegion& aOpaqueRegion,
                          gfx::Rect* aClipRectOut = nullptr,
                          gfx::Rect* aRenderBoundsOut = nullptr) = 0;
                          gfx::IntRect* aClipRectOut = nullptr,
                          gfx::IntRect* aRenderBoundsOut = nullptr) = 0;

  /**
   * Flush the current frame to the screen and tidy up.
@@ -417,13 +417,13 @@ public:

  void DrawDiagnostics(DiagnosticFlags aFlags,
                       const gfx::Rect& visibleRect,
                       const gfx::Rect& aClipRect,
                       const gfx::IntRect& aClipRect,
                       const gfx::Matrix4x4& transform,
                       uint32_t aFlashCounter = DIAGNOSTIC_FLASH_COUNTER_MAX);

  void DrawDiagnostics(DiagnosticFlags aFlags,
                       const nsIntRegion& visibleRegion,
                       const gfx::Rect& aClipRect,
                       const gfx::IntRect& aClipRect,
                       const gfx::Matrix4x4& transform,
                       uint32_t aFlashCounter = DIAGNOSTIC_FLASH_COUNTER_MAX);

@@ -540,7 +540,7 @@ public:
protected:
  void DrawDiagnosticsInternal(DiagnosticFlags aFlags,
                               const gfx::Rect& aVisibleRect,
                               const gfx::Rect& aClipRect,
                               const gfx::IntRect& aClipRect,
                               const gfx::Matrix4x4& transform,
                               uint32_t aFlashCounter);

@@ -556,7 +556,7 @@ protected:
   */
  gfx::IntRect ComputeBackdropCopyRect(
    const gfx::Rect& aRect,
    const gfx::Rect& aClipRect,
    const gfx::IntRect& aClipRect,
    const gfx::Matrix4x4& aTransform,
    gfx::Matrix4x4* aOutTransform,
    gfx::Rect* aOutLayerQuad = nullptr);
+10 −10
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ SetupMask(const EffectChain& aEffectChain,

void
BasicCompositor::DrawQuad(const gfx::Rect& aRect,
                          const gfx::Rect& aClipRect,
                          const gfx::IntRect& aClipRect,
                          const EffectChain &aEffectChain,
                          gfx::Float aOpacity,
                          const gfx::Matrix4x4& aTransform,
@@ -323,7 +323,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
    new3DTransform.PreTranslate(aRect.x, aRect.y, 0);
  }

  buffer->PushClipRect(aClipRect);
  buffer->PushClipRect(Rect(aClipRect));

  newTransform.PostTranslate(-offset.x, -offset.y);
  buffer->SetTransform(newTransform);
@@ -475,14 +475,14 @@ BasicCompositor::ClearRect(const gfx::Rect& aRect)

void
BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
                            const gfx::Rect *aClipRectIn,
                            const gfx::Rect& aRenderBounds,
                            const gfx::IntRect *aClipRectIn,
                            const gfx::IntRect& aRenderBounds,
                            const nsIntRegion& aOpaqueRegion,
                            gfx::Rect *aClipRectOut /* = nullptr */,
                            gfx::Rect *aRenderBoundsOut /* = nullptr */)
                            gfx::IntRect *aClipRectOut /* = nullptr */,
                            gfx::IntRect *aRenderBoundsOut /* = nullptr */)
{
  LayoutDeviceIntRect intRect(LayoutDeviceIntPoint(), mWidget->GetClientSize());
  Rect rect = Rect(0, 0, intRect.width, intRect.height);
  IntRect rect = IntRect(0, 0, intRect.width, intRect.height);

  LayoutDeviceIntRegion invalidRegionSafe;
  if (mDidExternalComposition) {
@@ -500,7 +500,7 @@ BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
  mInvalidRect = mInvalidRegion.GetBounds();

  if (aRenderBoundsOut) {
    *aRenderBoundsOut = Rect();
    *aRenderBoundsOut = IntRect();
  }

  BufferMode bufferMode = BufferMode::BUFFERED;
@@ -560,9 +560,9 @@ BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
  }

  if (aClipRectIn) {
    mRenderTarget->mDrawTarget->PushClipRect(*aClipRectIn);
    mRenderTarget->mDrawTarget->PushClipRect(Rect(*aClipRectIn));
  } else {
    mRenderTarget->mDrawTarget->PushClipRect(rect);
    mRenderTarget->mDrawTarget->PushClipRect(Rect(rect));
    if (aClipRectOut) {
      *aClipRectOut = rect;
    }
+5 −5
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ public:
  }

  virtual void DrawQuad(const gfx::Rect& aRect,
                        const gfx::Rect& aClipRect,
                        const gfx::IntRect& aClipRect,
                        const EffectChain &aEffectChain,
                        gfx::Float aOpacity,
                        const gfx::Matrix4x4& aTransform,
@@ -100,11 +100,11 @@ public:
  virtual void ClearRect(const gfx::Rect& aRect) override;

  virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
                          const gfx::Rect *aClipRectIn,
                          const gfx::Rect& aRenderBounds,
                          const gfx::IntRect *aClipRectIn,
                          const gfx::IntRect& aRenderBounds,
                          const nsIntRegion& aOpaqueRegion,
                          gfx::Rect *aClipRectOut = nullptr,
                          gfx::Rect *aRenderBoundsOut = nullptr) override;
                          gfx::IntRect *aClipRectOut = nullptr,
                          gfx::IntRect *aRenderBoundsOut = nullptr) override;
  virtual void EndFrame() override;
  virtual void EndFrameForExternalComposition(const gfx::Matrix& aTransform) override;

+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ CanvasLayerComposite::RenderLayer(const IntRect& aClipRect)
#endif

  RenderWithAllMasks(this, mCompositor, aClipRect,
                     [&](EffectChain& effectChain, const Rect& clipRect) {
                     [&](EffectChain& effectChain, const IntRect& clipRect) {
    mCompositableHost->Composite(this, effectChain,
                          GetEffectiveOpacity(),
                          GetEffectiveTransform(),
Loading