Backed out changeset 29d01ad10d0b (bug 1152135)

This commit is contained in:
Sotaro Ikeda 2015-04-13 12:28:06 -07:00
Родитель 7375ce1ae0
Коммит a3181c2cc5
12 изменённых файлов: 85 добавлений и 106 удалений

Просмотреть файл

@ -96,14 +96,6 @@ public:
return mContext;
}
EGLSurface GetEGLSurface() {
return mSurface;
}
EGLDisplay GetEGLDisplay() {
return EGL_DISPLAY();
}
bool BindTex2DOffscreen(GLContext *aOffscreen);
void UnbindTex2DOffscreen(GLContext *aOffscreen);
void BindOffscreenFramebuffer();

Просмотреть файл

@ -230,6 +230,17 @@ GLContextEGL::GLContextEGL(
#ifdef DEBUG
printf_stderr("Initializing context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
#endif
#if defined(MOZ_WIDGET_GONK)
if (!mIsOffscreen) {
mHwc = HwcComposer2D::GetInstance();
MOZ_ASSERT(!mHwc->Initialized());
if (mHwc->Init(EGL_DISPLAY(), mSurface, this)) {
NS_WARNING("HWComposer initialization failed!");
mHwc = nullptr;
}
}
#endif
}
GLContextEGL::~GLContextEGL()
@ -452,7 +463,16 @@ GLContextEGL::SwapBuffers()
? mSurfaceOverride
: mSurface;
if (surface) {
return sEGLLibrary.fSwapBuffers(EGL_DISPLAY(), surface);
#ifdef MOZ_WIDGET_GONK
if (!mIsOffscreen) {
if (mHwc) {
return mHwc->Render(EGL_DISPLAY(), surface);
} else {
return GetGonkDisplay()->SwapBuffers(EGL_DISPLAY(), surface);
}
} else
#endif
return sEGLLibrary.fSwapBuffers(EGL_DISPLAY(), surface);
} else {
return false;
}

Просмотреть файл

@ -652,12 +652,14 @@ LayerManagerComposite::Render()
/** Our more efficient but less powerful alter ego, if one is available. */
nsRefPtr<Composer2D> composer2D;
composer2D = mCompositor->GetWidget()->GetComposer2D();
// We can't use composert2D if we have layer effects
if (!mTarget && !haveLayerEffects &&
composer2D && composer2D->HasHwc() && composer2D->TryRenderWithHwc(mRoot, mGeometryChanged))
{
// We can't use composert2D if we have layer effects, so only get it
// when we don't have any effects.
if (!haveLayerEffects) {
composer2D = mCompositor->GetWidget()->GetComposer2D();
}
if (!mTarget && composer2D && composer2D->TryRender(mRoot, mGeometryChanged)) {
LayerScope::SetHWComposed();
if (mFPS) {
double fps = mFPS->mCompositionFps.AddFrameAndGetFps(TimeStamp::Now());
@ -670,7 +672,7 @@ LayerManagerComposite::Render()
mInvalidRegion.SetEmpty();
mLastFrameMissedHWC = false;
return;
} else if (!mTarget && !haveLayerEffects) {
} else if (!mTarget) {
mLastFrameMissedHWC = !!composer2D;
}
@ -761,10 +763,6 @@ LayerManagerComposite::Render()
mCompositor->SetFBAcquireFence(mRoot);
}
if (composer2D) {
composer2D->Render();
}
mCompositor->GetWidget()->PostRender(this);
RecordFrame();

Просмотреть файл

@ -52,19 +52,7 @@ public:
* Currently, when TryRender() returns true, the entire framebuffer
* must have been rendered.
*/
virtual bool TryRenderWithHwc(Layer* aRoot, bool aGeometryChanged) = 0;
/**
* Return true if Composer2D does composition. Return false if Composer2D
* failed the composition.
*/
virtual bool Render() = 0;
/**
* Return true if Composer2D has a fast composition hardware.
* Return false if Composer2D does not have a fast composition hardware.
*/
virtual bool HasHwc() = 0;
virtual bool TryRender(Layer* aRoot, bool aGeometryChanged) = 0;
};
} // namespace layers

Просмотреть файл

@ -131,19 +131,13 @@ CompositorOGL::CreateContext()
caps, requireCompatProfile);
}
if (!context) {
if (!context)
context = gl::GLContextProvider::CreateForWindow(mWidget);
}
if (!context) {
NS_WARNING("Failed to create CompositorOGL context");
}
#ifdef MOZ_WIDGET_GONK
mWidget->SetNativeData(NS_NATIVE_OPENGL_CONTEXT,
reinterpret_cast<uintptr_t>(context.get()));
#endif
return context.forget();
}

