2018-11-30 19:52:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2005-04-06 01:54:26 +00:00
|
|
|
|
2005-04-11 04:36:18 +00:00
|
|
|
#ifndef GFX_PATTERN_H
|
|
|
|
#define GFX_PATTERN_H
|
2005-04-06 01:54:26 +00:00
|
|
|
|
2007-01-27 01:26:49 +00:00
|
|
|
#include "gfxTypes.h"
|
2005-04-06 01:54:26 +00:00
|
|
|
|
|
|
|
#include "gfxMatrix.h"
|
2013-08-14 07:00:52 +00:00
|
|
|
#include "mozilla/Alignment.h"
|
2012-01-05 07:17:51 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-09-29 13:12:06 +00:00
|
|
|
#include "mozilla/gfx/PatternHelpers.h"
|
2013-10-07 23:15:59 +00:00
|
|
|
#include "nsISupportsImpl.h"
|
2013-11-08 04:50:39 +00:00
|
|
|
#include "nsTArray.h"
|
2005-04-06 01:54:26 +00:00
|
|
|
|
2007-01-27 01:26:49 +00:00
|
|
|
typedef struct _cairo_pattern cairo_pattern_t;
|
2006-01-18 22:43:42 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class gfxPattern final {
|
2010-04-01 18:05:40 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(gfxPattern)
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2005-04-06 01:54:26 +00:00
|
|
|
public:
|
2019-05-01 08:47:10 +00:00
|
|
|
explicit gfxPattern(const mozilla::gfx::Color& aColor);
|
2005-04-06 01:54:26 +00:00
|
|
|
// linear
|
2007-01-27 01:26:49 +00:00
|
|
|
gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1); // linear
|
2005-04-08 05:44:32 +00:00
|
|
|
gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0, gfxFloat cx1,
|
2007-01-27 01:26:49 +00:00
|
|
|
gfxFloat cy1, gfxFloat radius1); // radial
|
2019-05-01 08:47:10 +00:00
|
|
|
gfxPattern(mozilla::gfx::SourceSurface* aSurface,
|
|
|
|
const mozilla::gfx::Matrix& aPatternToUserSpace);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
void AddColorStop(gfxFloat offset, const mozilla::gfx::Color& c);
|
|
|
|
void SetColorStops(mozilla::gfx::GradientStops* aStops);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2013-11-08 04:50:39 +00:00
|
|
|
// This should only be called on a cairo pattern that we want to use with
|
|
|
|
// Azure. We will read back the color stops from cairo and try to look
|
|
|
|
// them up in the cache.
|
2019-05-01 08:47:10 +00:00
|
|
|
void CacheColorStops(const mozilla::gfx::DrawTarget* aDT);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
void SetMatrix(const gfxMatrix& matrix);
|
2007-03-03 00:18:34 +00:00
|
|
|
gfxMatrix GetMatrix() const;
|
2013-06-21 18:55:24 +00:00
|
|
|
gfxMatrix GetInverseMatrix() const;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-03-29 18:53:43 +00:00
|
|
|
/* Get an Azure Pattern for the current Cairo pattern. aPattern transform
|
|
|
|
* specifies the transform that was set on the DrawTarget when the pattern
|
2013-07-31 15:44:31 +00:00
|
|
|
* was set. When this is nullptr it is assumed the transform is identical
|
2012-03-29 18:53:43 +00:00
|
|
|
* to the current transform.
|
|
|
|
*/
|
2019-05-01 08:47:10 +00:00
|
|
|
mozilla::gfx::Pattern* GetPattern(
|
|
|
|
const mozilla::gfx::DrawTarget* aTarget,
|
|
|
|
const mozilla::gfx::Matrix* aOriginalUserToDevice = nullptr);
|
2012-01-05 07:17:51 +00:00
|
|
|
bool IsOpaque();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2015-09-25 07:58:23 +00:00
|
|
|
// clamp, repeat, reflect
|
|
|
|
void SetExtend(mozilla::gfx::ExtendMode aExtend);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-05-25 16:01:18 +00:00
|
|
|
void SetSamplingFilter(mozilla::gfx::SamplingFilter aSamplingFilter);
|
|
|
|
mozilla::gfx::SamplingFilter SamplingFilter() const;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2006-08-09 20:25:07 +00:00
|
|
|
/* returns TRUE if it succeeded */
|
2019-05-01 08:47:10 +00:00
|
|
|
bool GetSolidColor(mozilla::gfx::Color& aColorOut);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2014-04-04 16:27:02 +00:00
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2014-09-29 13:12:06 +00:00
|
|
|
~gfxPattern() {}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2014-09-29 13:12:06 +00:00
|
|
|
mozilla::gfx::GeneralPattern mGfxPattern;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<mozilla::gfx::SourceSurface> mSourceSurface;
|
2014-09-15 15:24:03 +00:00
|
|
|
mozilla::gfx::Matrix mPatternToUserSpace;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<mozilla::gfx::GradientStops> mStops;
|
2014-09-14 09:58:56 +00:00
|
|
|
nsTArray<mozilla::gfx::GradientStop> mStopsList;
|
2015-09-25 07:58:23 +00:00
|
|
|
mozilla::gfx::ExtendMode mExtend;
|
2005-04-06 01:54:26 +00:00
|
|
|
};
|
|
|
|
|
2005-04-11 04:36:18 +00:00
|
|
|
#endif /* GFX_PATTERN_H */
|