2012-01-10 02:15:10 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
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/. */
|
2012-01-10 02:15:10 +04:00
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_HELPERSCAIRO_H_
|
|
|
|
#define MOZILLA_GFX_HELPERSCAIRO_H_
|
|
|
|
|
|
|
|
#include "2D.h"
|
|
|
|
#include "cairo.h"
|
2012-08-09 00:17:04 +04:00
|
|
|
#include "Logging.h"
|
2012-01-10 02:15:10 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
static inline cairo_operator_t
|
|
|
|
GfxOpToCairoOp(CompositionOp op)
|
|
|
|
{
|
|
|
|
switch (op)
|
|
|
|
{
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_OVER:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_OVER;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_ADD:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_ADD;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_ATOP:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_ATOP;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_OUT:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_OUT;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_IN:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_IN;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_SOURCE:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_SOURCE;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_DEST_IN:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_DEST_IN;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_DEST_OUT:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_DEST_OUT;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_DEST_OVER:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_DEST_OVER;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_DEST_ATOP:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_DEST_ATOP;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_XOR:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_OPERATOR_XOR;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_MULTIPLY:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_MULTIPLY;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_SCREEN:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_SCREEN;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_OVERLAY:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_OVERLAY;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_DARKEN:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_DARKEN;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_LIGHTEN:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_LIGHTEN;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_COLOR_DODGE:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_COLOR_DODGE;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_COLOR_BURN:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_COLOR_BURN;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_HARD_LIGHT:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_HARD_LIGHT;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_SOFT_LIGHT:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_SOFT_LIGHT;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_DIFFERENCE:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_DIFFERENCE;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_EXCLUSION:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_EXCLUSION;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_HUE:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_HSL_HUE;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_SATURATION:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_HSL_SATURATION;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_COLOR:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_HSL_COLOR;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_LUMINOSITY:
|
2012-12-13 00:28:17 +04:00
|
|
|
return CAIRO_OPERATOR_HSL_LUMINOSITY;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CompositionOp::OP_COUNT:
|
2012-01-10 02:15:10 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CAIRO_OPERATOR_OVER;
|
|
|
|
}
|
|
|
|
|
2013-08-21 03:56:27 +04:00
|
|
|
static inline cairo_antialias_t
|
|
|
|
GfxAntialiasToCairoAntialias(AntialiasMode antialias)
|
|
|
|
{
|
|
|
|
switch (antialias)
|
|
|
|
{
|
2014-01-10 23:06:17 +04:00
|
|
|
case AntialiasMode::NONE:
|
2013-08-21 03:56:27 +04:00
|
|
|
return CAIRO_ANTIALIAS_NONE;
|
2014-01-10 23:06:17 +04:00
|
|
|
case AntialiasMode::GRAY:
|
2013-08-21 03:56:27 +04:00
|
|
|
return CAIRO_ANTIALIAS_GRAY;
|
2014-01-10 23:06:17 +04:00
|
|
|
case AntialiasMode::SUBPIXEL:
|
2013-08-21 03:56:27 +04:00
|
|
|
return CAIRO_ANTIALIAS_SUBPIXEL;
|
2015-09-02 21:12:32 +03:00
|
|
|
default:
|
2013-08-21 03:56:27 +04:00
|
|
|
return CAIRO_ANTIALIAS_DEFAULT;
|
|
|
|
}
|
2015-09-02 21:12:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline AntialiasMode
|
|
|
|
CairoAntialiasToGfxAntialias(cairo_antialias_t aAntialias)
|
|
|
|
{
|
|
|
|
switch(aAntialias) {
|
|
|
|
case CAIRO_ANTIALIAS_NONE:
|
|
|
|
return AntialiasMode::NONE;
|
|
|
|
case CAIRO_ANTIALIAS_GRAY:
|
|
|
|
return AntialiasMode::GRAY;
|
|
|
|
case CAIRO_ANTIALIAS_SUBPIXEL:
|
|
|
|
return AntialiasMode::SUBPIXEL;
|
|
|
|
default:
|
|
|
|
return AntialiasMode::DEFAULT;
|
|
|
|
}
|
2013-08-21 03:56:27 +04:00
|
|
|
}
|
|
|
|
|
2012-01-10 02:15:10 +04:00
|
|
|
static inline cairo_filter_t
|
2016-05-25 19:01:18 +03:00
|
|
|
GfxSamplingFilterToCairoFilter(SamplingFilter filter)
|
2012-01-10 02:15:10 +04:00
|
|
|
{
|
|
|
|
switch (filter)
|
|
|
|
{
|
2016-05-25 19:01:18 +03:00
|
|
|
case SamplingFilter::GOOD:
|
2013-07-31 22:46:25 +04:00
|
|
|
return CAIRO_FILTER_GOOD;
|
2016-05-25 19:01:18 +03:00
|
|
|
case SamplingFilter::LINEAR:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_FILTER_BILINEAR;
|
2016-05-25 19:01:18 +03:00
|
|
|
case SamplingFilter::POINT:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_FILTER_NEAREST;
|
2015-10-06 03:12:46 +03:00
|
|
|
default:
|
2016-05-13 23:34:41 +03:00
|
|
|
MOZ_CRASH("GFX: bad Cairo filter");
|
2012-01-10 02:15:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return CAIRO_FILTER_BILINEAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline cairo_extend_t
|
|
|
|
GfxExtendToCairoExtend(ExtendMode extend)
|
|
|
|
{
|
|
|
|
switch (extend)
|
|
|
|
{
|
2014-01-10 23:06:17 +04:00
|
|
|
case ExtendMode::CLAMP:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_EXTEND_PAD;
|
2015-11-23 19:17:35 +03:00
|
|
|
// Cairo doesn't support tiling in only 1 direction,
|
|
|
|
// So we have to fallback and tile in both.
|
|
|
|
case ExtendMode::REPEAT_X:
|
|
|
|
case ExtendMode::REPEAT_Y:
|
2014-01-10 23:06:17 +04:00
|
|
|
case ExtendMode::REPEAT:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_EXTEND_REPEAT;
|
2014-01-10 23:06:17 +04:00
|
|
|
case ExtendMode::REFLECT:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_EXTEND_REFLECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CAIRO_EXTEND_PAD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline cairo_format_t
|
|
|
|
GfxFormatToCairoFormat(SurfaceFormat format)
|
|
|
|
{
|
|
|
|
switch (format)
|
|
|
|
{
|
2015-10-19 07:53:40 +03:00
|
|
|
case SurfaceFormat::A8R8G8B8_UINT32:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_FORMAT_ARGB32;
|
2015-10-19 07:53:40 +03:00
|
|
|
case SurfaceFormat::X8R8G8B8_UINT32:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_FORMAT_RGB24;
|
2014-01-10 23:06:16 +04:00
|
|
|
case SurfaceFormat::A8:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_FORMAT_A8;
|
2015-10-23 09:01:31 +03:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16:
|
2012-08-09 00:17:04 +04:00
|
|
|
return CAIRO_FORMAT_RGB16_565;
|
2012-02-04 16:22:47 +04:00
|
|
|
default:
|
2015-07-14 22:22:29 +03:00
|
|
|
gfxCriticalError() << "Unknown image format " << (int)format;
|
2012-02-04 16:22:47 +04:00
|
|
|
return CAIRO_FORMAT_ARGB32;
|
2012-01-10 02:15:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-16 02:09:49 +03:00
|
|
|
static inline cairo_format_t
|
|
|
|
CairoContentToCairoFormat(cairo_content_t content)
|
|
|
|
{
|
|
|
|
switch (content)
|
|
|
|
{
|
|
|
|
case CAIRO_CONTENT_COLOR:
|
|
|
|
return CAIRO_FORMAT_RGB24;
|
|
|
|
case CAIRO_CONTENT_ALPHA:
|
|
|
|
return CAIRO_FORMAT_A8;
|
|
|
|
case CAIRO_CONTENT_COLOR_ALPHA:
|
|
|
|
return CAIRO_FORMAT_ARGB32;
|
|
|
|
default:
|
|
|
|
gfxCriticalError() << "Unknown cairo content type " << (int)content;
|
|
|
|
return CAIRO_FORMAT_A8; // least likely to cause OOB reads
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-10 02:15:10 +04:00
|
|
|
static inline cairo_content_t
|
|
|
|
GfxFormatToCairoContent(SurfaceFormat format)
|
|
|
|
{
|
|
|
|
switch (format)
|
|
|
|
{
|
2015-10-19 07:53:40 +03:00
|
|
|
case SurfaceFormat::A8R8G8B8_UINT32:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_CONTENT_COLOR_ALPHA;
|
2015-10-19 07:53:40 +03:00
|
|
|
case SurfaceFormat::X8R8G8B8_UINT32:
|
2015-10-23 09:01:31 +03:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16: //fall through
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_CONTENT_COLOR;
|
2014-01-10 23:06:16 +04:00
|
|
|
case SurfaceFormat::A8:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_CONTENT_ALPHA;
|
2012-02-04 16:22:47 +04:00
|
|
|
default:
|
2015-07-14 22:22:29 +03:00
|
|
|
gfxCriticalError() << "Unknown image content format " << (int)format;
|
2012-02-04 16:22:47 +04:00
|
|
|
return CAIRO_CONTENT_COLOR_ALPHA;
|
2012-01-10 02:15:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline cairo_line_join_t
|
|
|
|
GfxLineJoinToCairoLineJoin(JoinStyle style)
|
|
|
|
{
|
|
|
|
switch (style)
|
|
|
|
{
|
2014-01-10 23:06:17 +04:00
|
|
|
case JoinStyle::BEVEL:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_LINE_JOIN_BEVEL;
|
2014-01-10 23:06:17 +04:00
|
|
|
case JoinStyle::ROUND:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_LINE_JOIN_ROUND;
|
2014-01-10 23:06:17 +04:00
|
|
|
case JoinStyle::MITER:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_LINE_JOIN_MITER;
|
2014-01-10 23:06:17 +04:00
|
|
|
case JoinStyle::MITER_OR_BEVEL:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_LINE_JOIN_MITER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CAIRO_LINE_JOIN_MITER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline cairo_line_cap_t
|
|
|
|
GfxLineCapToCairoLineCap(CapStyle style)
|
|
|
|
{
|
|
|
|
switch (style)
|
|
|
|
{
|
2014-01-10 23:06:17 +04:00
|
|
|
case CapStyle::BUTT:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_LINE_CAP_BUTT;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CapStyle::ROUND:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_LINE_CAP_ROUND;
|
2014-01-10 23:06:17 +04:00
|
|
|
case CapStyle::SQUARE:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_LINE_CAP_SQUARE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CAIRO_LINE_CAP_BUTT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline SurfaceFormat
|
|
|
|
CairoContentToGfxFormat(cairo_content_t content)
|
|
|
|
{
|
|
|
|
switch (content)
|
|
|
|
{
|
|
|
|
case CAIRO_CONTENT_COLOR_ALPHA:
|
2015-10-19 07:53:40 +03:00
|
|
|
return SurfaceFormat::A8R8G8B8_UINT32;
|
2012-01-10 02:15:10 +04:00
|
|
|
case CAIRO_CONTENT_COLOR:
|
2012-08-09 00:17:04 +04:00
|
|
|
// BEWARE! format may be 565
|
2015-10-19 07:53:40 +03:00
|
|
|
return SurfaceFormat::X8R8G8B8_UINT32;
|
2012-01-10 02:15:10 +04:00
|
|
|
case CAIRO_CONTENT_ALPHA:
|
2014-01-10 23:06:16 +04:00
|
|
|
return SurfaceFormat::A8;
|
2012-01-10 02:15:10 +04:00
|
|
|
}
|
|
|
|
|
2014-01-10 23:06:16 +04:00
|
|
|
return SurfaceFormat::B8G8R8A8;
|
2012-01-10 02:15:10 +04:00
|
|
|
}
|
|
|
|
|
2014-12-18 00:49:57 +03:00
|
|
|
static inline SurfaceFormat
|
|
|
|
CairoFormatToGfxFormat(cairo_format_t format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case CAIRO_FORMAT_ARGB32:
|
2015-10-19 07:53:40 +03:00
|
|
|
return SurfaceFormat::A8R8G8B8_UINT32;
|
2014-12-18 00:49:57 +03:00
|
|
|
case CAIRO_FORMAT_RGB24:
|
2015-10-19 07:53:40 +03:00
|
|
|
return SurfaceFormat::X8R8G8B8_UINT32;
|
2014-12-18 00:49:57 +03:00
|
|
|
case CAIRO_FORMAT_A8:
|
|
|
|
return SurfaceFormat::A8;
|
|
|
|
case CAIRO_FORMAT_RGB16_565:
|
2015-10-23 09:01:31 +03:00
|
|
|
return SurfaceFormat::R5G6B5_UINT16;
|
2014-12-18 00:49:57 +03:00
|
|
|
default:
|
2015-03-09 16:34:45 +03:00
|
|
|
gfxCriticalError() << "Unknown cairo format " << format;
|
2014-12-18 00:49:57 +03:00
|
|
|
return SurfaceFormat::UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-02 21:12:32 +03:00
|
|
|
static inline FontHinting
|
|
|
|
CairoHintingToGfxHinting(cairo_hint_style_t aHintStyle)
|
|
|
|
{
|
|
|
|
switch (aHintStyle) {
|
|
|
|
case CAIRO_HINT_STYLE_NONE:
|
|
|
|
return FontHinting::NONE;
|
|
|
|
case CAIRO_HINT_STYLE_SLIGHT:
|
|
|
|
return FontHinting::LIGHT;
|
|
|
|
case CAIRO_HINT_STYLE_MEDIUM:
|
|
|
|
return FontHinting::NORMAL;
|
|
|
|
case CAIRO_HINT_STYLE_FULL:
|
|
|
|
return FontHinting::FULL;
|
|
|
|
default:
|
|
|
|
return FontHinting::NORMAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-07 03:19:56 +03:00
|
|
|
SurfaceFormat GfxFormatForCairoSurface(cairo_surface_t* surface);
|
2014-12-18 00:49:57 +03:00
|
|
|
|
2012-01-10 02:15:10 +04:00
|
|
|
static inline void
|
|
|
|
GfxMatrixToCairoMatrix(const Matrix& mat, cairo_matrix_t& retval)
|
|
|
|
{
|
|
|
|
cairo_matrix_init(&retval, mat._11, mat._12, mat._21, mat._22, mat._31, mat._32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
SetCairoStrokeOptions(cairo_t* aCtx, const StrokeOptions& aStrokeOptions)
|
|
|
|
{
|
|
|
|
cairo_set_line_width(aCtx, aStrokeOptions.mLineWidth);
|
|
|
|
|
|
|
|
cairo_set_miter_limit(aCtx, aStrokeOptions.mMiterLimit);
|
|
|
|
|
|
|
|
if (aStrokeOptions.mDashPattern) {
|
|
|
|
// Convert array of floats to array of doubles
|
|
|
|
std::vector<double> dashes(aStrokeOptions.mDashLength);
|
2015-06-02 01:02:10 +03:00
|
|
|
bool nonZero = false;
|
2012-01-10 02:15:10 +04:00
|
|
|
for (size_t i = 0; i < aStrokeOptions.mDashLength; ++i) {
|
2015-06-02 01:02:10 +03:00
|
|
|
if (aStrokeOptions.mDashPattern[i] != 0) {
|
|
|
|
nonZero = true;
|
|
|
|
}
|
2012-01-10 02:15:10 +04:00
|
|
|
dashes[i] = aStrokeOptions.mDashPattern[i];
|
|
|
|
}
|
2015-06-02 01:02:10 +03:00
|
|
|
// Avoid all-zero patterns that would trigger the CAIRO_STATUS_INVALID_DASH context error state.
|
|
|
|
if (nonZero) {
|
|
|
|
cairo_set_dash(aCtx, &dashes[0], aStrokeOptions.mDashLength,
|
|
|
|
aStrokeOptions.mDashOffset);
|
|
|
|
}
|
2012-01-10 02:15:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cairo_set_line_join(aCtx, GfxLineJoinToCairoLineJoin(aStrokeOptions.mLineJoin));
|
|
|
|
|
|
|
|
cairo_set_line_cap(aCtx, GfxLineCapToCairoLineCap(aStrokeOptions.mLineCap));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline cairo_fill_rule_t
|
|
|
|
GfxFillRuleToCairoFillRule(FillRule rule)
|
|
|
|
{
|
|
|
|
switch (rule)
|
|
|
|
{
|
2014-01-10 23:06:17 +04:00
|
|
|
case FillRule::FILL_WINDING:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_FILL_RULE_WINDING;
|
2014-01-10 23:06:17 +04:00
|
|
|
case FillRule::FILL_EVEN_ODD:
|
2012-01-10 02:15:10 +04:00
|
|
|
return CAIRO_FILL_RULE_EVEN_ODD;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CAIRO_FILL_RULE_WINDING;
|
|
|
|
}
|
|
|
|
|
2012-09-04 01:47:09 +04:00
|
|
|
// RAII class for temporarily changing the cairo matrix transform. It will use
|
|
|
|
// the given matrix transform while it is in scope. When it goes out of scope
|
|
|
|
// it will put the cairo context back the way it was.
|
|
|
|
|
|
|
|
class CairoTempMatrix
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CairoTempMatrix(cairo_t* aCtx, const Matrix& aMatrix)
|
|
|
|
: mCtx(aCtx)
|
|
|
|
{
|
|
|
|
cairo_get_matrix(aCtx, &mSaveMatrix);
|
|
|
|
cairo_matrix_t matrix;
|
|
|
|
GfxMatrixToCairoMatrix(aMatrix, matrix);
|
|
|
|
cairo_set_matrix(aCtx, &matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
~CairoTempMatrix()
|
|
|
|
{
|
2012-10-02 06:12:13 +04:00
|
|
|
cairo_set_matrix(mCtx, &mSaveMatrix);
|
2012-09-04 01:47:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
cairo_t* mCtx;
|
|
|
|
cairo_matrix_t mSaveMatrix;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2012-01-10 02:15:10 +04:00
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_HELPERSCAIRO_H_ */
|