View Issue Details

IDProjectCategoryView StatusLast Update
0023168LazarusLCLpublic2013-06-09 14:08
ReporterKrzysztof DibowskiAssigned ToPaul Ishenin 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.0.3 (SVN)Product Build 
Target VersionFixed in Version1.2.0 
Summary0023168: Latest changes in GTK2 changed drawing rules
DescriptionAre some serious changes implementing in GTK interface right now? I'm
the author and maintainer of BGRA Controls package which are using
BGRA Bitmap package for drawing. Issues:

1. First, I can't compile BGRA Bitmap package without comment line:

{ifdef LCL_GTK2}
type TGtkDeviceContext = TGtk2DeviceContext;
{$endif}

What happened with TGtk2DeviceContext? This same with other non-BGRA
controls like VirtualTreeView (but there is more GTK errors than only
TGtk2DeviceContext )

2. BGRA Controls are using simple BGRA Bitmap api for drawing:
BGRABitmap.Draw(Canvas, 0,0,false). This code worked from a several
years, but now seems that GTK coordinates are different. If I drag (or
in runtime) some BGRA Control on center of the form, I don't see what
is drawed, just transparent frame, but If I move control to left-top
corner then I see control body. Seems that GTK is starting drawing
from form canvas, not control.

I notified this a few days ago, I thought that this is some temporary
issue, but with today trunk is the same problem.

Regards, Dibo
Additional InformationI attached simple demo:

1. You must install BGRA Bitmap package first (tested on version 6.1 and oldes) from https://sourceforge.net/projects/lazpaint/files/src/
2. Run attached demo
3. You will see small rectangle in top-left corner. This is paint box.
4. Now got to design form and move paint box to the center of the form and run program. Rectangle is now unvisible

Ubuntu 12.10 64bit GTK (Unity), Lazarus from svn trunk, fpc 2.6.0
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files

Activities

2012-10-20 17:10

 

bgra_offset.zip (2,749 bytes)

Zeljan Rikalo

2012-10-20 17:24

developer   ~0063317

Paul changed some stuff in gtk2 recently.
This one removed TGtk2DeviceContext:
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/gtk2/gtk2def.pp?root=lazarus&r1=38728&r2=38742

Paul Ishenin

2012-10-20 17:34

manager   ~0063318

is it possible to create an example without extra dependencies?

Krzysztof Dibowski

2012-10-20 18:34

reporter   ~0063321

Probably not, because LCL Canvas.Draw working ok. BGRABitmap is first additional package where I noticed this. Don't know where is the problem (in LCL_GTK or in BGRABitmap), but BGRABitmap.Draw(Canvas,0,0,False) worked fine from a several years.

Zeljan Rikalo

2012-10-21 11:11

developer   ~0063340

@Krzysztof, does Qt work ok with BGRABitmap (mean BGRABitmap.Draw()), it uses painter offset from the beginning ?

Krzysztof Dibowski

2012-10-21 11:55

reporter   ~0063343

I can prepare virtualbox KDE image and check this, but this take a while. I let you know. BTW: Users says that on windows is ok

Zeljan Rikalo

2012-10-21 12:00

developer   ~0063344

why virtualbox for that ? Isn't enough to install qt libs and libQt4Pas to get it work ?

Zeljan Rikalo

2012-10-21 12:04

developer   ~0063345

r39148 - added deprecated TGtk2DeviceContext.

Krzysztof Dibowski

2012-10-21 12:32

reporter   ~0063346

Ok, I did some test. On QT everything working fine. BGRABitmap.Draw() working like before.

I updated to r39148. Now I can compile BGRABitmap without comment TGtk2DeviceContext type, but still are problems with drawing

Zeljan Rikalo

2012-10-21 13:24

developer   ~0063348

Maybe something in some Gtk2WidgetSet function needs coord translation (or have double coord translation of context). Why simple project with TBitmap cannot show problem ?

Krzysztof Dibowski

2012-10-21 13:37

reporter   ~0063349

I tried to contact with author of BGRABitmap by posting issue on forum:
http://www.lazarus.freepascal.org/index.php/topic,18618.0.html

But he have no idea what it is. What I know he don't have Linux GTK to test it

Krzysztof Dibowski

2012-10-22 16:17

reporter   ~0063379

I think I fixed it. Bgraitmap using this api for drawing:

  gdk_pixbuf_render_to_drawable(FPixBuf,
    TGtkDeviceContext(ACanvas.Handle).Drawable,
    TGtkDeviceContext(ACanvas.Handle).GC,
    0,0,
    TGtkDeviceContext(ACanvas.Handle).Offset.X+Rect.Left,
    TGtkDeviceContext(ACanvas.Handle).Offset.y+Rect.Top,
    Width,Height,
    GDK_RGB_DITHER_NORMAL,0,0);

