fune/gfx/layers/wr/WebRenderColorLayer.cpp
Kartikaya Gupta 1dd42d38a4 Bug 1359842 - Add a StackingContextHelper to reduce duplicated code. r=nical
This class is a RAII class that can be used to push a stacking context
with properties from a WebRenderLayer. It can also then be used to
convert rects in the layer coordinate system to be relative to the
stacking context, which is what we want for passing to WR.

MozReview-Commit-ID: 1WVrfRYqLqc
2017-04-27 12:04:25 -04:00

38 lines
1.1 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebRenderColorLayer.h"
#include "gfxPrefs.h"
#include "LayersLogging.h"
#include "mozilla/webrender/webrender_ffi.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/layers/StackingContextHelper.h"
#include "mozilla/layers/WebRenderBridgeChild.h"
namespace mozilla {
namespace layers {
using namespace mozilla::gfx;
void
WebRenderColorLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
{
StackingContextHelper sc(aBuilder, this);
LayerRect rect = Bounds();
DumpLayerInfo("ColorLayer", rect);
LayerRect clipRect = ClipRect().valueOr(rect);
Maybe<WrImageMask> mask = BuildWrMaskLayer(true);
WrClipRegion clip = aBuilder.BuildClipRegion(
sc.ToRelativeWrRect(clipRect),
mask.ptrOr(nullptr));
aBuilder.PushRect(sc.ToRelativeWrRect(rect), clip, wr::ToWrColor(mColor));
}
} // namespace layers
} // namespace mozilla