Просмотреть файл

@ -110,8 +110,6 @@ static StaticRefPtr<HwcComposer2D> sInstance;
HwcComposer2D::HwcComposer2D()
: mHwc(nullptr)
, mList(nullptr)
, mDpy(EGL_NO_DISPLAY)
, mSur(EGL_NO_SURFACE)
, mGLContext(nullptr)
, mMaxLayerCount(0)
, mColorFill(false)
@ -127,11 +125,21 @@ HwcComposer2D::HwcComposer2D()
#if ANDROID_VERSION >= 17
RegisterHwcEventCallback();
#endif
}
HwcComposer2D::~HwcComposer2D() {
free(mList);
}
int
HwcComposer2D::Init(hwc_display_t dpy, hwc_surface_t sur, gl::GLContext* aGLContext)
{
MOZ_ASSERT(!Initialized());
mHwc = (HwcDevice*)GetGonkDisplay()->GetHWCDevice();
if (!mHwc) {
LOGD("no hwc support");
return;
LOGE("Failed to initialize hwc");
return -1;
}
nsIntSize screenSize;
@ -161,10 +169,12 @@ HwcComposer2D::HwcComposer2D()
mColorFill = (atoi(propValue) == 1) ? true : false;
mRBSwapSupport = true;
#endif
}
HwcComposer2D::~HwcComposer2D() {
free(mList);
mDpy = dpy;
mSur = sur;
mGLContext = aGLContext;
return 0;
}
HwcComposer2D*
@ -225,7 +235,7 @@ HwcComposer2D::Vsync(int aDisplay, nsecs_t aVsyncTimestamp)
void
HwcComposer2D::Invalidate()
{
if (!mHwc) {
if (!Initialized()) {
LOGE("HwcComposer2D::Invalidate failed!");
return;
}
@ -244,14 +254,6 @@ HwcComposer2D::SetCompositorParent(CompositorParent* aCompositorParent)
mCompositorParent = aCompositorParent;
}
void
HwcComposer2D::SetEGLInfo(hwc_display_t aDisplay, hwc_surface_t aSurface, gl::GLContext* aGLContext)
{
mDpy = aDisplay;
mSur = aSurface;
mGLContext = aGLContext;
}
bool
HwcComposer2D::ReallocLayerList()
{
@ -754,13 +756,15 @@ HwcComposer2D::TryHwComposition()
}
bool
HwcComposer2D::Render()
HwcComposer2D::Render(EGLDisplay dpy, EGLSurface sur)
{
// HWC module does not exist.
if (!mHwc) {
GetGonkDisplay()->SwapBuffers(mDpy, mSur);// Only GonkDisplayICS uses arguments.
if (!mList) {
// After boot, HWC list hasn't been created yet
return GetGonkDisplay()->SwapBuffers(dpy, sur);
}
GetGonkDisplay()->UpdateFBSurface(dpy, sur);
FramebufferSurface* fbsurface = (FramebufferSurface*)(GetGonkDisplay()->GetFBSurface());
if (!fbsurface) {
LOGE("H/W Composition failed. FBSurface not initialized.");
@ -900,9 +904,9 @@ HwcComposer2D::TryHwComposition()
}
bool
HwcComposer2D::Render()
HwcComposer2D::Render(EGLDisplay dpy, EGLSurface sur)
{
return GetGonkDisplay()->SwapBuffers(mDpy, mSur);
return GetGonkDisplay()->SwapBuffers(dpy, sur);
}
void
@ -913,13 +917,10 @@ HwcComposer2D::Reset()
#endif
bool
HwcComposer2D::TryRenderWithHwc(Layer* aRoot,
bool aGeometryChanged)
HwcComposer2D::TryRender(Layer* aRoot,
bool aGeometryChanged)
{
if (!mHwc) {
return false;
}
MOZ_ASSERT(Initialized());
if (mList) {
setHwcGeometry(aGeometryChanged);
mList->numHwLayers = 0;
@ -948,7 +949,7 @@ HwcComposer2D::TryRenderWithHwc(Layer* aRoot,
SendtoLayerScope();
if (!TryHwComposition()) {
LOGD("Full HWC Composition failed. Fallback to GPU Composition or partial OVERLAY Composition");
LOGD("H/W Composition failed");
LayerScope::CleanLayer();
return false;
}

Просмотреть файл

@ -77,17 +77,19 @@ public:
HwcComposer2D();
virtual ~HwcComposer2D();
int Init(hwc_display_t aDisplay, hwc_surface_t aSurface, gl::GLContext* aGLContext);
bool Initialized() const { return mHwc; }
static HwcComposer2D* GetInstance();
// Returns TRUE if the container has been succesfully rendered
// Returns FALSE if the container cannot be fully rendered
// by this composer so nothing was rendered at all
virtual bool TryRenderWithHwc(layers::Layer* aRoot,
bool aGeometryChanged) override;
bool TryRender(layers::Layer* aRoot,
bool aGeometryChanged) override;
virtual bool Render() override;
virtual bool HasHwc() override { return mHwc; }
bool Render(EGLDisplay dpy, EGLSurface sur);
bool EnableVsync(bool aEnable);
#if ANDROID_VERSION >= 17
@ -97,10 +99,6 @@ public:
#endif
void SetCompositorParent(layers::CompositorParent* aCompositorParent);
// Set EGL info of primary display. Used for BLIT Composition.
// XXX Add multiple displays compostion support.
void SetEGLInfo(hwc_display_t aDisplay, hwc_surface_t aSurface, gl::GLContext* aGLContext);
private:
void Reset();
void Prepare(buffer_handle_t fbHandle, int fence);
@ -115,9 +113,9 @@ private:
HwcDevice* mHwc;
HwcList* mList;
hwc_display_t mDpy; // Store for BLIT Composition and GonkDisplayICS
hwc_surface_t mSur; // Store for BLIT Composition and GonkDisplayICS
gl::GLContext* mGLContext; // Store for BLIT Composition
hwc_display_t mDpy;
hwc_surface_t mSur;
gl::GLContext* mGLContext;
nsIntRect mScreenRect;
int mMaxLayerCount;
bool mColorFill;

Просмотреть файл

@ -42,9 +42,6 @@ public:
virtual void* GetFBSurface() = 0;
/**
* Only GonkDisplayICS uses arguments.
*/
virtual bool SwapBuffers(EGLDisplay dpy, EGLSurface sur) = 0;
virtual ANativeWindowBuffer* DequeueBuffer() = 0;

Просмотреть файл

@ -186,9 +186,8 @@ GonkDisplayICS::SwapBuffers(EGLDisplay dpy, EGLSurface sur)
// Only HWC v1.0 needs this call. ICS gonk always needs the call.
mFBSurface->compositionComplete();
if (!mHwc) {
return true;
}
if (!mHwc)
return eglSwapBuffers(dpy, sur);
mHwc->prepare(mHwc, nullptr);
return !mHwc->set(mHwc, dpy, sur, 0);

Просмотреть файл

@ -238,6 +238,12 @@ GonkDisplayJB::SwapBuffers(EGLDisplay dpy, EGLSurface sur)
if (mFBDevice && mFBDevice->compositionComplete) {
mFBDevice->compositionComplete(mFBDevice);
}
#if ANDROID_VERSION == 17
mList->dpy = dpy;
mList->sur = sur;
#endif
eglSwapBuffers(dpy, sur);
return Post(mFBSurface->lastHandle, mFBSurface->GetPrevFBAcquireFd());
}

Просмотреть файл

@ -31,7 +31,6 @@
#include "gfxUtils.h"
#include "GLContextProvider.h"
#include "GLContext.h"
#include "GLContextEGL.h"
#include "nsAutoPtr.h"
#include "nsAppShell.h"
#include "nsIdleService.h"
@ -601,28 +600,11 @@ nsWindow::GetNativeData(uint32_t aDataType)
{
switch (aDataType) {
case NS_NATIVE_WINDOW:
// Called before primary display's EGLSurface creation.
return GetGonkDisplay()->GetNativeWindow();
}
return nullptr;
}
void
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);
HwcComposer2D* hwc = HwcComposer2D::GetInstance();
hwc->SetEGLInfo(GLContextEGL::Cast(context)->GetEGLDisplay(),
GLContextEGL::Cast(context)->GetEGLSurface(),
context);
return;
}
}
NS_IMETHODIMP
nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus)
{
@ -878,7 +860,12 @@ nsWindow::GetComposer2D()
if (!sUsingHwc) {
return nullptr;
}
return HwcComposer2D::GetInstance();
if (HwcComposer2D* hwc = HwcComposer2D::GetInstance()) {
return hwc->Initialized() ? hwc : nullptr;
}
return nullptr;
}
// nsScreenGonk.cpp

Просмотреть файл

@ -82,7 +82,6 @@ public:
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
NS_IMETHOD Invalidate(const nsIntRect &aRect);
virtual void* GetNativeData(uint32_t aDataType);
virtual void SetNativeData(uint32_t aDataType, uintptr_t aVal);
NS_IMETHOD SetTitle(const nsAString& aTitle)
{
return NS_OK;