Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NgLop-0005yL-2s for mharc-grub-devel@gnu.org; Sat, 13 Feb 2010 12:30:11 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NgLon-0005yF-J0 for grub-devel@gnu.org; Sat, 13 Feb 2010 12:30:09 -0500 Received: from [140.186.70.92] (port=56464 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NgLom-0005y7-00 for grub-devel@gnu.org; Sat, 13 Feb 2010 12:30:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NgLoi-0006ve-Oh for grub-devel@gnu.org; Sat, 13 Feb 2010 12:30:07 -0500 Received: from mail-fx0-f217.google.com ([209.85.220.217]:59555) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NgLoi-0006vN-Eo for grub-devel@gnu.org; Sat, 13 Feb 2010 12:30:04 -0500 Received: by fxm9 with SMTP id 9so22158fxm.30 for ; Sat, 13 Feb 2010 09:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:from:date:x-google-sender-auth:message-id:subject:to :content-type:content-transfer-encoding; bh=rW8unUXAGwfJuWlq0OFL+PkZXT/P1T+hQtMYzExVdBo=; b=ba13+m3KDqZTSEJitPCpzjhLsfDeHS8PGy1tStdGDjW5fcFZ3ajZisDUCv5eiQVBNA DGE+6o2MHfnRvBL46RnUCF9onr+sH2ArCVqY0HkzBnNKf4R4czP7813YobLBXPqxp2oC jFBWH/W1EY0IC9eVCafu7hH1VO8XDRBZKLWlA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; b=HOun8qaiUzSSnIsKO0yftdYzQqTW2BqDv62Ax+Cc2HWy9KLHmtoDz7B8UsoQBiZBAD //q43leh95452uLeCwpN+dp5iDG6KKfodthszz7fGkVJE3B+ZV2416Z8Dw3WlwYZGibk NoMexlLuljPLfHmzFZpKLYy1DRJjoy9vZWrkE= MIME-Version: 1.0 Sender: hramrach@gmail.com Received: by 10.239.177.211 with SMTP id w19mr320809hbf.162.1266082201118; Sat, 13 Feb 2010 09:30:01 -0800 (PST) In-Reply-To: <4B742B70.3080303@gmail.com> References: <4B736F82.7010005@gmail.com> <4B742B70.3080303@gmail.com> From: Michal Suchanek Date: Sat, 13 Feb 2010 18:29:41 +0100 X-Google-Sender-Auth: 6f8fcc24d74c844e Message-ID: To: The development of GNU GRUB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [RFC] Framebuffer rotation patch X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Feb 2010 17:30:09 -0000 2010/2/11 Vladimir '=CF=86-coder/phcoder' Serbinenko : > Michal Suchanek wrote: >> 2010/2/11 Vladimir '=CF=86-coder/phcoder' Serbinenko = : >> >>> Michal Suchanek wrote: >>> >>>> Hello >>>> >>>> Sending a preliminary framebuffer rotation patch. >>>> >>>> You can use videotest to see 4 tiles rotated from the same bitmap data= . >>>> >>>> >>>> >>> +char leaf_data[] =3D { 0x00, 0x0f, 0xe0, 0x00, >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= 0x00, 0x7f, 0xfc, 0x00, >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= 0x01, 0xff, 0xff, 0x00, >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= 0x03, 0xff, 0xff, 0x80, >>> This is a blob. Could it be generated automatically at build time? >>> >> >> How less of a blob it would be if it was included as a bitmap? >> >> > It's not easily editable in current form. >> This is just a shape used for the video tests. >> >> There are some X tools for working with bitmaps/pixmaps which could >> generate this from a viewable file but they are usually not available >> on Windows and other non-X platforms AFAIK. >> >> > Using XBM is fine (it's easily editable in either gimp or emacs) and you > should be able to > #include "leaf1.xbm" That would work if XBM and grub did not have opposite bit order. The bytes are ordered the same but the bits are reversed. >>> Could you split addition of videotests from the rest of the patch? Yes, there should be no problem with that. >>> - =C2=A0 =C2=A0unsigned int x; >>> - =C2=A0 =C2=A0unsigned int y; >>> - =C2=A0 =C2=A0unsigned int width; >>> - =C2=A0 =C2=A0unsigned int height; >>> + =C2=A0 =C2=A0int x; >>> + =C2=A0 =C2=A0int y; >>> + =C2=A0 =C2=A0int width; >>> + =C2=A0 =C2=A0int height; >>> Why do you need negative values? >>> >> >> I don't need the negative values everywhere but this change was to >> align the typing so that casts are not required. >> >> > Perhaps few casts together with appropiate checks when casting is better > than potentially exposing the whole code to the values it's not intended > for. How is it exposed to more unwanted values than now? It uses the variables only to store the viewport dimensions and at most adds a border around it. The unsigned integer is able to represent values outside of the viewport as much as signed integers are, only signed integer can represent values outside of viewport in both directions. The unwanted values (if erroneously calculated which does not seem to be the case here) are clipped by the viewport clipping in video_fb. On the other hand, there would be more than a few casts as the variables are used multiple times and the interface now uses signed integers. >>> +/* Supported operations are simple and easy to understand. >>> + * MIRROR =C2=A0| =C2=A0swap image across (around) the vertical axis >>> + * FLIP =C2=A0 =C2=A0- =C2=A0swap image across the horizontal axis - u= pside down >>> + * SWAP =C2=A0 =C2=A0/ =C2=A0swap image across the x=3Dy axis - swap t= he x and y coordinates >>> It's just a D_8 group. Could you add a comment to functions what they d= o >>> in group theoretical sense? It would make the code easier to follow and >>> >> >> Obviously it is a group, > >> any set of transforms closed on composition is. >> >> > Not true. Consider an example of empty set: it has no identity element. > Less trivial counter-example: set of transformations: (x,y)->(kx,ky), > 0 with <=3D1 you will have an identity element but no other element is > invertible. It depends on your exact definition of group which somewhat varies but it is true that most definitions at least require the set to be non-empty. >> >> If you have clearer explanation or more efficient code please share. >> >> > I was thinking of using 2 generators instead of 3: > 1) standard generators: s=3Drot90 or rot270, t=3Dany reflection. Then all > elements are s^k or s^k*t. It makes computation of composition easier. > Rules on generators are: > s^n=3Dt^2=3D1 > tst=3Ds^{-1} > 2) or using 2 reflections. E.g. u=3D| and v=3D/. You already figured how = to > generate with u=3D|, v=3D/, w=3D- > But w=3Duvuv > Then rules of computation are: > u^2=3Dv^2=3D(uv)^4=3D1 This might be mathematically optimal but how that maps to actual efficient = code? In my view the v (and s) operations are expensive so I want to avoid them if possible. This requires that both u and w be in the chosen set of generators because otherwise use of v or s twice is required to get one from the other. Using (u or w) and v as the two basic operations additionally requires composing generators in non-fixed order to get all the 8 possible combinations. The other reason for having 3 generators is clear and efficient reperesentation of the 8 possible transformations. They are represented as bits in the bitmap where each bit specifies if the particular basic transform is included or not but they are always applied in fixed order and at most once. Compare this to your representation of s^k,s^k*t where k is 0..3. Depending on representation the composition and inversion rules might still be somewhat non-trivial in actual code, using two reflections which require multiple applications of the two generators in particular order would lead to even more "interesting" code. >>> +static inline long >>> +grub_min (long x, long y) >>> +{ >>> + =C2=A0if (x > y) >>> + =C2=A0 =C2=A0return y; >>> + =C2=A0else >>> + =C2=A0 =C2=A0return x; >>> +} >>> + >>> Same here >>> + >>> + =C2=A0int transform; >>> I would prefer an enum >>> >> >> This is a bit field. How does it transform into an enum? >> > enum my_bitfield > { > =C2=A0MY_BITFIELD_NONE=3D0, > =C2=A0MY_BITFIELD_BIT0 =3D 1 << 0, > =C2=A0MY_BITFIELD_BIT1 =3D 1 << 1, > =C2=A0MY_BITFIELD_BIT2 =3D 1 << 2 > }; The whole point of a bitfield is to have values like MY_BITFIELD_1_AND_2 =3D MY_BITFIELD_BIT1 | MY_BITFIELD_BIT2 which enum does not allow. Thanks Michal