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/OpenJDK)