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