本文整理汇总了C++中GlyphPage::owner方法的典型用法代码示例。如果您正苦于以下问题:C++ GlyphPage::owner方法的具体用法?C++ GlyphPage::owner怎么用?C++ GlyphPage::owner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlyphPage
的用法示例。
在下文中一共展示了GlyphPage::owner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializePage
void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNumber)
{
ASSERT(!m_page);
ASSERT(fontData);
// This function must not be called for the root of the tree, because that
// level does not contain any glyphs.
ASSERT(m_level > 0 && m_parent);
if (m_level == 1) {
// Children of the root hold pure pages. These will cover only one
// font data's glyphs, and will have glyph index 0 if the font data does not
// contain the glyph.
initializePurePage(fontData, pageNumber);
return;
}
// The parent's page will be 0 if we are level one or the parent's font data
// did not contain any glyphs for that page.
GlyphPage* parentPage = m_parent->page();
if (parentPage && parentPage->owner() != m_parent) {
// The page we're overriding may not be owned by our parent node.
// This happens when our parent node provides no useful overrides
// and just copies the pointer to an already-existing page (see
// below).
//
// We want our override to be shared by all nodes that reference
// that page to avoid duplication, and so standardize on having the
// page's owner collect all the overrides. Call getChild on the
// page owner with the desired font data (this will populate
// the page) and then reference it.
m_page = static_cast<GlyphPageTreeNode*>(parentPage->owner())->getNormalChild(fontData, pageNumber)->page();
return;
}
initializeOverridePage(fontData, pageNumber);
}
示例2: initializePage
//.........这里部分代码省略.........
unsigned numRanges = segmentedFontData->numRanges();
bool zeroFilled = false;
RefPtr<GlyphPage> scratchPage;
GlyphPage* pageToFill = m_page.get();
for (unsigned i = 0; i < numRanges; i++) {
const FontDataRange& range = segmentedFontData->rangeAt(i);
int from = max(0, range.from() - static_cast<int>(start));
int to = 1 + min(range.to() - static_cast<int>(start), static_cast<int>(GlyphPage::size) - 1);
if (from < static_cast<int>(GlyphPage::size) && to > 0) {
if (haveGlyphs && !scratchPage) {
scratchPage = GlyphPage::create(this);
pageToFill = scratchPage.get();
}
if (!zeroFilled) {
if (from > 0 || to < static_cast<int>(GlyphPage::size)) {
for (unsigned i = 0; i < GlyphPage::size; i++)
pageToFill->setGlyphDataForIndex(i, 0, 0);
}
zeroFilled = true;
}
haveGlyphs |= pageToFill->fill(from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData());
if (scratchPage) {
for (int j = from; j < to; j++) {
if (!m_page->m_glyphs[j].glyph && pageToFill->m_glyphs[j].glyph)
m_page->m_glyphs[j] = pageToFill->m_glyphs[j];
}
}
}
}
} else
haveGlyphs = m_page->fill(0, GlyphPage::size, buffer, bufferLength, static_cast<const SimpleFontData*>(fontData));
if (!haveGlyphs)
m_page = 0;
} else if (parentPage && parentPage->owner() != m_parent) {
// The page we're overriding may not be owned by our parent node.
// This happens when our parent node provides no useful overrides
// and just copies the pointer to an already-existing page (see
// below).
//
// We want our override to be shared by all nodes that reference
// that page to avoid duplication, and so standardize on having the
// page's owner collect all the overrides. Call getChild on the
// page owner with the desired font data (this will populate
// the page) and then reference it.
m_page = parentPage->owner()->getChild(fontData, pageNumber)->page();
} else {
// Get the pure page for the fallback font (at level 1 with no
// overrides). getRootChild will always create a page if one
// doesn't exist, but the page doesn't necessarily have glyphs
// (this pointer may be 0).
GlyphPage* fallbackPage = getRootChild(fontData, pageNumber)->page();
if (!parentPage) {
// When the parent has no glyphs for this page, we can easily
// override it just by supplying the glyphs from our font.
m_page = fallbackPage;
} else if (!fallbackPage) {
// When our font has no glyphs for this page, we can just reference the
// parent page.
m_page = parentPage;
} else {
// Combine the parent's glyphs and ours to form a new more complete page.
m_page = GlyphPage::create(this);
// Overlay the parent page on the fallback page. Check if the fallback font
// has added anything.
bool newGlyphs = false;
for (unsigned i = 0; i < GlyphPage::size; i++) {
if (parentPage->m_glyphs[i].glyph)
m_page->m_glyphs[i] = parentPage->m_glyphs[i];
else if (fallbackPage->m_glyphs[i].glyph) {
m_page->m_glyphs[i] = fallbackPage->m_glyphs[i];
newGlyphs = true;
} else {
const GlyphData data = { 0, 0 };
m_page->m_glyphs[i] = data;
}
}
if (!newGlyphs)
// We didn't override anything, so our override is just the parent page.
m_page = parentPage;
}
}
} else {
m_page = GlyphPage::create(this);
// System fallback. Initialized with the parent's page here, as individual
// entries may use different fonts depending on character. If the Font
// ever finds it needs a glyph out of the system fallback page, it will
// ask the system for the best font to use and fill that glyph in for us.
if (parentPage)
memcpy(m_page->m_glyphs, parentPage->m_glyphs, GlyphPage::size * sizeof(m_page->m_glyphs[0]));
else {
const GlyphData data = { 0, 0 };
for (unsigned i = 0; i < GlyphPage::size; i++)
m_page->m_glyphs[i] = data;
}
}
}
示例3: initializePage
//.........这里部分代码省略.........
bool haveGlyphs;
if (!fontData->isSegmented()) {
m_page = GlyphPage::createForSingleFontData(this, toSimpleFontData(fontData));
haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength, toSimpleFontData(fontData));
} else {
m_page = GlyphPage::createForMixedFontData(this);
haveGlyphs = false;
const SegmentedFontData* segmentedFontData = toSegmentedFontData(fontData);
for (int i = segmentedFontData->numRanges() - 1; i >= 0; i--) {
const FontDataRange& range = segmentedFontData->rangeAt(i);
// all this casting is to ensure all the parameters to min and max have the same type,
// to avoid ambiguous template parameter errors on Windows
int from = max(0, static_cast<int>(range.from()) - static_cast<int>(start));
int to = 1 + min(static_cast<int>(range.to()) - static_cast<int>(start), static_cast<int>(GlyphPage::size) - 1);
if (from >= static_cast<int>(GlyphPage::size) || to <= 0)
continue;
// If this is a custom font needs to be loaded, do not fill
// the page so that font fallback is used while loading.
RefPtr<CustomFontData> customData = range.fontData()->customFontData();
if (customData && customData->isLoadingFallback()) {
for (int j = from; j < to; j++) {
m_page->setCustomFontToLoad(j, customData.get());
haveGlyphs = true;
}
continue;
}
haveGlyphs |= fill(m_page.get(), from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData().get());
}
}
if (!haveGlyphs)
m_page = nullptr;
} else if (parentPage && parentPage->owner() != m_parent) {
// The page we're overriding may not be owned by our parent node.
// This happens when our parent node provides no useful overrides
// and just copies the pointer to an already-existing page (see
// below).
//
// We want our override to be shared by all nodes that reference
// that page to avoid duplication, and so standardize on having the
// page's owner collect all the overrides. Call getChild on the
// page owner with the desired font data (this will populate
// the page) and then reference it.
m_page = parentPage->owner()->getChild(fontData, pageNumber)->page();
} else {
// Get the pure page for the fallback font (at level 1 with no
// overrides). getRootChild will always create a page if one
// doesn't exist, but the page doesn't necessarily have glyphs
// (this pointer may be 0).
GlyphPage* fallbackPage = getRootChild(fontData, pageNumber)->page();
if (!parentPage) {
// When the parent has no glyphs for this page, we can easily
// override it just by supplying the glyphs from our font.
m_page = fallbackPage;
} else if (!fallbackPage) {
// When our font has no glyphs for this page, we can just reference the
// parent page.
m_page = parentPage;
} else {
// Combine the parent's glyphs and ours to form a new more complete page.
m_page = GlyphPage::createForMixedFontData(this);
// Overlay the parent page on the fallback page. Check if the fallback font
// has added anything.
bool newGlyphs = false;
for (unsigned i = 0; i < GlyphPage::size; i++) {
if (parentPage->glyphAt(i)) {
m_page->setGlyphDataForIndex(i, parentPage->glyphDataForIndex(i));
} else if (fallbackPage->glyphAt(i)) {
m_page->setGlyphDataForIndex(i, fallbackPage->glyphDataForIndex(i));
newGlyphs = true;
}
if (parentPage->customFontToLoadAt(i)) {
m_page->setCustomFontToLoad(i, parentPage->customFontToLoadAt(i));
} else if (fallbackPage->customFontToLoadAt(i) && !parentPage->glyphAt(i)) {
m_page->setCustomFontToLoad(i, fallbackPage->customFontToLoadAt(i));
newGlyphs = true;
}
}
if (!newGlyphs)
// We didn't override anything, so our override is just the parent page.
m_page = parentPage;
}
}
} else {
// System fallback. Initialized with the parent's page here, as individual
// entries may use different fonts depending on character. If the Font
// ever finds it needs a glyph out of the system fallback page, it will
// ask the system for the best font to use and fill that glyph in for us.
if (parentPage)
m_page = parentPage->createCopiedSystemFallbackPage(this);
else
m_page = GlyphPage::createForMixedFontData(this);
}
}