Graphics library rendering

15 posts / 0 new
Last post
alfkil
alfkil's picture
Offline
Last seen: 11 months 6 days ago
Joined: 2011-05-10 22:02
Graphics library rendering
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...
kas1e
kas1e's picture
Offline
Last seen: 4 months 6 days ago
Joined: 2010-11-30 15:30
@alkfil From my expirience i
@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.
Hans
Hans's picture
Offline
Last seen: 3 weeks 5 days ago
Joined: 2010-12-09 22:04
@kas1e I recall hearing that
@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
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project. http://keasigmadelta.co.nz/ - more of my software.
alfkil
alfkil's picture
Offline
Last seen: 11 months 6 days ago
Joined: 2011-05-10 22:02
@kas1e So is your own
@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.
alfkil
alfkil's picture
Offline
Last seen: 11 months 6 days ago
Joined: 2011-05-10 22:02
@Hans Yes, that is probably
@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.
kas1e
kas1e's picture
Offline
Last seen: 4 months 6 days ago
Joined: 2010-11-30 15:30
@alfkil So is your own
@alfkil
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.
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.
I would need gl or cairo for that
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 ?
salass00
salass00's picture
Offline
Last seen: 1 month 5 days ago
Joined: 2011-02-03 11:27
@alfkil Yes, that is
@alfkil
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.
The AmigaOS 4.x DrawGradient() function is in intuition.library for some reason so you have to look it up in the intuition autodoc.
alfkil
alfkil's picture
Offline
Last seen: 11 months 6 days ago
Joined: 2011-05-10 22:02
@salass00 Huh? That's odd!
@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?
alfkil
alfkil's picture
Offline
Last seen: 11 months 6 days ago
Joined: 2011-05-10 22:02
Also, I am having a bit of a
Also, I am having a bit of a problem with CompositeTags: I want to translate a piece of code from ClipBlit to CompositeTags:
  1. #if 1
  2. IGraphics->ClipBlit(px.rastport(), sx, sy,
  3. d->rastport,
  4. x, y,
  5. sw, sh,
  6. 0xc0);
  7. #else
  8. uint32 result = IGraphics->CompositeTags(COMPOSITE_Src_Over_Dest, px.rastport()->BitMap, d->rastport->BitMap,
  9. COMPTAG_SrcX, sx,
  10. COMPTAG_SrcY, sy,
  11. COMPTAG_SrcWidth, sw,
  12. COMPTAG_SrcHeight, sh,
  13. COMPTAG_DestX, x,
  14. COMPTAG_DestY, y,
  15. COMPTAG_DestWidth, sw,
  16. COMPTAG_DestHeight,sh,
  17. COMPTAG_Flags, COMPFLAG_HardwareOnly,
  18. TAG_DONE);
  19. #endif
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??
Hans
Hans's picture
Offline
Last seen: 3 weeks 5 days ago
Joined: 2010-12-09 22:04
@alfkil Yes, that is probably
@alfkil
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.
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
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project. http://keasigmadelta.co.nz/ - more of my software.
Hans
Hans's picture
Offline
Last seen: 3 weeks 5 days ago
Joined: 2010-12-09 22:04
@alfkil Try
@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
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project. http://keasigmadelta.co.nz/ - more of my software.
Hans
Hans's picture
Offline
Last seen: 3 weeks 5 days ago
Joined: 2010-12-09 22:04
@alfkil On a somewhat
@alfkil
On a somewhat related note: Is it possible to have ClipBlit account for an alpha channel, or do I need CompositeTags for that?
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
http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more. Home of the RadeonHD driver for Amiga OS 4.x project. http://keasigmadelta.co.nz/ - more of my software.
alfkil
alfkil's picture
Offline
Last seen: 11 months 6 days ago
Joined: 2011-05-10 22:02
Ok I found out: One has to
Ok I found out: One has to use COMPTAG_OffsetX/Y instead of COMPTAG_DestX/Y... Confusing!
alfkil
alfkil's picture
Offline
Last seen: 11 months 6 days ago
Joined: 2011-05-10 22:02
@Hans Thanks for all the
@Hans Thanks for all the info, I am a documentation bloop at times, so it is nice that someone can point the right way ;-).
chris
chris's picture
Offline
Last seen: 1 year 3 months ago
Joined: 2012-02-16 22:30
Cairo as supplied with OS4.1
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.
Log in or register to post comments