Bug 28122 - [Haiku] Adding some simple graphic files (IntPoint, IntRect…)
Summary: [Haiku] Adding some simple graphic files (IntPoint, IntRect…)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Other
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-09 05:10 PDT by Maxime Simon
Modified: 2009-08-12 13:16 PDT (History)
2 users (show)

See Also:


Attachments
Patch to add eight graphic files. (21.60 KB, patch)
2009-08-09 05:16 PDT, Maxime Simon
eric: review-
Details | Formatted Diff | Diff
Patch to add eight graphic files for WebCore/platform/graphics/haiku. (21.42 KB, patch)
2009-08-09 11:20 PDT, Maxime Simon
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Simon 2009-08-09 05:10:52 PDT
Here is a patch to add 8 simple files:
WebCore/platform/graphics/haiku/ColorHaiku.cpp
WebCore/platform/graphics/haiku/FloatPointHaiku.cpp
WebCore/platform/graphics/haiku/FloatRectHaiku.cpp
WebCore/platform/graphics/haiku/GradientHaiku.cpp
WebCore/platform/graphics/haiku/IntPointHaiku.cpp
WebCore/platform/graphics/haiku/IntRectHaiku.cpp
WebCore/platform/graphics/haiku/IntSizeHaiku.cpp
WebCore/platform/graphics/haiku/PathHaiku.cpp

Regards,
Maxime
Comment 1 Maxime Simon 2009-08-09 05:16:50 PDT
Created attachment 34407 [details]
Patch to add eight graphic files.
Comment 2 Eric Seidel (no email) 2009-08-09 07:46:50 PDT
Comment on attachment 34407 [details]
Patch to add eight graphic files.

What does the color struct look like?  Could you just use a COMPILE_ASSERT to assert identical layout with the WebCore:RGBA32 type and not need to call make_color, etc?

See how I did things in ColorSkia (where we just cast directly).  Your current solution is *totally fine*.  I just wanted to bring the opportunity of casting directly to your attention.

Why are the +1 needed for one way conversion:
 38     , m_size(rect.Width() + 1, rect.Height() + 1)

and -1 is not needed the other way:
 44     return BRect(BPoint(x(), y()), BSize(width(), height()));

That at least needs a comment.

It seems if BPoint is a float point you don't want to have it implicitly constructed.
 IntPoint::IntPoint(const BPoint& point)
 37     : m_x(static_cast<int>(point.x))
 38     , m_y(static_cast<int>(point.y))
 39 {
 40 }

See how CGPoint is handled.

Yeah, it seems that BRect, BPoint, BSize should only map to the Float* variants (similar to how CG* works).  Why a FIXME here, but not before?
42 IntRect::operator BRect() const
 43 {
 44     // FIXME: subtract 1 from height and width?
 45     return BRect(BPoint(x(), y()), BSize(width(), height()));
 46 }

