no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / gfx / thebes / gfxPattern.h
blobcc8a7d5231ee134122a9ede7e12833c6c5416f9a
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_PATTERN_H
7 #define GFX_PATTERN_H
9 #include "gfxTypes.h"
11 #include "gfxMatrix.h"
12 #include "mozilla/Alignment.h"
13 #include "mozilla/gfx/2D.h"
14 #include "mozilla/gfx/PatternHelpers.h"
15 #include "nsISupportsImpl.h"
16 #include "nsTArray.h"
18 typedef struct _cairo_pattern cairo_pattern_t;
20 class gfxPattern final {
21 NS_INLINE_DECL_REFCOUNTING(gfxPattern)
23 public:
24 explicit gfxPattern(const mozilla::gfx::DeviceColor& aColor);
25 // gradients
26 gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1); // linear
27 gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0, gfxFloat cx1,
28 gfxFloat cy1, gfxFloat radius1); // radial
29 gfxPattern(gfxFloat cx, gfxFloat cy, gfxFloat angle, gfxFloat startOffset,
30 gfxFloat endOffset); // conic
31 gfxPattern(mozilla::gfx::SourceSurface* aSurface,
32 const mozilla::gfx::Matrix& aPatternToUserSpace);
34 void AddColorStop(gfxFloat offset, const mozilla::gfx::DeviceColor& c);
35 void SetColorStops(mozilla::gfx::GradientStops* aStops);
37 // This should only be called on a cairo pattern that we want to use with
38 // Azure. We will read back the color stops from cairo and try to look
39 // them up in the cache.
40 void CacheColorStops(const mozilla::gfx::DrawTarget* aDT);
42 void SetMatrix(const gfxMatrix& matrix);
43 gfxMatrix GetMatrix() const;
44 gfxMatrix GetInverseMatrix() const;
46 /* Get an Azure Pattern for the current Cairo pattern. aPattern transform
47 * specifies the transform that was set on the DrawTarget when the pattern
48 * was set. When this is nullptr it is assumed the transform is identical
49 * to the current transform.
51 mozilla::gfx::Pattern* GetPattern(
52 const mozilla::gfx::DrawTarget* aTarget,
53 const mozilla::gfx::Matrix* aOriginalUserToDevice = nullptr);
54 bool IsOpaque();
56 // clamp, repeat, reflect
57 void SetExtend(mozilla::gfx::ExtendMode aExtend);
59 void SetSamplingFilter(mozilla::gfx::SamplingFilter aSamplingFilter);
60 mozilla::gfx::SamplingFilter SamplingFilter() const;
62 /* returns TRUE if it succeeded */
63 bool GetSolidColor(mozilla::gfx::DeviceColor& aColorOut);
65 private:
66 // Private destructor, to discourage deletion outside of Release():
67 ~gfxPattern() = default;
69 mozilla::gfx::GeneralPattern mGfxPattern;
70 RefPtr<mozilla::gfx::SourceSurface> mSourceSurface;
71 mozilla::gfx::Matrix mPatternToUserSpace;
72 RefPtr<mozilla::gfx::GradientStops> mStops;
73 nsTArray<mozilla::gfx::GradientStop> mStopsList;
74 mozilla::gfx::ExtendMode mExtend;
77 #endif /* GFX_PATTERN_H */