JDK绘制文字的流程与代码分析
Posted 柳鲲鹏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JDK绘制文字的流程与代码分析相关的知识,希望对你有一定的参考价值。
还没整理,简单的把总结放这里:
- 绘制动作
FreetypeFontScaler.getGlyphImageNative()
FileFont.getGlyphImage()
FileFontStrike.getGlyphImagePtrs()
{
images[i] = setCachedGlyphptr(glyphCode, glyphPtr);
}
GlyphList.mapChars():位图信息保存在images
sun.java2d.loops.DrawGlyphList.DrawGlyphList
DrawGlyphListFunc
具体调用是:
pPrim->funcs.drawglyphlist()
- 初始化流程
NativePrimitive *pPrim;
GetNativePrim()
反射字段pNativePrim
JNU_GetLongFieldAsPtr
GraphicsPrimitiveMgr.registerNativeLoops
RegisterPrimitives
registerNativeLoops
在RegisterAnyInt初始化中完成。
AnyInt.c
NativePrimitive AnyIntPrimitives[] = {
//REGISTER_FILLRECT, REGISTER_PRIMITIVE, 1
REGISTER_SOLID_FILLRECT(AnyInt),
//REGISTER_FILLSPANS, REGISTER_PRIMITIVE, 1
REGISTER_SOLID_FILLSPANS(AnyInt),
//REGISTER_PRIMITIVE, 2
REGISTER_SOLID_PARALLELOGRAM(AnyInt),
//REGISTER_LINE_PRIMITIVES, REGISTER_PRIMITIVE, 5
REGISTER_SOLID_LINE_PRIMITIVES(AnyInt),
//REGISTER_FILLRECT, REGISTER_PRIMITIVE, 1
REGISTER_XOR_FILLRECT(AnyInt),
//REGISTER_FILLSPANS, REGISTER_PRIMITIVE, 1
REGISTER_XOR_FILLSPANS(AnyInt),
//REGISTER_LINE_PRIMITIVES, REGISTER_PRIMITIVE, 5
REGISTER_XOR_LINE_PRIMITIVES(AnyInt),
//REGISTER_DRAWGLYPHLIST, REGISTER_PRIMITIVE, 1
//字体使用这个进行绘制。
REGISTER_SOLID_DRAWGLYPHLIST(AnyInt),
//REGISTER_DRAWGLYPHLIST, REGISTER_PRIMITIVE, 1
//REGISTER_DRAWGLYPHLISTAA, REGISTER_PRIMITIVE, 1
REGISTER_XOR_DRAWGLYPHLIST(AnyInt),
//共19个
};
DEFINE_SOLID_DRAWGLYPHLIST是定义在LoopMacros.h的宏。
具体来说:
NAME_SOLID_DRAWGLYPHLIST
以上是关于JDK绘制文字的流程与代码分析的主要内容,如果未能解决你的问题,请参考以下文章