2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef GFX_PATTERN_H
|
|
|
|
#define GFX_PATTERN_H
|
|
|
|
|
|
|
|
#include "gfxTypes.h"
|
|
|
|
|
|
|
|
#include "gfxMatrix.h"
|
2013-08-14 00:00:52 -07:00
|
|
|
#include "mozilla/Alignment.h"
|
2012-01-04 23:17:51 -08:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-09-29 06:12:06 -07:00
|
|
|
#include "mozilla/gfx/PatternHelpers.h"
|
2013-10-01 14:01:19 -07:00
|
|
|
#include "GraphicsFilter.h"
|
2013-10-07 16:15:59 -07:00
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-11-07 20:50:39 -08:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class gfxContext;
|
|
|
|
class gfxASurface;
|
2013-10-07 16:15:59 -07:00
|
|
|
struct gfxRGBA;
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef struct _cairo_pattern cairo_pattern_t;
|
|
|
|
|
|
|
|
|
2014-04-04 09:27:02 -07:00
|
|
|
class gfxPattern MOZ_FINAL{
|
2010-04-01 11:05:40 -07:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(gfxPattern)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
public:
|
2014-08-05 14:58:40 -07:00
|
|
|
explicit gfxPattern(const gfxRGBA& aColor);
|
2007-03-22 10:30:00 -07:00
|
|
|
// linear
|
|
|
|
gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1); // linear
|
|
|
|
gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0,
|
|
|
|
gfxFloat cx1, gfxFloat cy1, gfxFloat radius1); // radial
|
2012-01-04 23:17:51 -08:00
|
|
|
gfxPattern(mozilla::gfx::SourceSurface *aSurface,
|
2014-09-15 08:24:03 -07:00
|
|
|
const mozilla::gfx::Matrix &aPatternToUserSpace);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void AddColorStop(gfxFloat offset, const gfxRGBA& c);
|
2014-06-12 12:24:05 -07:00
|
|
|
void SetColorStops(mozilla::gfx::GradientStops* aStops);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-11-07 20:50:39 -08: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 06:15:19 -07:00
|
|
|
void CacheColorStops(const mozilla::gfx::DrawTarget *aDT);
|
2013-11-07 20:50:39 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void SetMatrix(const gfxMatrix& matrix);
|
|
|
|
gfxMatrix GetMatrix() const;
|
2013-06-21 11:55:24 -07:00
|
|
|
gfxMatrix GetInverseMatrix() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-29 11:53:43 -07: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 08:44:31 -07:00
|
|
|
* was set. When this is nullptr it is assumed the transform is identical
|
2012-03-29 11:53:43 -07:00
|
|
|
* to the current transform.
|
|
|
|
*/
|
2014-09-29 06:26:15 -07:00
|
|
|
mozilla::gfx::Pattern *GetPattern(const mozilla::gfx::DrawTarget *aTarget,
|
2014-09-15 08:24:03 -07:00
|
|
|
mozilla::gfx::Matrix *aOriginalUserToDevice = nullptr);
|
2012-01-04 23:17:51 -08:00
|
|
|
bool IsOpaque();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
enum GraphicsExtend {
|
|
|
|
EXTEND_NONE,
|
|
|
|
EXTEND_REPEAT,
|
|
|
|
EXTEND_REFLECT,
|
2008-09-25 12:49:55 -07:00
|
|
|
EXTEND_PAD,
|
|
|
|
|
|
|
|
// Our own private flag for setting either NONE or PAD,
|
|
|
|
// depending on what the platform does for NONE. This is only
|
|
|
|
// relevant for surface patterns; for all other patterns, it
|
|
|
|
// behaves identical to PAD. On MacOS X, this becomes "NONE",
|
|
|
|
// because Quartz does the thing that we want at image edges;
|
|
|
|
// similarily on the win32 printing surface, since
|
|
|
|
// everything's done with GDI there. On other platforms, it
|
|
|
|
// usually becomes PAD.
|
|
|
|
EXTEND_PAD_EDGE = 1000
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// none, repeat, reflect
|
|
|
|
void SetExtend(GraphicsExtend extend);
|
|
|
|
GraphicsExtend Extend() const;
|
|
|
|
|
2008-03-05 22:51:13 -08:00
|
|
|
enum GraphicsPatternType {
|
|
|
|
PATTERN_SOLID,
|
|
|
|
PATTERN_SURFACE,
|
|
|
|
PATTERN_LINEAR,
|
|
|
|
PATTERN_RADIAL
|
|
|
|
};
|
|
|
|
|
|
|
|
GraphicsPatternType GetType() const;
|
|
|
|
|
|
|
|
int CairoStatus();
|
|
|
|
|
2009-03-21 08:36:38 -07:00
|
|
|
void SetFilter(GraphicsFilter filter);
|
|
|
|
GraphicsFilter Filter() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* returns TRUE if it succeeded */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetSolidColor(gfxRGBA& aColor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-04-04 09:27:02 -07:00
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2014-09-29 06:12:06 -07:00
|
|
|
~gfxPattern() {}
|
2012-01-04 23:17:51 -08:00
|
|
|
|
2014-09-29 06:12:06 -07:00
|
|
|
mozilla::gfx::GeneralPattern mGfxPattern;
|
2012-01-04 23:17:51 -08:00
|
|
|
mozilla::RefPtr<mozilla::gfx::SourceSurface> mSourceSurface;
|
2014-09-15 08:24:03 -07:00
|
|
|
mozilla::gfx::Matrix mPatternToUserSpace;
|
2012-01-04 23:17:51 -08:00
|
|
|
mozilla::RefPtr<mozilla::gfx::GradientStops> mStops;
|
2014-09-14 02:58:56 -07:00
|
|
|
nsTArray<mozilla::gfx::GradientStop> mStopsList;
|
2013-06-19 14:06:42 -07:00
|
|
|
GraphicsExtend mExtend;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_PATTERN_H */
|