Giter VIP home page Giter VIP logo

Comments (12)

HannesBrockmann avatar HannesBrockmann commented on June 2, 2024 1

In this issue everything works for now.
Thank you

from graphics32.

andersmelander avatar andersmelander commented on June 2, 2024

You are using the FPC_GTK branch, right?

from graphics32.

andersmelander avatar andersmelander commented on June 2, 2024

Looking at the source for TLCLBackend I can see that Textout(X, Y, Text) calls Canvas.TextOut while Textout(DstRect, Flags, Text) calls LCLIntf.DrawText passing the canvas handle as a parameter:

procedure TLCLBackend.Textout(X, Y: Integer; const Text: string);
begin
if Empty then
Exit;
UpdateFont;
if not FOwner.MeasuringMode then
Canvas.TextOut(X, Y, Text);
end;

procedure TLCLBackend.Textout(var DstRect: TRect; const Flags: Cardinal; const Text: string);
begin
if Empty then
Exit;
UpdateFont;
LCLIntf.DrawText(Canvas.Handle, PChar(Text), Length(Text), DstRect, Flags);
end;

The Canvas in the above is the TCanvas of an internally allocated TBitmap.
When the canvas/bitmap is modified (e.g by drawing text on them) the TLCLBackend.FCanvasDirty flag is set.
FCanvasDirty is checked in TLCLBackend.NeedBits. If FCanvasDirty is set then CopyCanvasToPixmap which copies pixel data from the canvas to the internal pixel buffer. NeedBits is called when TBitmap32 needs access to the internal pixel buffer.
Anyway, this apparently works.

My guess is that the problem simply is that LCLIntf.ExtTextOut(Canvas.Handle, ...) fails to call Changed on the canvas; In TLCLBackend.Textout and TLCLBackend.Textout after the call to LCLIntf.ExtTextOut(...) try adding a call to CanvasChanged.

from graphics32.

andersmelander avatar andersmelander commented on June 2, 2024

I made some additional changes that should improve performance of text output on GTK (if it compiles at all :-) )

from graphics32.

HannesBrockmann avatar HannesBrockmann commented on June 2, 2024

Hi Anders.

I now have rebuild all with the latest FPC_GTK sources.

Here the results.

@FIRST The TextOut now works!

some minor bugs i corrected:

###############################################################################

GR32_Lazarus.lpk

###############################################################################

Compile:

GR32_Backends_LCL_Gtk.pas(404,5) Error: Wrong number of parameters specified for call to "TextOut"

comes from:
GR32_Backends_LCL_Gtk.pas(403): Canvas.TextOut(X, Y, FOwner.ClipRect, Text)
... here Canvas is of type Graphics.TCanvas, which ownes ...
procedure TextOut(X,Y: Integer; const Text: String); virtual; {$IFDEF HasFPCanvas1}reintroduce;{$ENDIF}
procedure TextRect(const ARect: TRect; X, Y: integer; const Text: string);

changed to:
GR32_Backends_LCL_Gtk.pas(403): Canvas.TextRect(FOwner.ClipRect, X, Y, Text)


GR32_Backends_LCL_Gtk.pas(456,19) Error: Wrong number of parameters specified for call to "Copy"

comes from:
GR32_Backends_LCL_Gtk.pas(456): TextCopy := Copy(Text) // string must be writable
... here System.Copy needs 1-based Index and Count

changed to:
GR32_Backends_LCL_Gtk.pas(456): TextCopy := Copy(Text, 1, Length(Text))


GR32_Backends_LCL_Gtk.pas(516,11) Error: Identifier not found "PGtkWidget"

comes from:
GR32_Backends_LCL_Gtk.pas(44): gdk2, gdk2pixbuf, glib2, gtk2Def,
GR32_Backends_LCL_Gtk.pas(516): Widget: PGtkWidget;
... here PGtkWidget definition ist included in gtk2 unit

changed to:
GR32_Backends_LCL_Gtk.pas(44): gdk2, gdk2pixbuf, glib2, gtk2Def, gtk2


GR32_Backends_LCL_Gtk.pas(567,32) Error: Wrong number of parameters specified for call to "Max"

comes from:
GR32_Backends_LCL_Gtk.pas(567): AUpdateRects.Capacity := Max(AUpdateRects.Capacity, AUpdateRects.Count + AReservedCapacity + Count);
... here GR32_Lazarus.Max needs 3 parameters function Max(A,B,C:Integer):Integer;

changed to:
GR32_Backends_LCL_Gtk.pas(567): AUpdateRects.Capacity := Max(AUpdateRects.Capacity, AUpdateRects.Capacity, AUpdateRects.Count + AReservedCapacity + Count);


GR32.ImageFormats.TPicture.pas(127,32) Error: No matching implementation for interface method "LoadFromClipboardFormat(TCustomBitmap32;QWord;THandle;THandle):Boolean;" found