I changed to:

  gdk_pixbuf_render_to_drawable(FPixBuf,
    TGtkDeviceContext(ACanvas.Handle).Drawable,
    TGtkDeviceContext(ACanvas.Handle).GC,
    0,0,
    TGtkDeviceContext(ACanvas.Handle).ClipRect.X+Rect.Left,
    TGtkDeviceContext(ACanvas.Handle).ClipRect.y+Rect.Top,
    Width,Height,
    GDK_RGB_DITHER_NORMAL,0,0);

Seems that before Offset had some values, but now X and Y are 0. I changed to ClipRect and now it is working. Why offset is now 0? What should be used?

Paul Ishenin

2012-11-02 01:05

manager   ~0063624

You are still writing the wrong code. It is seems to me that you need logical corrdinates (they are based on device corrds but includes affine transformations). So instead of working with clipping you need to do the next thing:
P := Rect.TopLeft;
DpToLP(ACanvas.Handle, @P, 1);
gdk_pixbuf_render_to_drawable(FPixBuf,
    TGtkDeviceContext(ACanvas.Handle).Drawable,
    TGtkDeviceContext(ACanvas.Handle).GC,
    0,0,
    TGtkDeviceContext(ACanvas.Handle).Offset.X + P.X,
    TGtkDeviceContext(ACanvas.Handle).Offset.Y + P.Y,
    Width,Height,
    GDK_RGB_DITHER_NORMAL,0,0);

Offset is not always equals to (0,0) but now it does not include window origin (which was the case in past).

Krzysztof Dibowski

2012-11-05 11:48

reporter   ~0063674

Your code almost work :)

This code:

var
  p: TPoint;


  p := Rect.TopLeft;
  DpToLP(ACanvas.Handle, P, 1);


Return correct points but in negative value. I must use Abs() function:

  gdk_pixbuf_render_to_drawable(FPixBuf,
    TGtkDeviceContext(ACanvas.Handle).Drawable,
    TGtkDeviceContext(ACanvas.Handle).GC,
    0,0,
    TGtkDeviceContext(ACanvas.Handle).Offset.X+abs(P.X),
    TGtkDeviceContext(ACanvas.Handle).Offset.Y+abs(P.Y),
    Width,Height,
    GDK_RGB_DITHER_NORMAL,0,0);

Paul Ishenin

2012-12-28 10:22

manager   ~0064512

I don't know in which coords you are working. Maybe instead you need to transform logical coords to device. Then use LPtoDP function.

Paul Ishenin

2013-06-09 14:08

manager   ~0068154

I think the issue is already fixed. Moreover there is no more feedback.

Issue History

Date Modified Username Field Change
2012-10-20 17:10 Krzysztof Dibowski New Issue
2012-10-20 17:10 Krzysztof Dibowski File Added: bgra_offset.zip
2012-10-20 17:10 Krzysztof Dibowski Widgetset => GTK 2
2012-10-20 17:24 Zeljan Rikalo Note Added: 0063317
2012-10-20 17:34 Paul Ishenin Note Added: 0063318
2012-10-20 18:34 Krzysztof Dibowski Note Added: 0063321
2012-10-21 11:11 Zeljan Rikalo Note Added: 0063340
2012-10-21 11:55 Krzysztof Dibowski Note Added: 0063343
2012-10-21 12:00 Zeljan Rikalo Note Added: 0063344
2012-10-21 12:04 Zeljan Rikalo LazTarget => -
2012-10-21 12:04 Zeljan Rikalo Note Added: 0063345
2012-10-21 12:04 Zeljan Rikalo Status new => feedback
2012-10-21 12:32 Krzysztof Dibowski Note Added: 0063346
2012-10-21 13:24 Zeljan Rikalo Note Added: 0063348
2012-10-21 13:37 Krzysztof Dibowski Note Added: 0063349
2012-10-22 16:17 Krzysztof Dibowski Note Added: 0063379
2012-11-02 01:05 Paul Ishenin Status feedback => resolved
2012-11-02 01:05 Paul Ishenin Fixed in Version => 1.2.0
2012-11-02 01:05 Paul Ishenin Resolution open => no change required
2012-11-02 01:05 Paul Ishenin Assigned To => Paul Ishenin
2012-11-02 01:05 Paul Ishenin Note Added: 0063624
2012-11-05 11:48 Krzysztof Dibowski Status resolved => assigned
2012-11-05 11:48 Krzysztof Dibowski Resolution no change required => reopened
2012-11-05 11:48 Krzysztof Dibowski Note Added: 0063674
2012-12-28 10:22 Paul Ishenin Note Added: 0064512
2013-06-09 14:08 Paul Ishenin Note Added: 0068154
2013-06-09 14:08 Paul Ishenin Status assigned => resolved
2013-06-09 14:08 Paul Ishenin Resolution reopened => fixed