Closed
Bug 714416
Opened 13 years ago
Closed 13 years ago
Support multiple screen orientations in gonk backend
Categories
(Core :: Widget, defect)
Tracking
()
RESOLVED
FIXED
mozilla13
People
(Reporter: cjones, Assigned: mwu)
References
Details
(Keywords: dev-doc-complete, Whiteboard: [not-fennec-11])
Attachments
(4 files, 7 obsolete files)
7.28 KB,
patch
|
mwu
:
review+
|
Details | Diff | Splinter Review |
2.36 KB,
patch
|
Details | Diff | Splinter Review | |
8.64 KB,
patch
|
Details | Diff | Splinter Review | |
1.93 KB,
patch
|
Details | Diff | Splinter Review |
The gonk widget backend is the source of truth about screen orientation on b2g. The screen will have a default orientation decided by the display hardware. Beyond that, we need to support the screen rotated by 90, 180, and 270 degrees. (The orientation is portrait if width<height, landscape otherwise. This is separate from rotation.)
When the rotation changes, we need to resize gecko's view of the screen and window(s). There are some fancy things we can do here that should go in followups.
I have a pretty dumb prototype that implements rotation using transforms, but in some cases we may be able to use HW support for screen rotation. Work for followups, if needed.
Reporter | ||
Comment 1•13 years ago
|
||
Attachment #585118 -
Flags: superreview?(roc)
Attachment #585118 -
Flags: superreview?(roc) → superreview+
Reporter | ||
Comment 2•13 years ago
|
||
Patches written, just need to test them.
Assignee: nobody → jones.chris.g
Reporter | ||
Comment 3•13 years ago
|
||
Having these in separate files is just getting in the way. Would require grosser hacks to maintain separation for later patches.
Works fine.
Reporter | ||
Comment 4•13 years ago
|
||
Fixes the hard-codings of gScreenSize that break code when we rotate the screen. Should mostly work, might have missed a spot or two.
Reporter | ||
Comment 5•13 years ago
|
||
This is very WIP. It implements rotation for when we're using GL, but no impl for CPU.
There's some testing code in here that rotates the screen every 5 seconds off of a timer. As can be seen, it doesn't work correctly: something is not being resized correctly after rotation. Fixing that and implementing rotation of the memmapped framebuffer are the two TODOs left here.
Reporter | ||
Comment 6•13 years ago
|
||
Stepping down for the time being. mwu, faramarz is going to contact you about the screen rotation work. It'd be great if you could take this. Should be a few hours' work to get this landable.
Assignee: jones.chris.g → nobody
Assignee | ||
Updated•13 years ago
|
Status: NEW → ASSIGNED
Updated•13 years ago
|
Whiteboard: [not-fennec-11]
Assignee | ||
Comment 8•13 years ago
|
||
So, all I did was unbitrot this, so r=me. Whoo.
Attachment #591351 -
Attachment is obsolete: true
Attachment #596087 -
Flags: review+
Assignee | ||
Comment 9•13 years ago
|
||
This is basically an unbitrotted version of the original patch, except I changed the nsIScreen UUID out of paranoia. Probably not actually necessary though since we're adding things to the end of the interface.
Attachment #585118 -
Attachment is obsolete: true
Assignee | ||
Comment 10•13 years ago
|
||
This is a simplified version of the original part 3 and 4 patches. It only attempts to support GL - I want to cover the non-GL path in a follow up.
I had issues with this patch for a while until I fixed the resize code in the gonk backend to set mBounds correctly.
Attachment #591352 -
Attachment is obsolete: true
Attachment #591355 -
Attachment is obsolete: true
Attachment #596094 -
Flags: review?(jones.chris.g)
Assignee | ||
Comment 11•13 years ago
|
||
I used this patch to test rotation. It makes the volume buttons rotate the screen.
Assignee | ||
Comment 12•13 years ago
|
||
Well, nevermind. It turns out adding support for the non-GL case is trivial.
Attachment #596094 -
Attachment is obsolete: true
Attachment #596094 -
Flags: review?(jones.chris.g)
Attachment #596137 -
Flags: review?(jones.chris.g)
Reporter | ||
Comment 13•13 years ago
|
||
Comment on attachment 596137 [details] [diff] [review]
Add rotation support to gonk backend
>diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp
>index d336b29..7c1cab1 100644
>--- a/widget/gonk/nsWindow.cpp
>+++ b/widget/gonk/nsWindow.cpp
>@@ -64,6 +64,9 @@ using namespace mozilla::layers;
> using namespace mozilla::widget;
>
> nsIntRect gScreenBounds;
>+PRUint32 gScreenRotation;
Please, no more magical globals. Make this file-static and use
nsIScreen::GetRotation() elsewhere please.
>@@ -127,6 +133,7 @@ nsWindow::DoDraw(void)
> nsRefPtr<gfxASurface> backBuffer = Framebuffer::BackBuffer();
> {
> nsRefPtr<gfxContext> ctx = new gfxContext(backBuffer);
>+ ctx->SetMatrix(sRotationMatrix);
This is wrong. Let's just not attempt to rotate for the fallback path
until we really try to support the non-GL coordinate space.
> gfxUtils::PathFromRegion(ctx, event.region);
> ctx->Clip();
>
>@@ -137,7 +144,11 @@ nsWindow::DoDraw(void)
> }
> backBuffer->Flush();
>
>- Framebuffer::Present(event.region);
>+ // XXX Properly rotate the region for other orientations
>+ if (gScreenRotation == nsIScreen::ROTATION_0_DEG)
>+ Framebuffer::Present(event.region);
And here.
r=me with those changes.
Attachment #596137 -
Flags: review?(jones.chris.g) → review+
Assignee | ||
Comment 14•13 years ago
|
||
(In reply to Chris Jones [:cjones] [:warhammer] from comment #13)
> Comment on attachment 596137 [details] [diff] [review]
> Add rotation support to gonk backend
>
> >diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp
> >index d336b29..7c1cab1 100644
> >--- a/widget/gonk/nsWindow.cpp
> >+++ b/widget/gonk/nsWindow.cpp
> >@@ -64,6 +64,9 @@ using namespace mozilla::layers;
> > using namespace mozilla::widget;
> >
> > nsIntRect gScreenBounds;
> >+PRUint32 gScreenRotation;
>
> Please, no more magical globals. Make this file-static and use
> nsIScreen::GetRotation() elsewhere please.
>
This was attempted and along with adding some annoying XPCOM goop, it crashed. For some reason, the screen manager can't be obtained as early as the appshell wants. This can be placed in nsWindow to be less ugly.
> >@@ -127,6 +133,7 @@ nsWindow::DoDraw(void)
> > nsRefPtr<gfxASurface> backBuffer = Framebuffer::BackBuffer();
> > {
> > nsRefPtr<gfxContext> ctx = new gfxContext(backBuffer);
> >+ ctx->SetMatrix(sRotationMatrix);
>
> This is wrong. Let's just not attempt to rotate for the fallback path
> until we really try to support the non-GL coordinate space.
>
FWIW this has been tested a bit on the emulator and it seems to rotate and respond to events correctly. Do you really want this removed?
Reporter | ||
Comment 15•13 years ago
|
||
The coordinate space for the fallback surface is different so I'm not sure how the same transform is working. If it does, *shrug* ok.
Reporter | ||
Comment 16•13 years ago
|
||
And yeah let's do a static helper fn or something. Sigh re: xpcom.
Assignee | ||
Comment 17•13 years ago
|
||
Attachment #596137 -
Attachment is obsolete: true
Assignee | ||
Comment 18•13 years ago
|
||
Attachment #596095 -
Attachment is obsolete: true
Assignee | ||
Comment 19•13 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/3202141e00fb
https://hg.mozilla.org/integration/mozilla-inbound/rev/7f89c92dea51
https://hg.mozilla.org/integration/mozilla-inbound/rev/84725e191d21
Target Milestone: --- → mozilla13
Reporter | ||
Comment 20•13 years ago
|
||
\o/
Comment 21•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/3202141e00fb
https://hg.mozilla.org/mozilla-central/rev/7f89c92dea51
https://hg.mozilla.org/mozilla-central/rev/84725e191d21
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Updated•13 years ago
|
Keywords: dev-doc-needed
Comment 22•13 years ago
|
||
Documentation updated:
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIScreen
And mentioned on Firefox 13 for developers.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•