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