comes from
GR32.ImageFormats.TPicture.pas(42): {$ifdef FPC}
GR32.ImageFormats.TPicture.pas(43): LCLType,
GR32.ImageFormats.TPicture.pas(44): {$endif FPC}
GR32.ImageFormats.TPicture.pas(44): Classes,
GR32.ImageFormats.TPicture.pas(130): IImageFormatClipboardFormat)
GR32.ImageFormats.TPicture.pas(142): function LoadFromClipboardFormat(ADest: TCustomBitmap32; AFormat: TClipboardFormat; AData: THandle; APalette: THandle): boolean;
GR32.ImageFormats.TPicture.pas(227): function TImageFormatReaderTPicture.LoadFromClipboardFormat(ADest: TCustomBitmap32; AFormat: TClipboardFormat; AData: THandle; APalette: THandle): boolean;
... after many trys if found that LCLType has to be included behind Classes (like it is done for example in GR32.ImageFormats.TBitmap.pas )

changed to:
GR32.ImageFormats.TPicture.pas(42): Classes,
GR32.ImageFormats.TPicture.pas(43): {$ifdef FPC}
GR32.ImageFormats.TPicture.pas(44): LCLType,
GR32.ImageFormats.TPicture.pas(44): {$endif FPC}


Compile package GR32_Lazarus 2.0: Success, Hints: 2
Hint: Start of reading config file /home/hb/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.cfg
Hint: End of reading config file /home/hb/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.cfg
Verbose: Free Pascal Compiler version 3.2.2-r0d122c49 [2024/03/29] for x86_64
Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others
Verbose: Target OS: Linux for x86-64
Verbose: Compiling GR32_Lazarus.pas
Verbose: 23 lines compiled, 1.3 sec
Verbose: 2 hint(s) issued

###############################################################################

GR32_DSGN_Lazarus.lpk

###############################################################################

Compile:

Messages, Warnings: 2
Warning: other unit files search path (aka unit path) of "GR32_Lazarus 2.0" contains "/home/hb/Entwicklung/graphics32/Source", which belongs to package "GR32_DSGN_Lazarus"
Warning: other unit files search path (aka unit path) of "GR32_DSGN_Lazarus 2.0" contains "/home/hb/Entwicklung/graphics32/Source", which belongs to package "GR32_Lazarus"
Compile package GR32_DSGN_Lazarus 2.0: Success, Hints: 2
Hint: Start of reading config file /home/hb/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.cfg
Hint: End of reading config file /home/hb/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.cfg
Verbose: Free Pascal Compiler version 3.2.2-r0d122c49 [2024/03/29] for x86_64
Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others
Verbose: Target OS: Linux for x86-64
Verbose: Compiling GR32_DSGN_Lazarus.pas
GR32_DSGN_Lazarus.pas(10,13) Verbose: Unit "GR32_Dsgn_Misc" not used in GR32_DSGN_Lazarus
GR32_DSGN_Lazarus.pas(10,46) Verbose: Unit "GR32_Dsgn_Bitmap" not used in GR32_DSGN_Lazarus
Verbose: 22 lines compiled, 1.5 sec
Verbose: 4 hint(s) issued

Lazarus rebuilds without any errors.

Thank You.
We can Close this issue.

Hannes

from graphics32.

andersmelander avatar andersmelander commented on June 2, 2024

I'll close it when I have applied your changes :-)

from graphics32.

andersmelander avatar andersmelander commented on June 2, 2024

I have adapted your changes. If it still works (please test) then I will merge the branch and close the issue.

from graphics32.

HannesBrockmann avatar HannesBrockmann commented on June 2, 2024

1.try:
... Uninstall all GR32 stuff
... Compile package GR32_Lazarus 2.0: Success, Warnings: 57, Hints: 850
... Compile package GR32_DSGN_Lazarus 2.0: Success, Warnings: 9, Hints: 775
... Install (Rebuild Lazarus)
failed: GR32_Blend.pas(85,12) Error: Can't find unit GR32_Blend used by GR32

2.try:
... Uninstall all GR32 stuff
... Compile package GR32_DSGN_Lazarus 2.0: Success, Warnings: 8, Hints: 589
... Install (Rebuild Lazarus)
Success

GR32_Blend is still causing a problem
Did you understand why Classes has to be included before LCLType?

Greetings

from graphics32.

andersmelander avatar andersmelander commented on June 2, 2024

GR32_Blend is still causing a problem

Yes: #297
While the FPC_GTK branch design-time package can be installed right now, once it's merged into the master branch it will no longer be possible until #297 is fixed.

Did you understand why Classes has to be included before LCLType?

Yes; The declaration of THandle in Classes (via System) is incompatible with the declarations in LCLType. Why do you ask?

LCLType, // LCLType must be after Classes so we get the correct THandle

from graphics32.

HannesBrockmann avatar HannesBrockmann commented on June 2, 2024

Yes, I hadn't seen that

from graphics32.

andersmelander avatar andersmelander commented on June 2, 2024

Okay, so if there's no further changes required in this issue I will merge and close it.

from graphics32.

andersmelander avatar andersmelander commented on June 2, 2024

Thanks for the help with getting this working

from graphics32.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.