Closed Bug 870198 Opened 11 years ago Closed 11 years ago

Support basic display functions on gonk-JB

Categories

(Core Graveyard :: Widget: Gonk, defect)

All
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla24

People

(Reporter: mwu, Assigned: mwu)

References

Details

Attachments

(4 files, 6 obsolete files)

JB introduces a number of changes to graphics system. This patch introduces the GonkDisplay interface to abstract away these changes so we can support both JB and ICS.
Added ICS support. Need to add HWC support back before this is ready.
Attachment #747251 - Attachment is obsolete: true
HWC support put back
Attachment #747636 - Attachment is obsolete: true
This patch introduces a class named GonkDisplay which abstracts away the differences between ICS and JB. The boot animation code is now also called from GonkDisplay. The GonkDisplay and boot animation code is bundled up and linked into the b2g binary so the boot animation can start as soon as possible.

On ICS, FramebufferNativeWindow is used to both create gralloc'd buffers for drawing and providing a ANativeBuffer which EGL uses to grab buffers.

On JB, the Nexus 4 requires things to be drawn via HWC. There, we use FramebufferSurface/SurfaceTextureClient/BufferQueue to replace the function of FramebufferNativeWindow. SurfaceTextureClient provides a ANativeWindow so EGL can draw to buffers, and when buffers are ready to be shown on screen, FramebufferSurface provides them to GonkDisplay. We used to get a EGLDisplay and EGLSurface before, but now we get the buffer_handle_t's directly. GonkDisplay then creates a barebones display list for HWC to render the buffer.

HWC 1.1 and later require all this magic. HWC 1.0 doesn't AFAICT. It still tries to extract buffer handles out of EGLSurfaces. I don't think this code supports HWC 1.0 / no HWC right now, though romaxa is trying to get something working on the Nexus 7.
Attachment #747669 - Attachment is obsolete: true
Attachment #747698 - Flags: review?
Attachment #747698 - Flags: review? → review?(vladimir)
Comment on attachment 747698 [details] [diff] [review]
Abstract some display functions behind GonkDisplay, v4 (for review)

Review of attachment 747698 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/gonk/libdisplay/BootAnimation.cpp
@@ +416,5 @@
>          return nullptr;
>      }
>  
> +    int format = GetGonkDisplay()->surfaceformat;
> +    GonkDisplay *display = GetGonkDisplay();

Need to reverse the order of these two lines.

::: widget/gonk/libdisplay/BootAnimation.h
@@ +1,1 @@
> +#ifndef BOOTANIMATION_H

Need to add license boilerplate.

::: widget/gonk/libdisplay/GonkDisplay.h
@@ +27,5 @@
> +    virtual void SetEnabled(bool enabled) = 0;
> +
> +    virtual void* GetHWCDevice() = 0;
> +
> +    virtual bool SwapBuffers(void* dpy, void* sur) = 0;

Need to use EGLSurface/EGLDisplay..

::: widget/gonk/libdisplay/Makefile.in
@@ +35,5 @@
> +	$(NULL)
> +else ifeq (15,$(ANDROID_VERSION))
> +CPPSRCS += GonkDisplayICS.cpp
> +else
> +$(error Unsupported )

Forgot to finish this sentence.
Attachment #747698 - Attachment is obsolete: true
Attachment #747698 - Flags: review?(vladimir)
Attachment #748170 - Flags: review?(vladimir)
Attachment #747700 - Attachment is obsolete: true
Comment on attachment 748170 [details] [diff] [review]
Abstract some display functions behind GonkDisplay, v5 (for review)

Review of attachment 748170 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/gl/GLContextProviderEGL.cpp
@@ +273,5 @@
>  
>  #ifdef DEBUG
>          printf_stderr("Initializing context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
>  #endif
> +#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION == 15

may want to prefer < or > the appropriate version here instead of explicit == 15, just in case.

@@ +1593,5 @@
>      LOCAL_EGL_GREEN_SIZE,      8,
>      LOCAL_EGL_BLUE_SIZE,       8,
>      LOCAL_EGL_ALPHA_SIZE,      8,
> +#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
> +    /* EGL_FRAMEBUFFER_TARGET_ANDROID */ 0x3147, LOCAL_EGL_TRUE,

add EGL_FRAMEBUFFER_TARGET_ANDROID to GLDefs.h?

::: widget/gonk/libdisplay/GonkDisplayICS.cpp
@@ +42,5 @@
> +    // framebuffer device after we restart with the screen off.
> +    //
> +    // NB: this *must* run BEFORE allocating the
> +    // FramebufferNativeWindow.  Do not separate these two C++
> +    // statements.

Can we update this comment, because we did, in fact, separate the two C++ statements? :)
Attachment #748170 - Flags: review?(vladimir) → review+
A couple of fixes to make everything ok on ICS. I forgot to zero a new variable in the constructor, and ICS doesn't need to link against some of the new libraries JB uses.
https://hg.mozilla.org/mozilla-central/rev/875188dad4bf
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
(In reply to Michael Wu [:mwu] from comment #14)
> https://hg.mozilla.org/projects/birch/rev/875188dad4bf

Hi Michael,

It seams Gonk just supports older version of HWC(for ICS) so far ?
In the latest version of HWC(for JB), hwcomposer device is constructed by hwc_composer_device_1_t which is quite different from hwc_composer_device_t.

HwcComposer2D::Init(hwc_display_t dpy, hwc_surface_t sur)

...

if (int err = init()) {
   mHwc = (hwc_composer_device_t*)GetGonkDisplay()->GetHWCDevice();
   if (!mHwc) {
      LOGE("Failed to initialize hwc");
      return err;
      return -1;
   }

I'm just tracing the code and find this Bug ID by coincidence.
Not sure if it's proper to post here.
Sorry for bothering.
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: