void DisplayItemClip::FillIntersectionOfRoundedRectClips(gfxContext* aContext, const Color& aColor, int32_t aAppUnitsPerDevPixel, uint32_t aBegin, uint32_t aEnd) const { DrawTarget& aDrawTarget = *aContext->GetDrawTarget(); aEnd = std::min<uint32_t>(aEnd, mRoundedClipRects.Length()); if (aBegin >= aEnd) { return; } // Push clips for any rects that come BEFORE the rect at |aEnd - 1|, if any: ApplyRoundedRectClipsTo(aContext, aAppUnitsPerDevPixel, aBegin, aEnd - 1); // Now fill the rect at |aEnd - 1|: RefPtr<Path> roundedRect = MakeRoundedRectPath(aDrawTarget, aAppUnitsPerDevPixel, mRoundedClipRects[aEnd - 1]); ColorPattern color(ToDeviceColor(aColor)); aDrawTarget.Fill(roundedRect, color); // Finally, pop any clips that we may have pushed: for (uint32_t i = aBegin; i < aEnd - 1; ++i) { aContext->PopClip(); } }
void ReadbackProcessor::BuildUpdatesForLayer(ReadbackLayer* aLayer) { if (!aLayer->mSink) return; nsIntPoint offset; Layer* newBackground = FindBackgroundLayer(aLayer, &offset); if (!newBackground) { aLayer->SetUnknown(); return; } if (newBackground->GetType() == Layer::TYPE_COLOR) { ColorLayer* colorLayer = static_cast<ColorLayer*>(newBackground); if (aLayer->mBackgroundColor != colorLayer->GetColor()) { aLayer->mBackgroundLayer = nullptr; aLayer->mBackgroundColor = colorLayer->GetColor(); NS_ASSERTION(aLayer->mBackgroundColor.a == 1.f, "Color layer said it was opaque!"); RefPtr<gfxContext> ctx = aLayer->mSink->BeginUpdate(aLayer->GetRect(), aLayer->AllocateSequenceNumber()); if (ctx) { ColorPattern color(ToDeviceColor(aLayer->mBackgroundColor)); IntSize size = aLayer->GetSize(); ctx->GetDrawTarget()->FillRect(Rect(0, 0, size.width, size.height), color); aLayer->mSink->EndUpdate(ctx, aLayer->GetRect()); } } } else { NS_ASSERTION(newBackground->AsPaintedLayer(), "Must be PaintedLayer"); PaintedLayer* paintedLayer = static_cast<PaintedLayer*>(newBackground); // updateRect is relative to the PaintedLayer IntRect updateRect = aLayer->GetRect() - offset; if (paintedLayer != aLayer->mBackgroundLayer || offset != aLayer->mBackgroundLayerOffset) { aLayer->mBackgroundLayer = paintedLayer; aLayer->mBackgroundLayerOffset = offset; aLayer->mBackgroundColor = Color(); paintedLayer->SetUsedForReadback(true); } else { nsIntRegion invalid; invalid.Sub(updateRect, paintedLayer->GetValidRegion()); updateRect = invalid.GetBounds(); } Update update = { aLayer, updateRect, aLayer->AllocateSequenceNumber() }; mAllUpdates.AppendElement(update); } }