What is the easiest and fastest way to render a rectangle with outline and rounded corners with graphics.library?
Also, is there some smart way of rendering a gradient with gfx.library??
Explanation: I need a rendering engine for Qt that doesn't use opengl. Does our libcairo implementation use opengl??
EDIT: Apparently libcairo does not use opengl. But is it hardware accelerated or not? If not, I will not go through the trouble of creating an entire graphicssystem from scratch, might as well just use the Qt raster engine...
@alkfil
From my expirience i found that version of cairo which come with aos4 SDK (and includes from), are slower than my own custom build which use pixmap1. What make me think that even if cairo in SDK are HW accelerated somehow, its still do something bad/wrong. That all was in terms of muiowb, and all the testing i do was in that terms, but, as well as i remember, even joerg with his ra-owb, use his own custom cairo build and i think by the same reassons. The best way will be of course make a test cases to see the speed differences beetwen SDK version of cairo and custom builded one. For me, my own, was faster. Maybe i do something wrong through, but test cases should give us truth.
@kas1e
I recall hearing that the way that OWB uses Cairo counter-acts the benefits of the hardware acceleration. Basically, it ends up copying bitmaps between RAM and VRAM so often that it is faster to render it all in software and then copy it to VRAM once.
I cannot remember the details as to why but, from memory, it wasn't something that was easily fixed.
@alfkil
The graphics.library isn't very good at rounded edges to rectangular shapes. The outline can be done using Move() and Draw() (you'll have to approximate the rounded edges with line segments).
For the fill, you might be able to use AreaMove(), AreaDraw(), and AreaEnd() to do the fill, but I'm not sure how HW accelerated that would be. If you used RectFill() for the bulk of the fill, it might not matter too much. Alternatively, create a small bitmap with the desired fill colour, and use CompositeTags() with a vertex array to do the fill. The small bitmap would be the source "texture."
IMPORTANT: There is no software fallback for CompositeTags() with vertex arrays for graphics cards that don't support it. You will have to check for a failure (set the HW only flag to be on the safe side), and provide your own backup rendering routine.
Hans
Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work
@kas1e
So is your own version of cairo hw accelerated, or is it just software renderer?? If it is, then I am definitely interested in having a copy of it.
@Hans
Yes, that is probably how I am going to do it. I don't see any way of having graphics.library produce a gradient fill, I would need gl or cairo for that.
@alfkil
No no, my version is sw one , i just point out that version from sdk not looks like hw accelerated one, and in terms of owb the best choice was to use sw one, as it was faster by result. Maybe there is differences about which Hans say, and just need to test by test cases one from SDK, and one custom done (cairo + pixmap1). Also i remember that version of cairo in latest sdk are quite old, and year ago brothers say and show some benchmarks of their latest hw accelerated cairo, which, imho, still not available for us (as the version which we have quite old by date of creating). Imho only 2 different tests (one for sdk's cairo, and one for custom build) can show the differences by speed and show the truth.
Cairo way imho will be faster, as even with sw version it fast enough (owb is good example imho). Btw, maybe you somehow can use compositing as well ?
@alfkil
The AmigaOS 4.x DrawGradient() function is in intuition.library for some reason so you have to look it up in the intuition autodoc.
@salass00
Huh? That's odd! Let me check that out! :-)
On a somewhat related note: Is it possible to have ClipBlit account for
an alpha channel, or do I need CompositeTags for that?
Also, I am having a bit of a problem with CompositeTags: I want to translate a piece
of code from ClipBlit to CompositeTags:
If set to 1 it "works" (appart from alpha blend not working), but if set to 0 it only displays the background and nothing else... What am I doing wrong??
@alfkil
DrawGradient() has already been pointed out to you. However, I don't think that this function is HW accelerated. However, if you render the gradient to a bitmap, and use that as the source for a CompositeTags() operation, you can do quite fancy gradient fills.
Hans
Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work
@alfkil
Try adding:
COMPTAG_OffsetX, x,
COMPTAG_OffsetY, y,
If you read the documentation carefully, you'll discover that COMPTAG_DestX, COMPTAG_DestY, COMPTAG_DestWidth, and COMPTAG_DestHeight set a clipping rectangle in the destination bitmap. Those tags do NOT set the offset to where rendering will take place. You need to set COMPTAG_OffsetX, and COMPTAG_OffsetY to set where to render to. You don't even need to set the clipping rectangle, as it will default to the whole destination bitmap.
COMPTAG_DestX, COMPTAG_DestY, COMPTAG_DestWidth, and COMPTAG_DestHeight are more useful when you're rendering vertex arrays and want the result to be clipped to a specific region.
Hans
Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work
@alfkil
I'm not sure exactly what you're asking, but only CompositeTags() uses alpha channels. Other operations may copy the alpha channel verbatim, but won't use it for transparency (or compositing operations). Another caveat is that the graphics library's RectFill() won't set the alpha channel (IIRC), and so you should use Picasso96's fill rect function.
Hans
Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work
Ok I found out: One has to use COMPTAG_OffsetX/Y instead of COMPTAG_DestX/Y... Confusing!
@Hans
Thanks for all the info, I am a documentation bloop at times, so it is nice that someone can point the right way ;-).
Cairo as supplied with OS4.1 (ie. the SObj version) does have hardware acceleration. The accelerated version was supplied with the update which preceded the original Timberwolf Alpha version. I don't know how much acceleration it has, but it is definitely faster than the first version of Cairo.