mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 736134 - Part 1: Add GlyphRenderingOptions API to Azure. r=jrmuizel
This commit is contained in:
parent
f84a537689
commit
ef709193e2
24
gfx/2d/2D.h
24
gfx/2d/2D.h
@ -55,6 +55,7 @@ typedef _cairo_scaled_font cairo_scaled_font_t;
|
||||
|
||||
struct ID3D10Device1;
|
||||
struct ID3D10Texture2D;
|
||||
struct IDWriteRenderingParams;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -488,6 +489,23 @@ protected:
|
||||
ScaledFont() {}
|
||||
};
|
||||
|
||||
/* This class is designed to allow passing additional glyph rendering
|
||||
* parameters to the glyph drawing functions. This is an empty wrapper class
|
||||
* merely used to allow holding on to and passing around platform specific
|
||||
* parameters. This is because different platforms have unique rendering
|
||||
* parameters.
|
||||
*/
|
||||
class GlyphRenderingOptions : public RefCounted<GlyphRenderingOptions>
|
||||
{
|
||||
public:
|
||||
virtual ~GlyphRenderingOptions() {}
|
||||
|
||||
virtual FontType GetType() const = 0;
|
||||
|
||||
protected:
|
||||
GlyphRenderingOptions() {}
|
||||
};
|
||||
|
||||
/* This is the main class used for all the drawing. It is created through the
|
||||
* factory and accepts drawing commands. The results of drawing to a target
|
||||
* may be used either through a Snapshot or by flushing the target and directly
|
||||
@ -640,7 +658,8 @@ public:
|
||||
virtual void FillGlyphs(ScaledFont *aFont,
|
||||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions = DrawOptions()) = 0;
|
||||
const DrawOptions &aOptions = DrawOptions(),
|
||||
const GlyphRenderingOptions *aRenderingOptions = NULL) = 0;
|
||||
|
||||
/*
|
||||
* This takes a source pattern and a mask, and composites the source pattern
|
||||
@ -806,6 +825,9 @@ public:
|
||||
static void SetDirect3D10Device(ID3D10Device1 *aDevice);
|
||||
static ID3D10Device1 *GetDirect3D10Device();
|
||||
|
||||
static TemporaryRef<GlyphRenderingOptions>
|
||||
CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams);
|
||||
|
||||
private:
|
||||
static ID3D10Device1 *mD3D10Device;
|
||||
#endif
|
||||
|
@ -699,7 +699,8 @@ DrawTargetCG::Fill(const Path *aPath, const Pattern &aPattern, const DrawOptions
|
||||
|
||||
|
||||
void
|
||||
DrawTargetCG::FillGlyphs(ScaledFont *aFont, const GlyphBuffer &aBuffer, const Pattern &aPattern, const DrawOptions &aDrawOptions)
|
||||
DrawTargetCG::FillGlyphs(ScaledFont *aFont, const GlyphBuffer &aBuffer, const Pattern &aPattern, const DrawOptions &aDrawOptions,
|
||||
const GlyphRenderingOptions*)
|
||||
{
|
||||
MarkChanged();
|
||||
|
||||
|
@ -147,7 +147,7 @@ public:
|
||||
virtual void StrokeLine(const Point &, const Point &, const Pattern &, const StrokeOptions &, const DrawOptions &);
|
||||
virtual void Stroke(const Path *, const Pattern &, const StrokeOptions &, const DrawOptions &);
|
||||
virtual void Fill(const Path *, const Pattern &, const DrawOptions &);
|
||||
virtual void FillGlyphs(ScaledFont *, const GlyphBuffer&, const Pattern &, const DrawOptions &);
|
||||
virtual void FillGlyphs(ScaledFont *, const GlyphBuffer&, const Pattern &, const DrawOptions &, const GlyphRenderingOptions *);
|
||||
virtual void Mask(const Pattern &aSource,
|
||||
const Pattern &aMask,
|
||||
const DrawOptions &aOptions = DrawOptions());
|
||||
|
@ -587,7 +587,8 @@ void
|
||||
DrawTargetCairo::FillGlyphs(ScaledFont *aFont,
|
||||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions)
|
||||
const DrawOptions &aOptions,
|
||||
const GlyphRenderingOptions*)
|
||||
{
|
||||
AutoPrepareForDrawing prep(this, mContext);
|
||||
|
||||
|
@ -125,7 +125,8 @@ public:
|
||||
virtual void FillGlyphs(ScaledFont *aFont,
|
||||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions);
|
||||
const DrawOptions &aOptions,
|
||||
const GlyphRenderingOptions *aRenderingOptions = NULL);
|
||||
virtual void Mask(const Pattern &aSource,
|
||||
const Pattern &aMask,
|
||||
const DrawOptions &aOptions = DrawOptions());
|
||||
|
@ -880,7 +880,8 @@ void
|
||||
DrawTargetD2D::FillGlyphs(ScaledFont *aFont,
|
||||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions)
|
||||
const DrawOptions &aOptions,
|
||||
const GlyphRenderingOptions* aRenderOptions)
|
||||
{
|
||||
if (aFont->GetType() != FONT_DWRITE) {
|
||||
gfxDebug() << *this << ": Ignoring drawing call for incompatible font.";
|
||||
@ -893,6 +894,19 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aFont,
|
||||
|
||||
PrepareForDrawing(rt);
|
||||
|
||||
IDWriteRenderingParams *params = NULL;
|
||||
if (aRenderOptions) {
|
||||
if (aRenderOptions->GetType() != FONT_DWRITE) {
|
||||
gfxDebug() << *this << ": Ignoring incompatible GlyphRenderingOptions.";
|
||||
// This should never happen.
|
||||
MOZ_ASSERT(false);
|
||||
} else {
|
||||
params = static_cast<const GlyphRenderingOptionsDWrite*>(aRenderOptions)->mParams;
|
||||
}
|
||||
}
|
||||
|
||||
rt->SetTextRenderingParams(params);
|
||||
|
||||
RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aPattern, aOptions.mAlpha);
|
||||
|
||||
DWRITE_GLYPH_RUN glyphRun;
|
||||
|
@ -117,7 +117,8 @@ public:
|
||||
virtual void FillGlyphs(ScaledFont *aFont,
|
||||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions = DrawOptions());
|
||||
const DrawOptions &aOptions = DrawOptions(),
|
||||
const GlyphRenderingOptions *aRenderingOptions = NULL);
|
||||
virtual void Mask(const Pattern &aSource,
|
||||
const Pattern &aMask,
|
||||
const DrawOptions &aOptions = DrawOptions());
|
||||
|
@ -543,7 +543,8 @@ void
|
||||
DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
|
||||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions)
|
||||
const DrawOptions &aOptions,
|
||||
const GlyphRenderingOptions*)
|
||||
{
|
||||
if (aFont->GetType() != FONT_MAC && aFont->GetType() != FONT_SKIA) {
|
||||
return;
|
||||
|
@ -98,7 +98,8 @@ public:
|
||||
virtual void FillGlyphs(ScaledFont *aFont,
|
||||
const GlyphBuffer &aBuffer,
|
||||
const Pattern &aPattern,
|
||||
const DrawOptions &aOptions = DrawOptions());
|
||||
const DrawOptions &aOptions = DrawOptions(),
|
||||
const GlyphRenderingOptions *aRenderingOptions = NULL);
|
||||
virtual void Mask(const Pattern &aSource,
|
||||
const Pattern &aMask,
|
||||
const DrawOptions &aOptions = DrawOptions());
|
||||
|
@ -217,6 +217,15 @@ Factory::GetDirect3D10Device()
|
||||
return mD3D10Device;
|
||||
}
|
||||
|
||||
TemporaryRef<GlyphRenderingOptions>
|
||||
Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams)
|
||||
{
|
||||
RefPtr<GlyphRenderingOptions> options =
|
||||
new GlyphRenderingOptionsDWrite(aParams);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
#endif // XP_WIN
|
||||
|
||||
#ifdef USE_CAIRO
|
||||
|
@ -63,6 +63,22 @@ private:
|
||||
Float mSize;
|
||||
};
|
||||
|
||||
class GlyphRenderingOptionsDWrite : public GlyphRenderingOptions
|
||||
{
|
||||
public:
|
||||
GlyphRenderingOptionsDWrite(IDWriteRenderingParams *aParams)
|
||||
: mParams(aParams)
|
||||
{
|
||||
}
|
||||
|
||||
virtual FontType GetType() const { return FONT_DWRITE; }
|
||||
|
||||
private:
|
||||
friend class DrawTargetD2D;
|
||||
|
||||
RefPtr<IDWriteRenderingParams> mParams;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user