Parts of this would be easy to approve.  I think you need to double-check how you do the B* to Float*/Int* conversions.  Since it seems that B* are all floating-point values, you can follow exactly what the CG* types do, since those are all floating point values.
Comment 3 Eric Seidel (no email) 2009-08-09 07:47:30 PDT
The parts that I didn't comment on could be split out into a separate patch if you wanted quicker approval there.  This patch is definitely reviewable at this size however (it's mostly boilerplate).
Comment 4 Maxime Simon 2009-08-09 09:50:09 PDT
(In reply to comment #2)
> (From update of attachment 34407 [details])
> What does the color struct look like?  Could you just use a COMPILE_ASSERT to
> assert identical layout with the WebCore:RGBA32 type and not need to call
> make_color, etc?

Indeed rgb_color is a struct of { red, green, blue, alpha } like WebCore::RGBA32, So I should change this.

> Why are the +1 needed for one way conversion:
>  38     , m_size(rect.Width() + 1, rect.Height() + 1)
> 
> and -1 is not needed the other way:
>  44     return BRect(BPoint(x(), y()), BSize(width(), height()));

I assume that the +1/-1 are from the previous port and are what was done in the Syllable port. But I'm pretty sure they aren't necessary.

> It seems if BPoint is a float point you don't want to have it implicitly
> constructed.
>  IntPoint::IntPoint(const BPoint& point)
>  37     : m_x(static_cast<int>(point.x))
>  38     , m_y(static_cast<int>(point.y))
>  39 {
>  40 }
> 
> See how CGPoint is handled.

In CGPoint they used a static_cast as I did. :D

> I think you need to double-check how
> you do the B* to Float*/Int* conversions.  Since it seems that B* are all
> floating-point values, you can follow exactly what the CG* types do, since
> those are all floating point values.

I know that both BRect and BSize have IntegerWidth() and IntegerHeight() methods, but BPoint needs a cast to int.
That's what I used, but I will check again, and at least remove the +1/-1.
Comment 5 Maxime Simon 2009-08-09 10:35:57 PDT
(In reply to comment #2)
> (From update of attachment 34407 [details])
> What does the color struct look like?  Could you just use a COMPILE_ASSERT to
> assert identical layout with the WebCore:RGBA32 type and not need to call
> make_color, etc?
> 
> See how I did things in ColorSkia (where we just cast directly).  Your current
> solution is *totally fine*.  I just wanted to bring the opportunity of casting
> directly to your attention.

ColorSkia? I do not want to sound boring, but there is no such file.
In fact I was wrong, I can't cast an unsigned (RGBA32) to a struct of unsigned (rgb_color). So it would still use the make_color function.
Comment 6 Maxime Simon 2009-08-09 11:20:43 PDT
Created attachment 34426 [details]
Patch to add eight graphic files for WebCore/platform/graphics/haiku.
Comment 7 Ryan Leavengood 2009-08-09 11:28:53 PDT
(In reply to comment #5)
> 
> ColorSkia? I do not want to sound boring, but there is no such file.

I don't see that either.

> In fact I was wrong, I can't cast an unsigned (RGBA32) to a struct of unsigned
> (rgb_color). So it would still use the make_color function.

Are you sure? Doing a cast instead of calling a function would probably be
faster and I'm sure this conversion would need to be done a lot.

Eric, our rgb_color struct is defined here:

http://svn.berlios.de/viewcvs/haiku/haiku/trunk/headers/os/interface/GraphicsDefs.h?revision=25797&view=markup

Since this is C++ code the rgb_color struct is essentially a public class, so
maybe it can't be just cast even if the members are in the same order (then of
course there is endianness, which may also be an issue, right?)

I am not particularly skilled at the moment on these low-level types of issues
(too much Ruby, HTML and JavaScript these last few years), so any insight is
appreciated.

Also in regards to all the BRect and IntRect stuff, that probably does need an
audit.
Comment 8 Eric Seidel (no email) 2009-08-09 11:51:34 PDT
Note that the CG constructors are explicit:
    explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
Comment 10 Eric Seidel (no email) 2009-08-12 10:37:38 PDT
Comment on attachment 34426 [details]
Patch to add eight graphic files for WebCore/platform/graphics/haiku.

OK.
Comment 11 Eric Seidel (no email) 2009-08-12 13:16:28 PDT
Comment on attachment 34426 [details]
Patch to add eight graphic files for WebCore/platform/graphics/haiku.

Clearing flags on attachment: 34426

Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	WebCore/ChangeLog
	A	WebCore/platform/graphics/haiku/ColorHaiku.cpp
	A	WebCore/platform/graphics/haiku/FloatPointHaiku.cpp
	A	WebCore/platform/graphics/haiku/FloatRectHaiku.cpp
	A	WebCore/platform/graphics/haiku/GradientHaiku.cpp
	A	WebCore/platform/graphics/haiku/IntPointHaiku.cpp
	A	WebCore/platform/graphics/haiku/IntRectHaiku.cpp
	A	WebCore/platform/graphics/haiku/IntSizeHaiku.cpp
	A	WebCore/platform/graphics/haiku/PathHaiku.cpp
Committed r47142
	M	WebCore/ChangeLog
	A	WebCore/platform/graphics/haiku/PathHaiku.cpp
	A	WebCore/platform/graphics/haiku/GradientHaiku.cpp
	A	WebCore/platform/graphics/haiku/ColorHaiku.cpp
	A	WebCore/platform/graphics/haiku/FloatPointHaiku.cpp
	A	WebCore/platform/graphics/haiku/FloatRectHaiku.cpp
	A	WebCore/platform/graphics/haiku/IntPointHaiku.cpp
	A	WebCore/platform/graphics/haiku/IntSizeHaiku.cpp
	A	WebCore/platform/graphics/haiku/IntRectHaiku.cpp
r47142 = e4c305eb83f3dda05416b0db9336be7cd0e99ba8 (trunk)
No changes between current HEAD and refs/remotes/trunk
Resetting to the latest refs/remotes/trunk
http://trac.webkit.org/changeset/47142
Comment 12 Eric Seidel (no email) 2009-08-12 13:16:33 PDT
All reviewed patches have been landed.  Closing bug.