gecko-dev/layout/painting/nsCSSRenderingGradients.h
Daniel Holbert 680815cd6e Bug 1412346 part 5: (automated patch) Switch a bunch of C++ files in layout to use our standard mode lines. r=jfkthame
This patch was generated automatically by the "modeline.py" script, available
here: https://github.com/amccreight/moz-source-tools/blob/master/modeline.py

For every file that is modified in this patch, the changes are as follows:
 (1) The patch changes the file to use the exact C++ mode lines from the
     Mozilla coding style guide, available here:
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Mode_Line

 (2) The patch deletes any blank lines between the mode line & the MPL
     boilerplate comment.

 (3) If the file previously had the mode lines and MPL boilerplate in a
     single contiguous C++ comment, then the patch splits them into
     separate C++ comments, to match the boilerplate in the coding style.

MozReview-Commit-ID: EuRsDue63tK

--HG--
extra : rebase_source : 3356d4b80ff6213935192e87cdbc9103fec6084c
2017-10-27 10:33:53 -07:00

105 lines
3.6 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef nsCSSRenderingGradients_h__
#define nsCSSRenderingGradients_h__
#include "nsLayoutUtils.h"
#include "nsStyleStruct.h"
#include "Units.h"
#include "mozilla/Maybe.h"
#include "mozilla/gfx/2D.h"
namespace mozilla {
namespace layers {
class StackingContextHelper;
} // namespace layers
namespace wr {
class DisplayListBuilder;
} // namespace wr
// A resolved color stop, with a specific position along the gradient line and
// a color.
struct ColorStop {
ColorStop(): mPosition(0), mIsMidpoint(false) {}
ColorStop(double aPosition, bool aIsMidPoint, const gfx::Color& aColor) :
mPosition(aPosition), mIsMidpoint(aIsMidPoint), mColor(aColor) {}
double mPosition; // along the gradient line; 0=start, 1=end
bool mIsMidpoint;
gfx::Color mColor;
};
class nsCSSGradientRenderer final {
public:
/**
* Prepare a nsCSSGradientRenderer for a gradient for an element.
* aIntrinsicSize - the size of the source gradient.
*/
static nsCSSGradientRenderer Create(nsPresContext* aPresContext,
nsStyleGradient* aGradient,
const nsSize& aIntrinsiceSize);
/**
* Draw the gradient to aContext
* aDest - where the first tile of gradient is
* aFill - the area to be filled with tiles of aDest
* aSrc - the area of the gradient that will fill aDest
* aRepeatSize - the distance from the origin of a tile
* to the next origin of a tile
* aDirtyRect - pixels outside of this area may be skipped
*/
void Paint(gfxContext& aContext,
const nsRect& aDest,
const nsRect& aFill,
const nsSize& aRepeatSize,
const mozilla::CSSIntRect& aSrc,
const nsRect& aDirtyRect,
float aOpacity = 1.0);
/**
* Collect the gradient parameters
*/
void BuildWebRenderParameters(float aOpacity,
wr::ExtendMode& aMode,
nsTArray<wr::GradientStop>& aStops,
LayoutDevicePoint& aLineStart,
LayoutDevicePoint& aLineEnd,
LayoutDeviceSize& aGradientRadius);
/**
* Build display items for the gradient
* aLayer - the layer to make this display item relative to
* aDest - where the first tile of gradient is
* aFill - the area to be filled with tiles of aDest
* aRepeatSize - the distance from the origin of a tile
* to the next origin of a tile
* aSrc - the area of the gradient that will fill aDest
*/
void BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuilder,
const layers::StackingContextHelper& aSc,
const nsRect& aDest,
const nsRect& aFill,
const nsSize& aRepeatSize,
const mozilla::CSSIntRect& aSrc,
bool aIsBackfaceVisible,
float aOpacity = 1.0);
private:
nsCSSGradientRenderer() {}
nsPresContext* mPresContext;
nsStyleGradient* mGradient;
nsTArray<ColorStop> mStops;
gfxPoint mLineStart, mLineEnd;
double mRadiusX, mRadiusY;
};
} // namespace mozilla
#endif /* nsCSSRenderingGradients_h__ */