2018-11-30 22:52:05 +03: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/. */
|
2011-12-10 02:32:29 +04:00
|
|
|
|
|
|
|
#ifndef GFX_GRAPHITESHAPER_H
|
|
|
|
#define GFX_GRAPHITESHAPER_H
|
|
|
|
|
|
|
|
#include "gfxFont.h"
|
|
|
|
|
2015-12-07 01:13:19 +03:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2021-03-23 13:36:36 +03:00
|
|
|
#include "nsTHashSet.h"
|
2015-12-07 01:13:19 +03:00
|
|
|
|
2019-12-19 19:05:35 +03:00
|
|
|
#include "ThebesRLBoxTypes.h"
|
|
|
|
|
2012-01-26 15:20:57 +04:00
|
|
|
struct gr_face;
|
|
|
|
struct gr_font;
|
|
|
|
struct gr_segment;
|
2011-12-10 02:32:29 +04:00
|
|
|
|
|
|
|
class gfxGraphiteShaper : public gfxFontShaper {
|
|
|
|
public:
|
2014-08-08 05:17:30 +04:00
|
|
|
explicit gfxGraphiteShaper(gfxFont* aFont);
|
2011-12-10 02:32:29 +04:00
|
|
|
virtual ~gfxGraphiteShaper();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-04-03 19:49:17 +03:00
|
|
|
bool ShapeText(DrawTarget* aDrawTarget, const char16_t* aText,
|
|
|
|
uint32_t aOffset, uint32_t aLength, Script aScript,
|
2020-11-13 16:15:39 +03:00
|
|
|
nsAtom* aLanguage, bool aVertical, RoundingFlags aRounding,
|
2017-04-03 19:49:17 +03:00
|
|
|
gfxShapedText* aShapedText) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-12-10 02:32:29 +04:00
|
|
|
static void Shutdown();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-12-10 02:32:29 +04:00
|
|
|
protected:
|
2017-04-03 19:49:17 +03:00
|
|
|
nsresult SetGlyphsFromSegment(gfxShapedText* aShapedText, uint32_t aOffset,
|
2014-01-04 19:02:17 +04:00
|
|
|
uint32_t aLength, const char16_t* aText,
|
2019-12-19 19:05:35 +03:00
|
|
|
tainted_opaque_gr<char16_t*> t_aText,
|
|
|
|
tainted_opaque_gr<gr_segment*> aSegment,
|
|
|
|
RoundingFlags aRounding);
|
|
|
|
|
|
|
|
// Graphite is run in a rlbox sandbox. Callback GrGetAdvance must be
|
|
|
|
// explicitly permitted. Since the sandbox is owned in gfxFontEntry class,
|
|
|
|
// gfxFontEntry needs access to the protected callback.
|
2022-11-22 09:06:36 +03:00
|
|
|
friend class gfxFontEntryCallbacks;
|
2019-12-19 19:05:35 +03:00
|
|
|
static tainted_opaque_gr<float> GrGetAdvance(
|
|
|
|
rlbox_sandbox_gr& sandbox, tainted_opaque_gr<const void*> appFontHandle,
|
|
|
|
tainted_opaque_gr<uint16_t> glyphid);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-12-19 19:05:35 +03:00
|
|
|
tainted_opaque_gr<gr_face*>
|
|
|
|
mGrFace; // owned by the font entry; shaper must call
|
|
|
|
// gfxFontEntry::ReleaseGrFace when finished with it
|
|
|
|
tainted_opaque_gr<gr_font*> mGrFont; // owned by the shaper itself
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-12-19 19:05:35 +03:00
|
|
|
// All libGraphite functionality is sandboxed. This is the sandbox instance.
|
|
|
|
rlbox_sandbox_gr* mSandbox;
|
|
|
|
|
|
|
|
// Holds the handle to the permitted callback into Firefox for the sandboxed
|
|
|
|
// libGraphite
|
|
|
|
sandbox_callback_gr<float (*)(const void*, uint16_t)>* mCallback;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-05-16 20:29:20 +04:00
|
|
|
struct CallbackData {
|
2017-06-30 03:52:43 +03:00
|
|
|
// mFont is a pointer to the font that owns this shaper, so it will
|
|
|
|
// remain valid throughout our lifetime
|
|
|
|
gfxFont* MOZ_NON_OWNING_REF mFont;
|
2013-05-16 20:29:20 +04:00
|
|
|
};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-05-16 20:29:20 +04:00
|
|
|
CallbackData mCallbackData;
|
2019-12-19 19:05:35 +03:00
|
|
|
static thread_local CallbackData* tl_GrGetAdvanceData;
|
|
|
|
|
2014-06-23 07:09:16 +04:00
|
|
|
bool mFallbackToSmallCaps; // special fallback for the petite-caps case
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-12-10 02:32:29 +04:00
|
|
|
// Convert HTML 'lang' (BCP47) to Graphite language code
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t GetGraphiteTagForLang(const nsCString& aLang);
|
2021-03-23 13:36:36 +03:00
|
|
|
static nsTHashSet<uint32_t>* sLanguageTags;
|
2011-12-10 02:32:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_GRAPHITESHAPER_H */
|