Bug 1187048 - Code clean up around nsScreenGonk's EGLSurface handling r=mwu
This commit is contained in:
@@ -167,6 +167,11 @@ CompositorOGL::CleanupResources()
|
|||||||
if (!mGLContext)
|
if (!mGLContext)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef MOZ_WIDGET_GONK
|
||||||
|
mWidget->SetNativeData(NS_NATIVE_OPENGL_CONTEXT,
|
||||||
|
reinterpret_cast<uintptr_t>(nullptr));
|
||||||
|
#endif
|
||||||
|
|
||||||
nsRefPtr<GLContext> ctx = mGLContext->GetSharedContext();
|
nsRefPtr<GLContext> ctx = mGLContext->GetSharedContext();
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
ctx = mGLContext;
|
ctx = mGLContext;
|
||||||
|
|||||||
@@ -709,7 +709,7 @@ HwcComposer2D::TryHwComposition(nsScreenGonk* aScreen)
|
|||||||
return false;
|
return false;
|
||||||
} else if (blitComposite) {
|
} else if (blitComposite) {
|
||||||
// BLIT Composition, flip DispSurface target
|
// BLIT Composition, flip DispSurface target
|
||||||
GetGonkDisplay()->UpdateDispSurface(aScreen->GetDpy(), aScreen->GetSur());
|
GetGonkDisplay()->UpdateDispSurface(aScreen->GetEGLDisplay(), aScreen->GetEGLSurface());
|
||||||
DisplaySurface* dispSurface = aScreen->GetDisplaySurface();
|
DisplaySurface* dispSurface = aScreen->GetDisplaySurface();
|
||||||
if (!dispSurface) {
|
if (!dispSurface) {
|
||||||
LOGE("H/W Composition failed. NULL DispSurface.");
|
LOGE("H/W Composition failed. NULL DispSurface.");
|
||||||
@@ -731,7 +731,7 @@ HwcComposer2D::Render(nsIWidget* aWidget)
|
|||||||
|
|
||||||
// HWC module does not exist or mList is not created yet.
|
// HWC module does not exist or mList is not created yet.
|
||||||
if (!mHal->HasHwc() || !mList) {
|
if (!mHal->HasHwc() || !mList) {
|
||||||
return GetGonkDisplay()->SwapBuffers(screen->GetDpy(), screen->GetSur());
|
return GetGonkDisplay()->SwapBuffers(screen->GetEGLDisplay(), screen->GetEGLSurface());
|
||||||
} else if (!mList && !ReallocLayerList()) {
|
} else if (!mList && !ReallocLayerList()) {
|
||||||
LOGE("Cannot realloc layer list");
|
LOGE("Cannot realloc layer list");
|
||||||
return false;
|
return false;
|
||||||
@@ -829,7 +829,7 @@ HwcComposer2D::Commit(nsScreenGonk* aScreen)
|
|||||||
bool
|
bool
|
||||||
HwcComposer2D::TryHwComposition(nsScreenGonk* aScreen)
|
HwcComposer2D::TryHwComposition(nsScreenGonk* aScreen)
|
||||||
{
|
{
|
||||||
mHal->SetEGLInfo(aScreen->GetDpy(), aScreen->GetSur());
|
mHal->SetEGLInfo(aScreen->GetEGLDisplay(), aScreen->GetEGLSurface());
|
||||||
return !mHal->Set(mList, aScreen->GetDisplayType());
|
return !mHal->Set(mList, aScreen->GetDisplayType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -837,7 +837,7 @@ bool
|
|||||||
HwcComposer2D::Render(nsIWidget* aWidget)
|
HwcComposer2D::Render(nsIWidget* aWidget)
|
||||||
{
|
{
|
||||||
nsScreenGonk* screen = static_cast<nsWindow*>(aWidget)->GetScreen();
|
nsScreenGonk* screen = static_cast<nsWindow*>(aWidget)->GetScreen();
|
||||||
GetGonkDisplay()->SwapBuffers(screen->GetDpy(), screen->GetSur());
|
GetGonkDisplay()->SwapBuffers(screen->GetEGLDisplay(), screen->GetEGLSurface());
|
||||||
|
|
||||||
if (!mHal->HasHwc()) {
|
if (!mHal->HasHwc()) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ public:
|
|||||||
virtual const hwc_rect_t GetHwcRect() const = 0;
|
virtual const hwc_rect_t GetHwcRect() const = 0;
|
||||||
|
|
||||||
// Set EGL info (only ICS need this info)
|
// Set EGL info (only ICS need this info)
|
||||||
virtual void SetEGLInfo(hwc_display_t aDpy,
|
virtual void SetEGLInfo(hwc_display_t aEGLDisplay,
|
||||||
hwc_surface_t aSur) = 0;
|
hwc_surface_t aEGLSurface) = 0;
|
||||||
|
|
||||||
// HwcDevice query properties
|
// HwcDevice query properties
|
||||||
virtual bool Query(QueryType aType) = 0;
|
virtual bool Query(QueryType aType) = 0;
|
||||||
|
|||||||
@@ -34,16 +34,16 @@ HwcICS::HwcICS()
|
|||||||
HwcICS::~HwcICS()
|
HwcICS::~HwcICS()
|
||||||
{
|
{
|
||||||
mHwc = nullptr;
|
mHwc = nullptr;
|
||||||
mDpy = nullptr;
|
mEGLDisplay = nullptr;
|
||||||
mSur = nullptr;
|
mEGLSurface = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
HwcICS::SetEGLInfo(hwc_display_t aDpy,
|
HwcICS::SetEGLInfo(hwc_display_t aEGLDisplay,
|
||||||
hwc_surface_t aSur)
|
hwc_surface_t aEGLSurface)
|
||||||
{
|
{
|
||||||
mDpy = aDpy;
|
mEGLDisplay = aEGLDisplay;
|
||||||
mSur = aSur;
|
mEGLSurface = aEGLSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -74,7 +74,7 @@ HwcICS::Set(HwcList* aList,
|
|||||||
if (!mHwc) {
|
if (!mHwc) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mHwc->set(mHwc, mDpy, mSur, aList);
|
return mHwc->set(mHwc, mEGLDisplay, mEGLSurface, aList);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ public:
|
|||||||
|
|
||||||
virtual const hwc_rect_t GetHwcRect() const override { return {0}; }
|
virtual const hwc_rect_t GetHwcRect() const override { return {0}; }
|
||||||
|
|
||||||
virtual void SetEGLInfo(hwc_display_t aDpy,
|
virtual void SetEGLInfo(hwc_display_t aEGLDisplay,
|
||||||
hwc_surface_t aSur) override;
|
hwc_surface_t aEGLSurface) override;
|
||||||
|
|
||||||
virtual bool Query(QueryType aType) override;
|
virtual bool Query(QueryType aType) override;
|
||||||
|
|
||||||
@@ -61,8 +61,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
HwcDevice *mHwc = nullptr;
|
HwcDevice *mHwc = nullptr;
|
||||||
hwc_display_t mDpy = nullptr;
|
hwc_display_t mEGLDisplay = nullptr;
|
||||||
hwc_surface_t mSur = nullptr;
|
hwc_surface_t mEGLSurface = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "HwcComposer2D.h"
|
#include "HwcComposer2D.h"
|
||||||
#include "VsyncSource.h"
|
#include "VsyncSource.h"
|
||||||
#include "nsWindow.h"
|
#include "nsWindow.h"
|
||||||
|
#include "mozilla/layers/CompositorParent.h"
|
||||||
#include "mozilla/Services.h"
|
#include "mozilla/Services.h"
|
||||||
#include "mozilla/ProcessPriorityManager.h"
|
#include "mozilla/ProcessPriorityManager.h"
|
||||||
#include "nsIdleService.h"
|
#include "nsIdleService.h"
|
||||||
@@ -47,6 +48,7 @@ using namespace mozilla;
|
|||||||
using namespace mozilla::hal;
|
using namespace mozilla::hal;
|
||||||
using namespace mozilla::gfx;
|
using namespace mozilla::gfx;
|
||||||
using namespace mozilla::gl;
|
using namespace mozilla::gl;
|
||||||
|
using namespace mozilla::layers;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -120,8 +122,8 @@ nsScreenGonk::nsScreenGonk(uint32_t aId,
|
|||||||
, mDisplaySurface(aNativeData.mDisplaySurface)
|
, mDisplaySurface(aNativeData.mDisplaySurface)
|
||||||
#endif
|
#endif
|
||||||
, mDisplayType(aDisplayType)
|
, mDisplayType(aDisplayType)
|
||||||
, mDpy(EGL_NO_DISPLAY)
|
, mEGLDisplay(EGL_NO_DISPLAY)
|
||||||
, mSur(EGL_NO_SURFACE)
|
, mEGLSurface(EGL_NO_SURFACE)
|
||||||
, mGLContext(nullptr)
|
, mGLContext(nullptr)
|
||||||
{
|
{
|
||||||
if (mNativeWindow->query(mNativeWindow.get(), NATIVE_WINDOW_WIDTH, &mVirtualBounds.width) ||
|
if (mNativeWindow->query(mNativeWindow.get(), NATIVE_WINDOW_WIDTH, &mVirtualBounds.width) ||
|
||||||
@@ -360,21 +362,24 @@ void
|
|||||||
nsScreenGonk::SetEGLInfo(hwc_display_t aDisplay, hwc_surface_t aSurface,
|
nsScreenGonk::SetEGLInfo(hwc_display_t aDisplay, hwc_surface_t aSurface,
|
||||||
gl::GLContext* aGLContext)
|
gl::GLContext* aGLContext)
|
||||||
{
|
{
|
||||||
mDpy = aDisplay;
|
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||||
mSur = aSurface;
|
mEGLDisplay = aDisplay;
|
||||||
|
mEGLSurface = aSurface;
|
||||||
mGLContext = aGLContext;
|
mGLContext = aGLContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwc_display_t
|
hwc_display_t
|
||||||
nsScreenGonk::GetDpy()
|
nsScreenGonk::GetEGLDisplay()
|
||||||
{
|
{
|
||||||
return mDpy;
|
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||||
|
return mEGLDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwc_surface_t
|
hwc_surface_t
|
||||||
nsScreenGonk::GetSur()
|
nsScreenGonk::GetEGLSurface()
|
||||||
{
|
{
|
||||||
return mSur;
|
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
|
||||||
|
return mEGLSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsScreenManagerGonk, nsIScreenManager)
|
NS_IMPL_ISUPPORTS(nsScreenManagerGonk, nsIScreenManager)
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ public:
|
|||||||
// Set EGL info of primary display. Used for BLIT Composition.
|
// Set EGL info of primary display. Used for BLIT Composition.
|
||||||
void SetEGLInfo(hwc_display_t aDisplay, hwc_surface_t aSurface,
|
void SetEGLInfo(hwc_display_t aDisplay, hwc_surface_t aSurface,
|
||||||
mozilla::gl::GLContext* aGLContext);
|
mozilla::gl::GLContext* aGLContext);
|
||||||
hwc_display_t GetDpy();
|
hwc_display_t GetEGLDisplay();
|
||||||
hwc_surface_t GetSur();
|
hwc_surface_t GetEGLSurface();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t mId;
|
uint32_t mId;
|
||||||
@@ -107,10 +107,12 @@ protected:
|
|||||||
#if ANDROID_VERSION >= 17
|
#if ANDROID_VERSION >= 17
|
||||||
android::sp<android::DisplaySurface> mDisplaySurface;
|
android::sp<android::DisplaySurface> mDisplaySurface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Accessed and updated only on compositor thread
|
||||||
GonkDisplay::DisplayType mDisplayType;
|
GonkDisplay::DisplayType mDisplayType;
|
||||||
hwc_display_t mDpy; // Store for BLIT Composition and GonkDisplayICS
|
hwc_display_t mEGLDisplay;
|
||||||
hwc_surface_t mSur; // Store for BLIT Composition and GonkDisplayICS
|
hwc_surface_t mEGLSurface;
|
||||||
mozilla::gl::GLContext* mGLContext; // Store for BLIT Composition
|
mozilla::gl::GLContext* mGLContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsScreenManagerGonk final : public nsIScreenManager
|
class nsScreenManagerGonk final : public nsIScreenManager
|
||||||
|
|||||||
@@ -546,8 +546,13 @@ nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal)
|
|||||||
{
|
{
|
||||||
switch (aDataType) {
|
switch (aDataType) {
|
||||||
case NS_NATIVE_OPENGL_CONTEXT:
|
case NS_NATIVE_OPENGL_CONTEXT:
|
||||||
// Called after primary display's GLContextEGL creation.
|
|
||||||
GLContext* context = reinterpret_cast<GLContext*>(aVal);
|
GLContext* context = reinterpret_cast<GLContext*>(aVal);
|
||||||
|
if (!context) {
|
||||||
|
mScreen->SetEGLInfo(EGL_NO_DISPLAY,
|
||||||
|
EGL_NO_SURFACE,
|
||||||
|
nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
mScreen->SetEGLInfo(GLContextEGL::Cast(context)->GetEGLDisplay(),
|
mScreen->SetEGLInfo(GLContextEGL::Cast(context)->GetEGLDisplay(),
|
||||||
GLContextEGL::Cast(context)->GetEGLSurface(),
|
GLContextEGL::Cast(context)->GetEGLSurface(),
|
||||||
context);
|
context);
|
||||||
|
|||||||
Reference in New Issue
Block a user