1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef LAYOUT_SVG_SVGPAINTSERVERFRAME_H_
8 #define LAYOUT_SVG_SVGPAINTSERVERFRAME_H_
11 #include "mozilla/Attributes.h"
12 #include "mozilla/SVGContainerFrame.h"
16 #include "nsQueryFrame.h"
27 * RAII class used to temporarily set and remove the
28 * NS_FRAME_DRAWING_AS_PAINTSERVER frame state bit while a frame is being
29 * drawn as a paint server.
31 class MOZ_RAII AutoSetRestorePaintServerState
{
33 explicit AutoSetRestorePaintServerState(nsIFrame
* aFrame
) : mFrame(aFrame
) {
34 mFrame
->AddStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER
);
36 ~AutoSetRestorePaintServerState() {
37 mFrame
->RemoveStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER
);
44 class SVGPaintServerFrame
: public SVGContainerFrame
{
46 using DrawTarget
= gfx::DrawTarget
;
48 SVGPaintServerFrame(ComputedStyle
* aStyle
, nsPresContext
* aPresContext
,
50 : SVGContainerFrame(aStyle
, aPresContext
, aID
) {
51 AddStateBits(NS_FRAME_IS_NONDISPLAY
);
55 using imgDrawingParams
= image::imgDrawingParams
;
57 NS_DECL_ABSTRACT_FRAME(SVGPaintServerFrame
)
59 NS_DECL_QUERYFRAME_TARGET(SVGPaintServerFrame
)
62 * Constructs a gfxPattern of the paint server rendering.
64 * @param aContextMatrix The transform matrix that is currently applied to
65 * the gfxContext that is being drawn to. This is needed by SVG patterns so
66 * that surfaces of the correct size can be created. (SVG gradients are
67 * vector based, so it's not used there.)
69 virtual already_AddRefed
<gfxPattern
> GetPaintServerPattern(
70 nsIFrame
* aSource
, const DrawTarget
* aDrawTarget
,
71 const gfxMatrix
& aContextMatrix
, StyleSVGPaint
nsStyleSVG::*aFillOrStroke
,
72 float aOpacity
, imgDrawingParams
& aImgParams
,
73 const gfxRect
* aOverrideBounds
= nullptr) = 0;
76 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
77 const nsDisplayListSet
& aLists
) override
{}
80 } // namespace mozilla
82 #endif // LAYOUT_SVG_SVGPAINTSERVERFRAME_H_