Forum > GTK

Bounty $60: rework of GTK2 ExtTextOut to use new API

(1/1)

AlexTP:
I want to suggest such small bounty.
It should affect speed of text rendering in my text editor CudaText.
If it will not affect the speed, it will be problematic patch, which I dislike and cannot give the bounty.

Current ExtTextOut in GTK2 calls this core function
(file lcl/interfaces/gtk2/gtk2devicecontext.inc)

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TGtkDeviceContext.DrawTextWithColors(AText: PChar; ALength: LongInt;  X, Y: Integer; FGColor, BGColor: PGdkColor);var  WidgetCont: PPangoContext;  NewMatrix: TPangoMatrix;  OldMatrix: PPangoMatrix;  renderer: PGdkPangoRenderer;  Direction : TPangoDirection;  AFont: PGdiObject;    procedure SetColors(AFGColor, ABGColor: PGdkColor); inline;  begin    gdk_pango_renderer_set_override_color(renderer, PANGO_RENDER_PART_FOREGROUND, AFGColor);    gdk_pango_renderer_set_override_color(renderer, PANGO_RENDER_PART_UNDERLINE, AFGColor);    gdk_pango_renderer_set_override_color(renderer, PANGO_RENDER_PART_STRIKETHROUGH, AFGColor);    gdk_pango_renderer_set_override_color(renderer, PANGO_RENDER_PART_BACKGROUND, ABGColor);  end;  begin  AFont := GetFont;  SetLayoutText(AFont^.GDIFontObject, AText, ALength);   WidgetCont := pango_layout_get_context(AFont^.GDIFontObject);  Direction := pango_find_base_dir(AText, ALength);  pango_context_set_base_dir(WidgetCont, Direction);   if AFont^.LogFont.lfEscapement <> 0 then  begin    if Widget <> nil then      renderer := gdk_pango_renderer_get_default(gtk_widget_get_screen(Widget))    else      renderer := gdk_pango_renderer_get_default(gdk_screen_get_default);    RemovePixbuf;    gdk_pango_renderer_set_drawable(renderer, drawable);    gdk_pango_renderer_set_gc(renderer, GC);    SetColors(FGColor, BGColor);     OldMatrix := pango_context_get_matrix(WidgetCont);    NewMatrix.xx := 1.0;    NewMatrix.xy := 0.0;    NewMatrix.yx := 0.0;    NewMatrix.yy := 1.0;    NewMatrix.x0 := 0.0;    NewMatrix.y0 := 0.0;    pango_matrix_translate(@NewMatrix, X, Y);    pango_matrix_rotate(@NewMatrix, AFont^.LogFont.lfEscapement / 10);     pango_context_set_matrix(WidgetCont, @NewMatrix);    pango_layout_context_changed(AFont^.GDIFontObject);    pango_renderer_draw_layout(PPangoRenderer(renderer), AFont^.GDIFontObject, X, Y);     //now reset    pango_context_set_matrix(WidgetCont, OldMatrix);    pango_layout_context_changed(AFont^.GDIFontObject);        SetColors(nil, nil);    gdk_pango_renderer_set_drawable(renderer, nil);    gdk_pango_renderer_set_gc(renderer, nil);  end  else    gdk_draw_layout_with_colors(drawable, GC, X, Y, AFont^.GDIFontObject, FGColor, BGColor);end; 
I looked at the GTK2 docs about these gdk_xxxxx APIs and docs say that they are deprecated! We must use some newer API from GTK2.
I don't have URL at hands, so please look at docs by yourself. If you won't find this text, I will help to find it.

AlexTP:
 
Found the docs!
https://www.manpagez.com/html/gdk2/gdk2-2.24.24/gdk2-Drawing-Primitives.php#gdk-draw-layout-with-colors

Navigation

[0] Message Index

Go to full version