diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index 5faa7f0d66d7..645747bcced1 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -337,7 +337,7 @@ public: */ virtual void EndFrame() = 0; - virtual void SetFBAcquireFence(Layer* aLayer) {} + virtual void SetDispAcquireFence(Layer* aLayer) {} virtual FenceHandle GetReleaseFence() { diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index 086471873cb7..ed9da915a8bb 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -768,7 +768,7 @@ LayerManagerComposite::Render() js::ProfileEntry::Category::GRAPHICS); mCompositor->EndFrame(); - mCompositor->SetFBAcquireFence(mRoot); + mCompositor->SetDispAcquireFence(mRoot); } if (composer2D) { @@ -945,7 +945,7 @@ LayerManagerComposite::RenderToPresentationSurface() RootLayer()->RenderLayer(clipRect); mCompositor->EndFrame(); - mCompositor->SetFBAcquireFence(mRoot); + mCompositor->SetDispAcquireFence(mRoot); } #endif diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 9727d3558c3f..f421def3afd8 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -1284,12 +1284,12 @@ CompositorOGL::EndFrame() #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 void -CompositorOGL::SetFBAcquireFence(Layer* aLayer) +CompositorOGL::SetDispAcquireFence(Layer* aLayer) { // OpenGL does not provide ReleaseFence for rendering. - // Instead use FBAcquireFence as layer buffer's ReleaseFence + // Instead use DispAcquireFence as layer buffer's ReleaseFence // to prevent flickering and tearing. - // FBAcquireFence is FramebufferSurface's AcquireFence. + // DispAcquireFence is DisplaySurface's AcquireFence. // AcquireFence will be signaled when a buffer's content is available. // See Bug 974152. @@ -1297,7 +1297,7 @@ CompositorOGL::SetFBAcquireFence(Layer* aLayer) return; } - android::sp fence = new android::Fence(GetGonkDisplay()->GetPrevFBAcquireFd()); + android::sp fence = new android::Fence(GetGonkDisplay()->GetPrevDispAcquireFd()); if (fence.get() && fence->isValid()) { FenceHandle handle = FenceHandle(fence); mReleaseFenceHandle.Merge(handle); @@ -1315,7 +1315,7 @@ CompositorOGL::GetReleaseFence() #else void -CompositorOGL::SetFBAcquireFence(Layer* aLayer) +CompositorOGL::SetDispAcquireFence(Layer* aLayer) { } diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 2893a157e32b..62b2f4e8a0cb 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -236,7 +236,7 @@ public: const gfx::Matrix4x4 &aTransform) override; virtual void EndFrame() override; - virtual void SetFBAcquireFence(Layer* aLayer) override; + virtual void SetDispAcquireFence(Layer* aLayer) override; virtual FenceHandle GetReleaseFence() override; virtual void EndFrameForExternalComposition(const gfx::Matrix& aTransform) override; diff --git a/widget/gonk/HwcComposer2D.cpp b/widget/gonk/HwcComposer2D.cpp index 58182d139d47..28d21b972214 100644 --- a/widget/gonk/HwcComposer2D.cpp +++ b/widget/gonk/HwcComposer2D.cpp @@ -35,7 +35,7 @@ #include "VsyncSource.h" #if ANDROID_VERSION >= 17 -#include "libdisplay/FramebufferSurface.h" +#include "libdisplay/DisplaySurface.h" #include "gfxPrefs.h" #include "nsThreadUtils.h" #endif @@ -674,10 +674,10 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer, bool HwcComposer2D::TryHwComposition() { - FramebufferSurface* fbsurface = (FramebufferSurface*)(GetGonkDisplay()->GetFBSurface()); + DisplaySurface* dispSurface = (DisplaySurface*)(GetGonkDisplay()->GetDispSurface()); - if (!(fbsurface && fbsurface->lastHandle)) { - LOGD("H/W Composition failed. FBSurface not initialized."); + if (!(dispSurface && dispSurface->lastHandle)) { + LOGD("H/W Composition failed. DispSurface not initialized."); return false; } @@ -690,7 +690,7 @@ HwcComposer2D::TryHwComposition() } } - Prepare(fbsurface->lastHandle, -1); + Prepare(dispSurface->lastHandle, -1); /* Possible composition paths, after hwc prepare: 1. GPU Composition @@ -744,22 +744,22 @@ HwcComposer2D::TryHwComposition() // GPU or partial OVERLAY Composition return false; } else if (blitComposite) { - // BLIT Composition, flip FB target - GetGonkDisplay()->UpdateFBSurface(mDpy, mSur); - FramebufferSurface* fbsurface = (FramebufferSurface*)(GetGonkDisplay()->GetFBSurface()); - if (!fbsurface) { - LOGE("H/W Composition failed. NULL FBSurface."); + // BLIT Composition, flip DispSurface target + GetGonkDisplay()->UpdateDispSurface(mDpy, mSur); + DisplaySurface* dispSurface = (DisplaySurface*)(GetGonkDisplay()->GetDispSurface()); + if (!dispSurface) { + LOGE("H/W Composition failed. NULL DispSurface."); return false; } - mList->hwLayers[idx].handle = fbsurface->lastHandle; - mList->hwLayers[idx].acquireFenceFd = fbsurface->GetPrevFBAcquireFd(); + mList->hwLayers[idx].handle = dispSurface->lastHandle; + mList->hwLayers[idx].acquireFenceFd = dispSurface->GetPrevDispAcquireFd(); } } // BLIT or full OVERLAY Composition Commit(); - GetGonkDisplay()->SetFBReleaseFd(mList->hwLayers[idx].releaseFenceFd); + GetGonkDisplay()->SetDispReleaseFd(mList->hwLayers[idx].releaseFenceFd); mList->hwLayers[idx].releaseFenceFd = -1; return true; } @@ -772,16 +772,16 @@ HwcComposer2D::Render() return GetGonkDisplay()->SwapBuffers(mDpy, mSur); } - FramebufferSurface* fbsurface = (FramebufferSurface*)(GetGonkDisplay()->GetFBSurface()); - if (!fbsurface) { - LOGE("H/W Composition failed. FBSurface not initialized."); + DisplaySurface* dispSurface = (DisplaySurface*)(GetGonkDisplay()->GetDispSurface()); + if (!dispSurface) { + LOGE("H/W Composition failed. DispSurface not initialized."); return false; } if (mPrepared) { // No mHwc prepare, if already prepared in current draw cycle - mList->hwLayers[mList->numHwLayers - 1].handle = fbsurface->lastHandle; - mList->hwLayers[mList->numHwLayers - 1].acquireFenceFd = fbsurface->GetPrevFBAcquireFd(); + mList->hwLayers[mList->numHwLayers - 1].handle = dispSurface->lastHandle; + mList->hwLayers[mList->numHwLayers - 1].acquireFenceFd = dispSurface->GetPrevDispAcquireFd(); } else { mList->flags = HWC_GEOMETRY_CHANGED; mList->numHwLayers = 2; @@ -792,19 +792,19 @@ HwcComposer2D::Render() mList->hwLayers[0].acquireFenceFd = -1; mList->hwLayers[0].releaseFenceFd = -1; mList->hwLayers[0].displayFrame = {0, 0, mScreenRect.width, mScreenRect.height}; - Prepare(fbsurface->lastHandle, fbsurface->GetPrevFBAcquireFd()); + Prepare(dispSurface->lastHandle, dispSurface->GetPrevDispAcquireFd()); } // GPU or partial HWC Composition Commit(); - GetGonkDisplay()->SetFBReleaseFd(mList->hwLayers[mList->numHwLayers - 1].releaseFenceFd); + GetGonkDisplay()->SetDispReleaseFd(mList->hwLayers[mList->numHwLayers - 1].releaseFenceFd); mList->hwLayers[mList->numHwLayers - 1].releaseFenceFd = -1; return true; } void -HwcComposer2D::Prepare(buffer_handle_t fbHandle, int fence) +HwcComposer2D::Prepare(buffer_handle_t dispHandle, int fence) { int idx = mList->numHwLayers - 1; const hwc_rect_t r = {0, 0, mScreenRect.width, mScreenRect.height}; @@ -818,7 +818,7 @@ HwcComposer2D::Prepare(buffer_handle_t fbHandle, int fence) mList->hwLayers[idx].hints = 0; mList->hwLayers[idx].flags = 0; mList->hwLayers[idx].transform = 0; - mList->hwLayers[idx].handle = fbHandle; + mList->hwLayers[idx].handle = dispHandle; mList->hwLayers[idx].blending = HWC_BLENDING_PREMULT; mList->hwLayers[idx].compositionType = HWC_FRAMEBUFFER_TARGET; setCrop(&mList->hwLayers[idx], r); diff --git a/widget/gonk/HwcComposer2D.h b/widget/gonk/HwcComposer2D.h index bb68ff6cf8b4..1a597d0b2f19 100644 --- a/widget/gonk/HwcComposer2D.h +++ b/widget/gonk/HwcComposer2D.h @@ -102,7 +102,7 @@ public: private: void Reset(); - void Prepare(buffer_handle_t fbHandle, int fence); + void Prepare(buffer_handle_t dispHandle, int fence); bool Commit(); bool TryHwComposition(); bool ReallocLayerList(); diff --git a/widget/gonk/libdisplay/FramebufferSurface.cpp b/widget/gonk/libdisplay/FramebufferSurface.cpp index 328244807163..0c5b6cf684dc 100644 --- a/widget/gonk/libdisplay/FramebufferSurface.cpp +++ b/widget/gonk/libdisplay/FramebufferSurface.cpp @@ -54,15 +54,10 @@ FramebufferSurface::FramebufferSurface(int disp, uint32_t height, uint32_t format, const sp& sc) -#if ANDROID_VERSION >= 19 - : ConsumerBase(sc, true) -#else - : ConsumerBase(sc) -#endif + : DisplaySurface(sc) , mDisplayType(disp) , mCurrentBufferSlot(-1) , mCurrentBuffer(0) - , lastHandle(0) { mName = "FramebufferSurface"; @@ -81,6 +76,21 @@ FramebufferSurface::FramebufferSurface(int disp, consumer->setDefaultMaxBufferCount(NUM_FRAMEBUFFER_SURFACE_BUFFERS); } +status_t FramebufferSurface::beginFrame(bool /*mustRecompose*/) { + return NO_ERROR; +} + +status_t FramebufferSurface::prepareFrame(CompositionType /*compositionType*/) { + return NO_ERROR; +} + +status_t FramebufferSurface::advanceFrame() { + // Once we remove FB HAL support, we can call nextBuffer() from here + // instead of using onFrameAvailable(). No real benefit, except it'll be + // more like VirtualDisplaySurface. + return NO_ERROR; +} + status_t FramebufferSurface::nextBuffer(sp& outBuffer, sp& outFence) { Mutex::Autolock lock(mMutex); @@ -174,28 +184,25 @@ status_t FramebufferSurface::setReleaseFenceFd(int fenceFd) { return err; } -int FramebufferSurface::GetPrevFBAcquireFd() { +int FramebufferSurface::GetPrevDispAcquireFd() { if (mPrevFBAcquireFence.get() && mPrevFBAcquireFence->isValid()) { return mPrevFBAcquireFence->dup(); } return -1; } -status_t FramebufferSurface::setUpdateRectangle(const Rect& r) -{ - return INVALID_OPERATION; +void FramebufferSurface::onFrameCommitted() { + // XXX This role is almost same to setReleaseFenceFd(). } status_t FramebufferSurface::compositionComplete() { + // Actual implementaiton is in GonkDisplay::SwapBuffers() + // XXX need to move that to here. return NO_ERROR; } -void FramebufferSurface::dump(String8& result) { - ConsumerBase::dump(result); -} - -void FramebufferSurface::dump(String8& result, const char* prefix) { +void FramebufferSurface::dump(String8& result) const { ConsumerBase::dump(result); } diff --git a/widget/gonk/libdisplay/FramebufferSurface.h b/widget/gonk/libdisplay/FramebufferSurface.h index f90dcd8dacf6..9c9abde27866 100644 --- a/widget/gonk/libdisplay/FramebufferSurface.h +++ b/widget/gonk/libdisplay/FramebufferSurface.h @@ -20,7 +20,7 @@ #include #include -#include +#include "DisplaySurface.h" // --------------------------------------------------------------------------- namespace android { @@ -29,24 +29,24 @@ namespace android { class Rect; class String8; -#if ANDROID_VERSION >= 21 -typedef IGraphicBufferConsumer StreamConsumer; -#else -typedef BufferQueue StreamConsumer; -#endif - // --------------------------------------------------------------------------- -class FramebufferSurface : public ConsumerBase { +class FramebufferSurface : public DisplaySurface { public: FramebufferSurface(int disp, uint32_t width, uint32_t height, uint32_t format, const sp& sc); - bool isUpdateOnDemand() const { return false; } - status_t setUpdateRectangle(const Rect& updateRect); - status_t compositionComplete(); - - virtual void dump(String8& result); - virtual void dump(String8& result, const char* prefix); + // From DisplaySurface + virtual status_t beginFrame(bool mustRecompose); + virtual status_t prepareFrame(CompositionType compositionType); + virtual status_t compositionComplete(); + virtual status_t advanceFrame(); + virtual void onFrameCommitted(); + // Implementation of DisplaySurface::dump(). Note that ConsumerBase also + // has a non-virtual dump() with the same signature. + virtual void dump(String8& result) const; + // Cannot resize a buffers in a FramebufferSurface. Only works with virtual + // displays. + virtual void resizeBuffers(const uint32_t /*w*/, const uint32_t /*h*/) { }; // setReleaseFenceFd stores a fence file descriptor that will signal when the // current buffer is no longer being read. This fence will be returned to @@ -56,9 +56,8 @@ public: // when finished with it. status_t setReleaseFenceFd(int fenceFd); - virtual int GetPrevFBAcquireFd(); + virtual int GetPrevDispAcquireFd(); - buffer_handle_t lastHandle; private: virtual ~FramebufferSurface() { }; // this class cannot be overloaded diff --git a/widget/gonk/libdisplay/GonkDisplay.h b/widget/gonk/libdisplay/GonkDisplay.h index c5b33c650b99..8f50ee768ea2 100644 --- a/widget/gonk/libdisplay/GonkDisplay.h +++ b/widget/gonk/libdisplay/GonkDisplay.h @@ -36,7 +36,7 @@ public: virtual void* GetHWCDevice() = 0; - virtual void* GetFBSurface() = 0; + virtual void* GetDispSurface() = 0; /** * Only GonkDisplayICS uses arguments. @@ -47,20 +47,20 @@ public: virtual bool QueueBuffer(ANativeWindowBuffer* buf) = 0; - virtual void UpdateFBSurface(EGLDisplay dpy, EGLSurface sur) = 0; + virtual void UpdateDispSurface(EGLDisplay dpy, EGLSurface sur) = 0; /** * Set FramebufferSurface ReleaseFence's file descriptor. * ReleaseFence will be signaled after the HWC has finished reading * from a buffer. */ - virtual void SetFBReleaseFd(int fd) = 0; + virtual void SetDispReleaseFd(int fd) = 0; /** * Get FramebufferSurface AcquireFence's file descriptor * AcquireFence will be signaled when a buffer's content is available. */ - virtual int GetPrevFBAcquireFd() = 0; + virtual int GetPrevDispAcquireFd() = 0; float xdpi; int32_t surfaceformat; diff --git a/widget/gonk/libdisplay/GonkDisplayICS.cpp b/widget/gonk/libdisplay/GonkDisplayICS.cpp index 48ecd269e84f..8c6efdf7eed9 100644 --- a/widget/gonk/libdisplay/GonkDisplayICS.cpp +++ b/widget/gonk/libdisplay/GonkDisplayICS.cpp @@ -173,12 +173,6 @@ GonkDisplayICS::GetHWCDevice() return mHwc; } -void* -GonkDisplayICS::GetFBSurface() -{ - return mFBSurface.get(); -} - bool GonkDisplayICS::SwapBuffers(EGLDisplay dpy, EGLSurface sur) { @@ -211,13 +205,13 @@ GonkDisplayICS::QueueBuffer(ANativeWindowBuffer *buf) } void -GonkDisplayICS::UpdateFBSurface(EGLDisplay dpy, EGLSurface sur) +GonkDisplayICS::UpdateDispSurface(EGLDisplay dpy, EGLSurface sur) { eglSwapBuffers(dpy, sur); } void -GonkDisplayICS::SetFBReleaseFd(int fd) +GonkDisplayICS::SetDispReleaseFd(int fd) { } diff --git a/widget/gonk/libdisplay/GonkDisplayICS.h b/widget/gonk/libdisplay/GonkDisplayICS.h index aaa4ec15cbbe..8a6a0ff065a2 100644 --- a/widget/gonk/libdisplay/GonkDisplayICS.h +++ b/widget/gonk/libdisplay/GonkDisplayICS.h @@ -38,7 +38,10 @@ public: virtual void* GetHWCDevice(); - virtual void* GetFBSurface(); + virtual void* GetDispSurface() + { + return nullptr; + } virtual bool SwapBuffers(EGLDisplay dpy, EGLSurface sur); @@ -46,11 +49,11 @@ public: virtual bool QueueBuffer(ANativeWindowBuffer* handle); - virtual void UpdateFBSurface(EGLDisplay dpy, EGLSurface sur); + virtual void UpdateDispSurface(EGLDisplay dpy, EGLSurface sur); - virtual void SetFBReleaseFd(int fd); + virtual void SetDispReleaseFd(int fd); - virtual int GetPrevFBAcquireFd() + virtual int GetPrevDispAcquireFd() { return -1; } diff --git a/widget/gonk/libdisplay/GonkDisplayJB.cpp b/widget/gonk/libdisplay/GonkDisplayJB.cpp index fb9e80a95159..2fc8a16bce9a 100644 --- a/widget/gonk/libdisplay/GonkDisplayJB.cpp +++ b/widget/gonk/libdisplay/GonkDisplayJB.cpp @@ -26,6 +26,7 @@ #include #include +#include "FramebufferSurface.h" #if ANDROID_VERSION == 17 #include "GraphicBufferAlloc.h" #endif @@ -119,11 +120,11 @@ GonkDisplayJB::GonkDisplayJB() sp consumer = new BufferQueue(true, mAlloc); #endif - mFBSurface = new FramebufferSurface(0, mWidth, mHeight, surfaceformat, consumer); + mDispSurface = new FramebufferSurface(0, mWidth, mHeight, surfaceformat, consumer); #if ANDROID_VERSION == 17 sp stc = new SurfaceTextureClient( - static_cast >(mFBSurface->getBufferQueue())); + static_cast >(mDispSurface->getBufferQueue())); #else sp stc = new Surface(producer); #endif @@ -223,9 +224,9 @@ GonkDisplayJB::GetHWCDevice() } void* -GonkDisplayJB::GetFBSurface() +GonkDisplayJB::GetDispSurface() { - return mFBSurface.get(); + return mDispSurface.get(); } bool @@ -238,7 +239,7 @@ GonkDisplayJB::SwapBuffers(EGLDisplay dpy, EGLSurface sur) if (mFBDevice && mFBDevice->compositionComplete) { mFBDevice->compositionComplete(mFBDevice); } - return Post(mFBSurface->lastHandle, mFBSurface->GetPrevFBAcquireFd()); + return Post(mDispSurface->lastHandle, mDispSurface->GetPrevDispAcquireFd()); } bool @@ -297,7 +298,7 @@ GonkDisplayJB::Post(buffer_handle_t buf, int fence) #endif mHwc->prepare(mHwc, HWC_NUM_DISPLAY_TYPES, displays); int err = mHwc->set(mHwc, HWC_NUM_DISPLAY_TYPES, displays); - mFBSurface->setReleaseFenceFd(mList->hwLayers[1].releaseFenceFd); + mDispSurface->setReleaseFenceFd(mList->hwLayers[1].releaseFenceFd); if (mList->retireFenceFd >= 0) close(mList->retireFenceFd); return !err; @@ -321,21 +322,21 @@ GonkDisplayJB::QueueBuffer(ANativeWindowBuffer* buf) } void -GonkDisplayJB::UpdateFBSurface(EGLDisplay dpy, EGLSurface sur) +GonkDisplayJB::UpdateDispSurface(EGLDisplay dpy, EGLSurface sur) { eglSwapBuffers(dpy, sur); } void -GonkDisplayJB::SetFBReleaseFd(int fd) +GonkDisplayJB::SetDispReleaseFd(int fd) { - mFBSurface->setReleaseFenceFd(fd); + mDispSurface->setReleaseFenceFd(fd); } int -GonkDisplayJB::GetPrevFBAcquireFd() +GonkDisplayJB::GetPrevDispAcquireFd() { - return mFBSurface->GetPrevFBAcquireFd(); + return mDispSurface->GetPrevDispAcquireFd(); } __attribute__ ((visibility ("default"))) diff --git a/widget/gonk/libdisplay/GonkDisplayJB.h b/widget/gonk/libdisplay/GonkDisplayJB.h index ad735623c59c..556f01b39342 100644 --- a/widget/gonk/libdisplay/GonkDisplayJB.h +++ b/widget/gonk/libdisplay/GonkDisplayJB.h @@ -16,8 +16,8 @@ #ifndef GONKDISPLAYJB_H #define GONKDISPLAYJB_H +#include "DisplaySurface.h" #include "GonkDisplay.h" -#include "FramebufferSurface.h" #include "hardware/hwcomposer.h" #include "hardware/power.h" #include "ui/Fence.h" @@ -38,7 +38,7 @@ public: virtual void* GetHWCDevice(); - virtual void* GetFBSurface(); + virtual void* GetDispSurface(); virtual bool SwapBuffers(EGLDisplay dpy, EGLSurface sur); @@ -46,11 +46,11 @@ public: virtual bool QueueBuffer(ANativeWindowBuffer* buf); - virtual void UpdateFBSurface(EGLDisplay dpy, EGLSurface sur); + virtual void UpdateDispSurface(EGLDisplay dpy, EGLSurface sur); - virtual void SetFBReleaseFd(int fd); + virtual void SetDispReleaseFd(int fd); - virtual int GetPrevFBAcquireFd(); + virtual int GetPrevDispAcquireFd(); bool Post(buffer_handle_t buf, int fence); @@ -60,7 +60,7 @@ private: hwc_composer_device_1_t* mHwc; framebuffer_device_t* mFBDevice; power_module_t* mPowerModule; - android::sp mFBSurface; + android::sp mDispSurface; android::sp mSTClient; android::sp mAlloc; int mFence; diff --git a/widget/gonk/libdisplay/VirtualDisplaySurface.cpp b/widget/gonk/libdisplay/VirtualDisplaySurface.cpp index c3d45ee09a0e..8c0156026a5b 100644 --- a/widget/gonk/libdisplay/VirtualDisplaySurface.cpp +++ b/widget/gonk/libdisplay/VirtualDisplaySurface.cpp @@ -16,7 +16,6 @@ // #define LOG_NDEBUG 0 #include "VirtualDisplaySurface.h" -#include "HWComposer.h" // --------------------------------------------------------------------------- namespace android { @@ -45,13 +44,12 @@ static const char* dbgCompositionTypeStr(DisplaySurface::CompositionType type) { } } -VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId, +VirtualDisplaySurface::VirtualDisplaySurface(int32_t dispId, const sp& sink, const sp& bqProducer, - const sp& bqConsumer, + const sp& bqConsumer, const String8& name) -: ConsumerBase(bqConsumer), - mHwc(hwc), +: DisplaySurface(bqConsumer), mDisplayId(dispId), mDisplayName(name), mOutputUsage(GRALLOC_USAGE_HW_COMPOSER), @@ -162,6 +160,11 @@ status_t VirtualDisplaySurface::compositionComplete() { } status_t VirtualDisplaySurface::advanceFrame() { + return NO_ERROR; + +// XXX Add HWC support + +#if 0 if (mDisplayId < 0) return NO_ERROR; @@ -204,9 +207,15 @@ status_t VirtualDisplaySurface::advanceFrame() { } return result; +#endif } void VirtualDisplaySurface::onFrameCommitted() { + return; + +// XXX Add HWC support + +#if 0 if (mDisplayId < 0) return; @@ -252,6 +261,7 @@ void VirtualDisplaySurface::onFrameCommitted() { } resetPerFrameState(); +#endif } void VirtualDisplaySurface::dump(String8& /* result */) const { @@ -495,6 +505,7 @@ int VirtualDisplaySurface::query(int what, int* value) { return NO_ERROR; } +#if ANDROID_VERSION >= 21 status_t VirtualDisplaySurface::connect(const sp& listener, int api, bool producerControlledByApp, QueueBufferOutput* output) { @@ -507,14 +518,29 @@ status_t VirtualDisplaySurface::connect(const sp& listener, } return result; } +#else +status_t VirtualDisplaySurface::connect(const sp& token, + int api, bool producerControlledByApp, + QueueBufferOutput* output) { + QueueBufferOutput qbo; + status_t result = mSource[SOURCE_SINK]->connect(token, api, producerControlledByApp, &qbo); + if (result == NO_ERROR) { + updateQueueBufferOutput(qbo); + *output = mQueueBufferOutput; + } + return result; +} +#endif status_t VirtualDisplaySurface::disconnect(int api) { return mSource[SOURCE_SINK]->disconnect(api); } +#if ANDROID_VERSION >= 21 status_t VirtualDisplaySurface::setSidebandStream(const sp& /*stream*/) { return INVALID_OPERATION; } +#endif void VirtualDisplaySurface::allocateBuffers(bool /* async */, uint32_t /* width */, uint32_t /* height */, uint32_t /* format */, @@ -538,6 +564,12 @@ void VirtualDisplaySurface::resetPerFrameState() { } status_t VirtualDisplaySurface::refreshOutputBuffer() { + + return INVALID_OPERATION; + +// XXX Add HWC support + +#if 0 if (mOutputProducerSlot >= 0) { mSource[SOURCE_SINK]->cancelBuffer( mapProducer2SourceSlot(SOURCE_SINK, mOutputProducerSlot), @@ -559,6 +591,7 @@ status_t VirtualDisplaySurface::refreshOutputBuffer() { mProducerBuffers[mOutputProducerSlot]); return result; +#endif } // This slot mapping function is its own inverse, so two copies are unnecessary. diff --git a/widget/gonk/libdisplay/VirtualDisplaySurface.h b/widget/gonk/libdisplay/VirtualDisplaySurface.h index 363dce20665b..32fb5a3b91c7 100644 --- a/widget/gonk/libdisplay/VirtualDisplaySurface.h +++ b/widget/gonk/libdisplay/VirtualDisplaySurface.h @@ -17,7 +17,6 @@ #ifndef ANDROID_SF_VIRTUAL_DISPLAY_SURFACE_H #define ANDROID_SF_VIRTUAL_DISPLAY_SURFACE_H -#include #include #include "DisplaySurface.h" @@ -69,13 +68,12 @@ class IProducerListener; * is released and the output buffer is queued to the sink. */ class VirtualDisplaySurface : public DisplaySurface, - public BnGraphicBufferProducer, - private ConsumerBase { + public BnGraphicBufferProducer { public: - VirtualDisplaySurface(HWComposer& hwc, int32_t dispId, + VirtualDisplaySurface(int32_t dispId, const sp& sink, const sp& bqProducer, - const sp& bqConsumer, + const sp& bqConsumer, const String8& name); // @@ -89,6 +87,9 @@ public: virtual void dump(String8& result) const; virtual void resizeBuffers(const uint32_t w, const uint32_t h); + virtual status_t setReleaseFenceFd(int fenceFd) { return INVALID_OPERATION; } + virtual int GetPrevDispAcquireFd() { return -1; }; + private: enum Source {SOURCE_SINK = 0, SOURCE_SCRATCH = 1}; @@ -109,10 +110,17 @@ private: const QueueBufferInput& input, QueueBufferOutput* output); virtual void cancelBuffer(int pslot, const sp& fence); virtual int query(int what, int* value); +#if ANDROID_VERSION >= 21 virtual status_t connect(const sp& listener, int api, bool producerControlledByApp, QueueBufferOutput* output); +#else + virtual status_t connect(const sp& token, + int api, bool producerControlledByApp, QueueBufferOutput* output); +#endif virtual status_t disconnect(int api); +#if ANDROID_VERSION >= 21 virtual status_t setSidebandStream(const sp& stream); +#endif virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, uint32_t format, uint32_t usage); @@ -138,7 +146,6 @@ private: // // Immutable after construction // - HWComposer& mHwc; const int32_t mDisplayId; const String8 mDisplayName; sp mSource[2]; // indexed by SOURCE_* diff --git a/widget/gonk/libdisplay/moz.build b/widget/gonk/libdisplay/moz.build index 1fd69b1a1069..3cb1426eec29 100644 --- a/widget/gonk/libdisplay/moz.build +++ b/widget/gonk/libdisplay/moz.build @@ -18,7 +18,13 @@ SOURCES += [ 'BootAnimation.cpp', ] -if CONFIG['ANDROID_VERSION'] >= '18': +if CONFIG['ANDROID_VERSION'] >= '19': + SOURCES += [ + 'FramebufferSurface.cpp', + 'GonkDisplayJB.cpp', + 'VirtualDisplaySurface.cpp', + ] +elif CONFIG['ANDROID_VERSION'] == '18': SOURCES += [ 'FramebufferSurface.cpp', 'GonkDisplayJB.cpp',