diff options
25 files changed, 6 insertions, 555 deletions
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 469e5989ba..2a78aa597f 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -54,7 +54,6 @@ LOCAL_C_INCLUDES := \ LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\" LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -LOCAL_CFLAGS += -DUSE_HWC2 LOCAL_CFLAGS += -fvisibility=hidden -Werror=format @@ -120,8 +119,6 @@ LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\" LOCAL_INIT_RC := surfaceflinger.rc -LOCAL_CFLAGS += -DUSE_HWC2 - LOCAL_SRC_FILES := \ main_surfaceflinger.cpp diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp index fc0949dd90..0c1693b53b 100644 --- a/services/surfaceflinger/BufferLayer.cpp +++ b/services/surfaceflinger/BufferLayer.cpp @@ -61,9 +61,7 @@ BufferLayer::BufferLayer(SurfaceFlinger* flinger, const sp<Client>& client, cons mPreviousFrameNumber(0), mUpdateTexImageFailed(false), mRefreshPending(false) { -#ifdef USE_HWC2 ALOGV("Creating Layer %s", name.string()); -#endif mFlinger->getRenderEngine().genTextures(1, &mTextureName); mTexture.init(Texture::TEXTURE_EXTERNAL, mTextureName); @@ -90,14 +88,12 @@ BufferLayer::~BufferLayer() { } mFlinger->deleteTextureAsync(mTextureName); -#ifdef USE_HWC2 if (!mHwcLayers.empty()) { ALOGE("Found stale hardware composer layers when destroying " "surface flinger layer %s", mName.string()); destroyAllHwcLayers(); } -#endif } void BufferLayer::useSurfaceDamage() { @@ -265,22 +261,12 @@ void BufferLayer::onDraw(const RenderArea& renderArea, const Region& clip, engine.disableTexturing(); } -#ifdef USE_HWC2 void BufferLayer::onLayerDisplayed(const sp<Fence>& releaseFence) { if (mHwcLayers.empty()) { return; } mSurfaceFlingerConsumer->setReleaseFence(releaseFence); } -#else -void BufferLayer::onLayerDisplayed(const sp<const DisplayDevice>& /*hw*/, - HWComposer::HWCLayerInterface* layer) { - if (layer) { - layer->onDisplayed(); - mSurfaceFlingerConsumer->setReleaseFence(layer->getAndResetReleaseFence()); - } -} -#endif void BufferLayer::abandon() { mSurfaceFlingerConsumer->abandon(); @@ -376,7 +362,6 @@ bool BufferLayer::getTransformToDisplayInverse() const { return mSurfaceFlingerConsumer->getTransformToDisplayInverse(); } -#ifdef USE_HWC2 void BufferLayer::releasePendingBuffer(nsecs_t dequeueReadyTime) { if (!mSurfaceFlingerConsumer->releasePendingBuffer()) { return; @@ -393,7 +378,6 @@ void BufferLayer::releasePendingBuffer(nsecs_t dequeueReadyTime) { std::move(releaseFenceTime)); } } -#endif Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime) { ATRACE_CALL(); @@ -523,16 +507,6 @@ Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime { Mutex::Autolock lock(mFrameEventHistoryMutex); mFrameEventHistory.addLatch(mCurrentFrameNumber, latchTime); -#ifndef USE_HWC2 - auto releaseFenceTime = - std::make_shared<FenceTime>(mSurfaceFlingerConsumer->getPrevFinalReleaseFence()); - mReleaseTimeline.updateSignalTimes(); - mReleaseTimeline.push(releaseFenceTime); - if (mPreviousFrameNumber != 0) { - mFrameEventHistory.addRelease(mPreviousFrameNumber, latchTime, - std::move(releaseFenceTime)); - } -#endif } mRefreshPending = true; @@ -604,7 +578,6 @@ void BufferLayer::setDefaultBufferSize(uint32_t w, uint32_t h) { mSurfaceFlingerConsumer->setDefaultBufferSize(w, h); } -#ifdef USE_HWC2 void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) { // Apply this display's projection's viewport to the visible region // before giving it to the HWC HAL. @@ -676,28 +649,6 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) } } -#else -void BufferLayer::setAcquireFence(const sp<const DisplayDevice>& /* hw */, - HWComposer::HWCLayerInterface& layer) { - int fenceFd = -1; - - // TODO: there is a possible optimization here: we only need to set the - // acquire fence the first time a new buffer is acquired on EACH display. - - if (layer.getCompositionType() == HWC_OVERLAY || - layer.getCompositionType() == HWC_CURSOR_OVERLAY) { - sp<Fence> fence = mSurfaceFlingerConsumer->getCurrentFence(); - if (fence->isValid()) { - fenceFd = fence->dup(); - if (fenceFd == -1) { - ALOGW("failed to dup layer fence, skipping sync: %d", errno); - } - } - } - layer.setAcquireFenceFd(fenceFd); -} -#endif - bool BufferLayer::isOpaque(const Layer::State& s) const { // if we don't have a buffer or sidebandStream yet, we're translucent regardless of the // layer's opaque flag. @@ -871,9 +822,7 @@ void BufferLayer::drawWithOpenGL(const RenderArea& renderArea, bool useIdentityT RenderEngine& engine(mFlinger->getRenderEngine()); engine.setupLayerBlending(mPremultipliedAlpha, isOpaque(s), false /* disableTexture */, getColor()); -#ifdef USE_HWC2 engine.setSourceDataSpace(mCurrentState.dataSpace); -#endif engine.drawMesh(mMesh); engine.disableBlending(); } @@ -913,7 +862,6 @@ uint64_t BufferLayer::getHeadFrameNumber() const { } bool BufferLayer::headFenceHasSignaled() const { -#ifdef USE_HWC2 if (latchUnsignaledBuffers()) { return true; } @@ -930,9 +878,6 @@ bool BufferLayer::headFenceHasSignaled() const { return true; } return mQueueItems[0].mFenceTime->getSignalTime() != Fence::SIGNAL_TIME_PENDING; -#else - return true; -#endif } uint32_t BufferLayer::getEffectiveScalingMode() const { diff --git a/services/surfaceflinger/BufferLayer.h b/services/surfaceflinger/BufferLayer.h index 418f032198..078302bc75 100644 --- a/services/surfaceflinger/BufferLayer.h +++ b/services/surfaceflinger/BufferLayer.h @@ -105,12 +105,7 @@ public: void onDraw(const RenderArea& renderArea, const Region& clip, bool useIdentityTransform) const override; -#ifdef USE_HWC2 void onLayerDisplayed(const sp<Fence>& releaseFence) override; -#else - void onLayerDisplayed(const sp<const DisplayDevice>& hw, - HWComposer::HWCLayerInterface* layer) override; -#endif void abandon() override; bool shouldPresentNow(const DispSync& dispSync) const override; @@ -124,10 +119,8 @@ public: public: bool onPreComposition(nsecs_t refreshStartTime) override; -#ifdef USE_HWC2 // If a buffer was replaced this frame, release the former buffer void releasePendingBuffer(nsecs_t dequeueReadyTime); -#endif /* * latchBuffer - called each time the screen is redrawn and returns whether @@ -139,12 +132,7 @@ public: bool isBufferLatched() const override { return mRefreshPending; } void setDefaultBufferSize(uint32_t w, uint32_t h) override; -#ifdef USE_HWC2 void setPerFrameData(const sp<const DisplayDevice>& displayDevice) override; -#else - void setAcquireFence(const sp<const DisplayDevice>& hw, - HWComposer::HWCLayerInterface& layer) override; -#endif bool isOpaque(const Layer::State& s) const override; diff --git a/services/surfaceflinger/ColorLayer.cpp b/services/surfaceflinger/ColorLayer.cpp index 8a17f882d0..292e1a7350 100644 --- a/services/surfaceflinger/ColorLayer.cpp +++ b/services/surfaceflinger/ColorLayer.cpp @@ -61,7 +61,6 @@ bool ColorLayer::isVisible() const { return !isHiddenByPolicy() && s.color.a; } -#ifdef USE_HWC2 void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) { const Transform& tr = displayDevice->getTransform(); const auto& viewport = displayDevice->getViewport(); @@ -89,7 +88,6 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) { static_cast<int32_t>(error)); } } -#endif // --------------------------------------------------------------------------- diff --git a/services/surfaceflinger/ColorLayer.h b/services/surfaceflinger/ColorLayer.h index debd3c3869..4022b319fa 100644 --- a/services/surfaceflinger/ColorLayer.h +++ b/services/surfaceflinger/ColorLayer.h @@ -42,21 +42,14 @@ public: void notifyAvailableFrames() override {} PixelFormat getPixelFormat() const override { return PIXEL_FORMAT_NONE; } uint32_t getEffectiveScalingMode() const override { return 0; } -#ifdef USE_HWC2 void releasePendingBuffer(nsecs_t) override {} -#endif Region latchBuffer(bool&, nsecs_t) override { return Region(); } void useSurfaceDamage() override {} void useEmptyDamage() override {} bool isBufferLatched() const override { return false; } bool onPreComposition(nsecs_t) override { return true; } void abandon() override {} -#ifdef USE_HWC2 void setPerFrameData(const sp<const DisplayDevice>& displayDevice) override; -#else - void setAcquireFence(const sp<const DisplayDevice>& /*hw*/, - HWComposer::HWCLayerInterface& /*layer*/) override {} -#endif void setDefaultBufferSize(uint32_t /*w*/, uint32_t /*h*/) override {} bool shouldPresentNow(const DispSync& /*dispSync*/) const override { return false; } bool onPostComposition(const std::shared_ptr<FenceTime>& /*glDoneFence*/, diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 0244c1b862..ef7d482f28 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -38,9 +38,7 @@ #include "DisplayHardware/DisplaySurface.h" #include "DisplayHardware/HWComposer.h" -#ifdef USE_HWC2 #include "DisplayHardware/HWC2.h" -#endif #include "RenderEngine/RenderEngine.h" #include "clz.h" @@ -86,9 +84,6 @@ DisplayDevice::DisplayDevice( const sp<SurfaceFlinger>& flinger, DisplayType type, int32_t hwcId, -#ifndef USE_HWC2 - int format, -#endif bool isSecure, const wp<IBinder>& displayToken, const sp<DisplaySurface>& displaySurface, @@ -105,9 +100,6 @@ DisplayDevice::DisplayDevice( mSurface(EGL_NO_SURFACE), mDisplayWidth(), mDisplayHeight(), -#ifndef USE_HWC2 - mFormat(), -#endif mFlags(), mPageFlipCount(), mIsSecure(isSecure), @@ -121,12 +113,8 @@ DisplayDevice::DisplayDevice( mNativeWindow = surface = new Surface(producer, false); ANativeWindow* const window = mNativeWindow.get(); -#ifdef USE_HWC2 mActiveColorMode = HAL_COLOR_MODE_NATIVE; mDisplayHasWideColor = supportWideColor; -#else - (void) supportWideColor; -#endif /* * Create our display's surface */ @@ -134,13 +122,8 @@ DisplayDevice::DisplayDevice( EGLSurface eglSurface; EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (config == EGL_NO_CONFIG) { -#ifdef USE_HWC2 config = RenderEngine::chooseEglConfig(display, PIXEL_FORMAT_RGBA_8888, /*logConfig*/ false); -#else - config = RenderEngine::chooseEglConfig(display, format, - /*logConfig*/ false); -#endif } eglSurface = eglCreateWindowSurface(display, config, window, NULL); eglQuerySurface(display, eglSurface, EGL_WIDTH, &mDisplayWidth); @@ -159,9 +142,6 @@ DisplayDevice::DisplayDevice( mConfig = config; mDisplay = display; mSurface = eglSurface; -#ifndef USE_HWC2 - mFormat = format; -#endif mPageFlipCount = 0; mViewport.makeInvalid(); mFrame.makeInvalid(); @@ -202,10 +182,6 @@ DisplayDevice::~DisplayDevice() { void DisplayDevice::disconnect(HWComposer& hwc) { if (mHwcDisplayId >= 0) { hwc.disconnectDisplay(mHwcDisplayId); -#ifndef USE_HWC2 - if (mHwcDisplayId >= DISPLAY_VIRTUAL) - hwc.freeDisplayId(mHwcDisplayId); -#endif mHwcDisplayId = -1; } } @@ -222,12 +198,6 @@ int DisplayDevice::getHeight() const { return mDisplayHeight; } -#ifndef USE_HWC2 -PixelFormat DisplayDevice::getFormat() const { - return mFormat; -} -#endif - EGLSurface DisplayDevice::getEGLSurface() const { return mSurface; } @@ -243,12 +213,6 @@ uint32_t DisplayDevice::getPageFlipCount() const { return mPageFlipCount; } -#ifndef USE_HWC2 -status_t DisplayDevice::compositionComplete() const { - return mDisplaySurface->compositionComplete(); -} -#endif - void DisplayDevice::flip(const Region& dirty) const { mFlinger->getRenderEngine().checkErrors(); @@ -269,7 +233,6 @@ status_t DisplayDevice::beginFrame(bool mustRecompose) const { return mDisplaySurface->beginFrame(mustRecompose); } -#ifdef USE_HWC2 status_t DisplayDevice::prepareFrame(HWComposer& hwc) { status_t error = hwc.prepare(*this); if (error != NO_ERROR) { @@ -293,41 +256,9 @@ status_t DisplayDevice::prepareFrame(HWComposer& hwc) { } return mDisplaySurface->prepareFrame(compositionType); } -#else -status_t DisplayDevice::prepareFrame(const HWComposer& hwc) const { - DisplaySurface::CompositionType compositionType; - bool haveGles = hwc.hasGlesComposition(mHwcDisplayId); - bool haveHwc = hwc.hasHwcComposition(mHwcDisplayId); - if (haveGles && haveHwc) { - compositionType = DisplaySurface::COMPOSITION_MIXED; - } else if (haveGles) { - compositionType = DisplaySurface::COMPOSITION_GLES; - } else if (haveHwc) { - compositionType = DisplaySurface::COMPOSITION_HWC; - } else { - // Nothing to do -- when turning the screen off we get a frame like - // this. Call it a HWC frame since we won't be doing any GLES work but - // will do a prepare/set cycle. - compositionType = DisplaySurface::COMPOSITION_HWC; - } - return mDisplaySurface->prepareFrame(compositionType); -} -#endif void DisplayDevice::swapBuffers(HWComposer& hwc) const { -#ifdef USE_HWC2 if (hwc.hasClientComposition(mHwcDisplayId)) { -#else - // We need to call eglSwapBuffers() if: - // (1) we don't have a hardware composer, or - // (2) we did GLES composition this frame, and either - // (a) we have framebuffer target support (not present on legacy - // devices, where HWComposer::commit() handles things); or - // (b) this is a virtual display - if (hwc.initCheck() != NO_ERROR || - (hwc.hasGlesComposition(mHwcDisplayId) && - (hwc.supportsFramebufferTarget() || mType >= DISPLAY_VIRTUAL))) { -#endif EGLBoolean success = eglSwapBuffers(mDisplay, mSurface); if (!success) { EGLint error = eglGetError(); @@ -349,17 +280,9 @@ void DisplayDevice::swapBuffers(HWComposer& hwc) const { } } -#ifdef USE_HWC2 void DisplayDevice::onSwapBuffersCompleted() const { mDisplaySurface->onFrameCommitted(); } -#else -void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const { - if (hwc.initCheck() == NO_ERROR) { - mDisplaySurface->onFrameCommitted(); - } -} -#endif uint32_t DisplayDevice::getFlags() const { @@ -437,7 +360,6 @@ int DisplayDevice::getActiveConfig() const { } // ---------------------------------------------------------------------------- -#ifdef USE_HWC2 void DisplayDevice::setActiveColorMode(android_color_mode_t mode) { mActiveColorMode = mode; } @@ -450,7 +372,6 @@ void DisplayDevice::setCompositionDataSpace(android_dataspace dataspace) { ANativeWindow* const window = mNativeWindow.get(); native_window_set_buffers_data_space(window, dataspace); } -#endif // ---------------------------------------------------------------------------- diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h index 49fef5805f..50e30b2571 100644 --- a/services/surfaceflinger/DisplayDevice.h +++ b/services/surfaceflinger/DisplayDevice.h @@ -21,18 +21,13 @@ #include <stdlib.h> -#ifndef USE_HWC2 -#include <ui/PixelFormat.h> -#endif #include <ui/Region.h> #include <EGL/egl.h> #include <EGL/eglext.h> -#ifdef USE_HWC2 #include <binder/IBinder.h> #include <utils/RefBase.h> -#endif #include <utils/Mutex.h> #include <utils/String8.h> #include <utils/Timers.h> @@ -41,9 +36,7 @@ #include <hardware/hwcomposer_defs.h> #include "RenderArea.h" -#ifdef USE_HWC2 #include <memory> -#endif struct ANativeWindow; @@ -90,9 +83,6 @@ public: const sp<SurfaceFlinger>& flinger, DisplayType type, int32_t hwcId, -#ifndef USE_HWC2 - int format, -#endif bool isSecure, const wp<IBinder>& displayToken, const sp<DisplaySurface>& displaySurface, @@ -117,9 +107,6 @@ public: int getWidth() const; int getHeight() const; -#ifndef USE_HWC2 - PixelFormat getFormat() const; -#endif uint32_t getFlags() const; EGLSurface getEGLSurface() const; @@ -150,24 +137,13 @@ public: // We pass in mustRecompose so we can keep VirtualDisplaySurface's state // machine happy without actually queueing a buffer if nothing has changed status_t beginFrame(bool mustRecompose) const; -#ifdef USE_HWC2 status_t prepareFrame(HWComposer& hwc); bool getWideColorSupport() const { return mDisplayHasWideColor; } -#else - status_t prepareFrame(const HWComposer& hwc) const; -#endif void swapBuffers(HWComposer& hwc) const; -#ifndef USE_HWC2 - status_t compositionComplete() const; -#endif // called after h/w composer has completed its set() call -#ifdef USE_HWC2 void onSwapBuffersCompleted() const; -#else - void onSwapBuffersCompleted(HWComposer& hwc) const; -#endif Rect getBounds() const { return Rect(mDisplayWidth, mDisplayHeight); @@ -189,11 +165,9 @@ public: void setPowerMode(int mode); bool isDisplayOn() const; -#ifdef USE_HWC2 android_color_mode_t getActiveColorMode() const; void setActiveColorMode(android_color_mode_t mode); void setCompositionDataSpace(android_dataspace dataspace); -#endif /* ------------------------------------------------------------------------ * Display active config management. @@ -228,9 +202,6 @@ private: EGLSurface mSurface; int mDisplayWidth; int mDisplayHeight; -#ifndef USE_HWC2 - PixelFormat mFormat; -#endif uint32_t mFlags; mutable uint32_t mPageFlipCount; String8 mDisplayName; @@ -269,7 +240,6 @@ private: int mPowerMode; // Current active config int mActiveConfig; -#ifdef USE_HWC2 // current active color mode android_color_mode_t mActiveColorMode; @@ -277,7 +247,6 @@ private: // Initialized by SurfaceFlinger when the DisplayDevice is created. // Fed to RenderEngine during composition. bool mDisplayHasWideColor; -#endif }; struct DisplayDeviceState { @@ -319,12 +288,10 @@ public: bool isSecure() const override { return mDevice->isSecure(); } bool needsFiltering() const override { return mDevice->needsFiltering(); } Rect getSourceCrop() const override { return mSourceCrop; } -#ifdef USE_HWC2 bool getWideColorSupport() const override { return mDevice->getWideColorSupport(); } android_color_mode_t getActiveColorMode() const override { return mDevice->getActiveColorMode(); } -#endif private: const sp<const DisplayDevice> mDevice; diff --git a/services/surfaceflinger/DisplayHardware/DisplaySurface.h b/services/surfaceflinger/DisplayHardware/DisplaySurface.h index cb08f084fe..f744f5cf21 100644 --- a/services/surfaceflinger/DisplayHardware/DisplaySurface.h +++ b/services/surfaceflinger/DisplayHardware/DisplaySurface.h @@ -50,14 +50,6 @@ public: }; virtual status_t prepareFrame(CompositionType compositionType) = 0; -#ifndef USE_HWC2 - // Should be called when composition rendering is complete for a frame (but - // eglSwapBuffers hasn't necessarily been called). Required by certain - // older drivers for synchronization. - // TODO: Remove this when we drop support for HWC 1.0. - virtual status_t compositionComplete() = 0; -#endif - // Inform the surface that GLES composition is complete for this frame, and // the surface should make sure that HWComposer has the correct buffer for // this frame. Some implementations may only push a new buffer to diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp index 93c6d5486f..182629c97e 100644 --- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp +++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp @@ -59,32 +59,21 @@ FramebufferSurface::FramebufferSurface(HWComposer& hwc, int disp, mCurrentBufferSlot(-1), mCurrentBuffer(), mCurrentFence(Fence::NO_FENCE), -#ifdef USE_HWC2 mHwc(hwc), mHasPendingRelease(false), mPreviousBufferSlot(BufferQueue::INVALID_BUFFER_SLOT), mPreviousBuffer() -#else - mHwc(hwc) -#endif { -#ifdef USE_HWC2 ALOGV("Creating for display %d", disp); -#endif mName = "FramebufferSurface"; mConsumer->setConsumerName(mName); mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER); -#ifdef USE_HWC2 const auto& activeConfig = mHwc.getActiveConfig(disp); mConsumer->setDefaultBufferSize(activeConfig->getWidth(), activeConfig->getHeight()); -#else - mConsumer->setDefaultBufferFormat(mHwc.getFormat(disp)); - mConsumer->setDefaultBufferSize(mHwc.getWidth(disp), mHwc.getHeight(disp)); -#endif mConsumer->setMaxAcquiredBufferCount( SurfaceFlinger::maxFrameBufferAcquiredBuffers - 1); } @@ -98,7 +87,6 @@ status_t FramebufferSurface::prepareFrame(CompositionType /*compositionType*/) { } status_t FramebufferSurface::advanceFrame() { -#ifdef USE_HWC2 uint32_t slot = 0; sp<GraphicBuffer> buf; sp<Fence> acquireFence(Fence::NO_FENCE); @@ -110,32 +98,18 @@ status_t FramebufferSurface::advanceFrame() { strerror(-result), result); } return result; -#else - // 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; -#endif } -#ifdef USE_HWC2 status_t FramebufferSurface::nextBuffer(uint32_t& outSlot, sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence, android_dataspace_t& outDataspace) { -#else -status_t FramebufferSurface::nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence) { -#endif Mutex::Autolock lock(mMutex); BufferItem item; status_t err = acquireBufferLocked(&item, 0); if (err == BufferQueue::NO_BUFFER_AVAILABLE) { -#ifdef USE_HWC2 mHwcBufferCache.getHwcBuffer(mCurrentBufferSlot, mCurrentBuffer, &outSlot, &outBuffer); -#else - outBuffer = mCurrentBuffer; -#endif return NO_ERROR; } else if (err != NO_ERROR) { ALOGE("error acquiring buffer: %s (%d)", strerror(-err), err); @@ -152,26 +126,15 @@ status_t FramebufferSurface::nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& // had released the old buffer first. if (mCurrentBufferSlot != BufferQueue::INVALID_BUFFER_SLOT && item.mSlot != mCurrentBufferSlot) { -#ifdef USE_HWC2 mHasPendingRelease = true; mPreviousBufferSlot = mCurrentBufferSlot; mPreviousBuffer = mCurrentBuffer; -#else - // Release the previous buffer. - err = releaseBufferLocked(mCurrentBufferSlot, mCurrentBuffer, - EGL_NO_DISPLAY, EGL_NO_SYNC_KHR); - if (err < NO_ERROR) { - ALOGE("error releasing buffer: %s (%d)", strerror(-err), err); - return err; - } -#endif } mCurrentBufferSlot = item.mSlot; mCurrentBuffer = mSlots[mCurrentBufferSlot].mGraphicBuffer; mCurrentFence = item.mFence; outFence = item.mFence; -#ifdef USE_HWC2 mHwcBufferCache.getHwcBuffer(mCurrentBufferSlot, mCurrentBuffer, &outSlot, &outBuffer); outDataspace = item.mDataSpace; @@ -181,31 +144,10 @@ status_t FramebufferSurface::nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& ALOGE("error posting framebuffer: %d", result); return result; } -#else - outBuffer = mCurrentBuffer; -#endif return NO_ERROR; } -#ifndef USE_HWC2 -// Overrides ConsumerBase::onFrameAvailable(), does not call base class impl. -void FramebufferSurface::onFrameAvailable(const BufferItem& /* item */) { - sp<GraphicBuffer> buf; - sp<Fence> acquireFence; - status_t err = nextBuffer(buf, acquireFence); - if (err != NO_ERROR) { - ALOGE("error latching nnext FramebufferSurface buffer: %s (%d)", - strerror(-err), err); - return; - } - err = mHwc.fbPost(mDisplayType, acquireFence, buf); - if (err != NO_ERROR) { - ALOGE("error posting framebuffer: %d", err); - } -} -#endif - void FramebufferSurface::freeBufferLocked(int slotIndex) { ConsumerBase::freeBufferLocked(slotIndex); if (slotIndex == mCurrentBufferSlot) { @@ -214,7 +156,6 @@ void FramebufferSurface::freeBufferLocked(int slotIndex) { } void FramebufferSurface::onFrameCommitted() { -#ifdef USE_HWC2 if (mHasPendingRelease) { sp<Fence> fence = mHwc.getPresentFence(mDisplayType); if (fence->isValid()) { @@ -231,24 +172,7 @@ void FramebufferSurface::onFrameCommitted() { mPreviousBuffer.clear(); mHasPendingRelease = false; } -#else - sp<Fence> fence = mHwc.getAndResetReleaseFence(mDisplayType); - if (fence->isValid() && - mCurrentBufferSlot != BufferQueue::INVALID_BUFFER_SLOT) { - status_t err = addReleaseFence(mCurrentBufferSlot, - mCurrentBuffer, fence); - ALOGE_IF(err, "setReleaseFenceFd: failed to add the fence: %s (%d)", - strerror(-err), err); - } -#endif -} - -#ifndef USE_HWC2 -status_t FramebufferSurface::compositionComplete() -{ - return mHwc.fbCompositionComplete(); } -#endif void FramebufferSurface::dumpAsString(String8& result) const { Mutex::Autolock lock(mMutex); @@ -259,9 +183,6 @@ void FramebufferSurface::dumpAsString(String8& result) const { void FramebufferSurface::dumpLocked(String8& result, const char* prefix) const { -#ifndef USE_HWC2 - mHwc.fbDump(result); -#endif ConsumerBase::dumpLocked(result, prefix); } diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h index a1756ca3c2..4186b7aac4 100644 --- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h +++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h @@ -42,9 +42,6 @@ public: virtual status_t beginFrame(bool mustRecompose); virtual status_t prepareFrame(CompositionType compositionType); -#ifndef USE_HWC2 - virtual status_t compositionComplete(); -#endif virtual status_t advanceFrame(); virtual void onFrameCommitted(); virtual void dumpAsString(String8& result) const; @@ -58,9 +55,6 @@ public: private: virtual ~FramebufferSurface() { }; // this class cannot be overloaded -#ifndef USE_HWC2 - virtual void onFrameAvailable(const BufferItem& item); -#endif virtual void freeBufferLocked(int slotIndex); virtual void dumpLocked(String8& result, const char* prefix) const; @@ -68,12 +62,8 @@ private: // nextBuffer waits for and then latches the next buffer from the // BufferQueue and releases the previously latched buffer to the // BufferQueue. The new buffer is returned in the 'buffer' argument. -#ifdef USE_HWC2 status_t nextBuffer(uint32_t& outSlot, sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence, android_dataspace_t& outDataspace); -#else - status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence); -#endif // mDisplayType must match one of the HWC display types int mDisplayType; @@ -100,14 +90,12 @@ private: // Hardware composer, owned by SurfaceFlinger. HWComposer& mHwc; -#ifdef USE_HWC2 HWComposerBufferCache mHwcBufferCache; // Previous buffer to release after getting an updated retire fence bool mHasPendingRelease; int mPreviousBufferSlot; sp<GraphicBuffer> mPreviousBuffer; -#endif }; // --------------------------------------------------------------------------- diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h index 3640bb5a98..3b6d931b5c 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer.h @@ -14,10 +14,6 @@ * limitations under the License. */ -#ifndef USE_HWC2 -#include "HWComposer_hwc1.h" -#else - #ifndef ANDROID_SF_HWCOMPOSER_H #define ANDROID_SF_HWCOMPOSER_H @@ -219,5 +215,3 @@ private: }; // namespace android #endif // ANDROID_SF_HWCOMPOSER_H - -#endif // #ifdef USE_HWC2 diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp index 1de5e48cb9..dba6f7cf9a 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp @@ -176,12 +176,6 @@ status_t VirtualDisplaySurface::prepareFrame(CompositionType compositionType) { return NO_ERROR; } -#ifndef USE_HWC2 -status_t VirtualDisplaySurface::compositionComplete() { - return NO_ERROR; -} -#endif - status_t VirtualDisplaySurface::advanceFrame() { if (mDisplayId < 0) return NO_ERROR; @@ -221,7 +215,6 @@ status_t VirtualDisplaySurface::advanceFrame() { status_t result = NO_ERROR; if (fbBuffer != NULL) { -#ifdef USE_HWC2 uint32_t hwcSlot = 0; sp<GraphicBuffer> hwcBuffer; mHwcBufferCache.getHwcBuffer(mFbProducerSlot, fbBuffer, @@ -230,9 +223,6 @@ status_t VirtualDisplaySurface::advanceFrame() { // TODO: Correctly propagate the dataspace from GL composition result = mHwc.setClientTarget(mDisplayId, hwcSlot, mFbFence, hwcBuffer, HAL_DATASPACE_UNKNOWN); -#else - result = mHwc.fbPost(mDisplayId, mFbFence, fbBuffer); -#endif } return result; @@ -246,22 +236,14 @@ void VirtualDisplaySurface::onFrameCommitted() { "Unexpected onFrameCommitted() in %s state", dbgStateStr()); mDbgState = DBG_STATE_IDLE; -#ifdef USE_HWC2 sp<Fence> retireFence = mHwc.getPresentFence(mDisplayId); -#else - sp<Fence> fbFence = mHwc.getAndResetReleaseFence(mDisplayId); -#endif if (mCompositionType == COMPOSITION_MIXED && mFbProducerSlot >= 0) { // release the scratch buffer back to the pool Mutex::Autolock lock(mMutex); int sslot = mapProducer2SourceSlot(SOURCE_SCRATCH, mFbProducerSlot); VDS_LOGV("onFrameCommitted: release scratch sslot=%d", sslot); -#ifdef USE_HWC2 addReleaseFenceLocked(sslot, mProducerBuffers[mFbProducerSlot], retireFence); -#else - addReleaseFenceLocked(sslot, mProducerBuffers[mFbProducerSlot], fbFence); -#endif releaseBufferLocked(sslot, mProducerBuffers[mFbProducerSlot], EGL_NO_DISPLAY, EGL_NO_SYNC_KHR); } @@ -269,9 +251,6 @@ void VirtualDisplaySurface::onFrameCommitted() { if (mOutputProducerSlot >= 0) { int sslot = mapProducer2SourceSlot(SOURCE_SINK, mOutputProducerSlot); QueueBufferOutput qbo; -#ifndef USE_HWC2 - sp<Fence> outFence = mHwc.getLastRetireFence(mDisplayId); -#endif VDS_LOGV("onFrameCommitted: queue sink sslot=%d", sslot); if (mMustRecompose) { status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot, @@ -280,11 +259,7 @@ void VirtualDisplaySurface::onFrameCommitted() { HAL_DATASPACE_UNKNOWN, Rect(mSinkBufferWidth, mSinkBufferHeight), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */, -#ifdef USE_HWC2 retireFence), -#else - outFence), -#endif &qbo); if (result == NO_ERROR) { updateQueueBufferOutput(std::move(qbo)); @@ -294,11 +269,7 @@ void VirtualDisplaySurface::onFrameCommitted() { // through the motions of updating the display to keep our state // machine happy. We cancel the buffer to avoid triggering another // re-composition and causing an infinite loop. -#ifdef USE_HWC2 mSource[SOURCE_SINK]->cancelBuffer(sslot, retireFence); -#else - mSource[SOURCE_SINK]->cancelBuffer(sslot, outFence); -#endif } } diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h index 1671aba1d8..5c8aceae92 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h @@ -84,9 +84,6 @@ public: // virtual status_t beginFrame(bool mustRecompose); virtual status_t prepareFrame(CompositionType compositionType); -#ifndef USE_HWC2 - virtual status_t compositionComplete(); -#endif virtual status_t advanceFrame(); virtual void onFrameCommitted(); virtual void dumpAsString(String8& result) const; @@ -253,10 +250,7 @@ private: bool mMustRecompose; -#ifdef USE_HWC2 HWComposerBufferCache mHwcBufferCache; -#endif - bool mForceHwcCopy; }; diff --git a/services/surfaceflinger/EventControlThread.cpp b/services/surfaceflinger/EventControlThread.cpp index 052a959724..02eea4769b 100644 --- a/services/surfaceflinger/EventControlThread.cpp +++ b/services/surfaceflinger/EventControlThread.cpp @@ -53,12 +53,7 @@ bool EventControlThread::threadLoop() { } bool enable = requestedVsyncState == VsyncState::On; -#ifdef USE_HWC2 mFlinger->setVsyncEnabled(HWC_DISPLAY_PRIMARY, enable); -#else - mFlinger->eventControl(HWC_DISPLAY_PRIMARY, - SurfaceFlinger::EVENT_VSYNC, enable); -#endif currentVsyncState = requestedVsyncState; } diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 80987a4f91..aa3100eb1d 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -85,9 +85,6 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n mFiltering(false), mNeedsFiltering(false), mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2), -#ifndef USE_HWC2 - mIsGlesComposition(false), -#endif mProtectedByApp(false), mClientRef(client), mPotentialCursor(false), @@ -128,13 +125,9 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n // drawing state & current state are identical mDrawingState = mCurrentState; -#ifdef USE_HWC2 const auto& hwc = flinger->getHwComposer(); const auto& activeConfig = hwc.getActiveConfig(HWC_DISPLAY_PRIMARY); nsecs_t displayPeriod = activeConfig->getVsyncPeriod(); -#else - nsecs_t displayPeriod = flinger->getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY); -#endif mFrameTracker.setDisplayRefreshPeriod(displayPeriod); CompositorTiming compositorTiming; @@ -157,12 +150,7 @@ Layer::~Layer() { * Layer. So, the implementation is done in BufferLayer. When called on a * ColorLayer object, it's essentially a NOP. */ -#ifdef USE_HWC2 void Layer::onLayerDisplayed(const sp<Fence>& /*releaseFence*/) {} -#else -void Layer::onLayerDisplayed(const sp<const DisplayDevice>& /* hw */, - HWComposer::HWCLayerInterface* /*layer*/) {} -#endif void Layer::onRemovedFromCurrentState() { // the layer is removed from SF mCurrentState to mLayersPendingRemoval @@ -187,9 +175,7 @@ void Layer::onRemoved() { // the layer is removed from SF mLayersPendingRemoval abandon(); -#ifdef USE_HWC2 destroyAllHwcLayers(); -#endif for (const auto& child : mCurrentChildren) { child->onRemoved(); @@ -217,7 +203,6 @@ sp<IBinder> Layer::getHandle() { // h/w composer set-up // --------------------------------------------------------------------------- -#ifdef USE_HWC2 bool Layer::createHwcLayer(HWComposer* hwc, int32_t hwcId) { LOG_ALWAYS_FATAL_IF(mHwcLayers.count(hwcId) != 0, "Already have a layer for hwcId %d", hwcId); HWC2::Layer* layer = hwc->createLayer(hwcId); @@ -254,7 +239,6 @@ void Layer::destroyAllHwcLayers() { LOG_ALWAYS_FATAL_IF(!mHwcLayers.empty(), "All hardware composer layers should have been destroyed"); } -#endif Rect Layer::getContentCrop() const { // this is the crop rectangle that applies to the buffer @@ -470,21 +454,12 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const { return crop; } -#ifdef USE_HWC2 void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z) -#else -void Layer::setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerInterface& layer) -#endif { -#ifdef USE_HWC2 const auto hwcId = displayDevice->getHwcDisplayId(); auto& hwcInfo = mHwcLayers[hwcId]; -#else - layer.setDefaultState(); -#endif // enable this layer -#ifdef USE_HWC2 hwcInfo.forceClientComposition = false; if (isSecure() && !displayDevice->isSecure()) { @@ -492,17 +467,9 @@ void Layer::setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerI } auto& hwcLayer = hwcInfo.layer; -#else - layer.setSkip(false); - - if (isSecure() && !hw->isSecure()) { - layer.setSkip(true); - } -#endif // this gives us only the "orientation" component of the transform const State& s(getDrawingState()); -#ifdef USE_HWC2 auto blendMode = HWC2::BlendMode::None; if (!isOpaque(s) || getAlpha() != 1.0f) { blendMode = @@ -514,11 +481,6 @@ void Layer::setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerI " %s (%d)", mName.string(), to_string(blendMode).c_str(), to_string(error).c_str(), static_cast<int32_t>(error)); -#else - if (!isOpaque(s) || getAlpha() != 1.0f) { - layer.setBlending(mPremultipliedAlpha ? HWC_BLENDING_PREMULT : HWC_BLENDING_COVERAGE); - } -#endif // apply the layer's transform, followed by the display's global transform // here we're guaranteed that the layer's transform preserves rects @@ -527,11 +489,7 @@ void Layer::setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerI if (!s.crop.isEmpty()) { Rect activeCrop(s.crop); activeCrop = t.transform(activeCrop); -#ifdef USE_HWC2 if (!activeCrop.intersect(displayDevice->getViewport(), &activeCrop)) { -#else - if (!activeCrop.intersect(hw->getViewport(), &activeCrop)) { -#endif activeCrop.clear(); } activeCrop = t.inverse().transform(activeCrop, true); @@ -558,7 +516,6 @@ void Layer::setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerI frame.clear(); } } -#ifdef USE_HWC2 if (!frame.intersect(displayDevice->getViewport(), &frame)) { frame.clear(); } @@ -607,15 +564,6 @@ void Layer::setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerI error = hwcLayer->setInfo(type, appId); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set info (%d)", mName.string(), static_cast<int32_t>(error)); -#else - if (!frame.intersect(hw->getViewport(), &frame)) { - frame.clear(); - } - const Transform& tr(hw->getTransform()); - layer.setFrame(tr.transform(frame)); - layer.setCrop(computeCrop(hw)); - layer.setPlaneAlpha(static_cast<uint8_t>(std::round(255.0f * getAlpha()))); -#endif /* * Transformations are applied in this order: @@ -650,7 +598,6 @@ void Layer::setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerI // this gives us only the "orientation" component of the transform const uint32_t orientation = transform.getOrientation(); -#ifdef USE_HWC2 if (orientation & Transform::ROT_INVALID) { // we can only handle simple transformation hwcInfo.forceClientComposition = true; @@ -663,17 +610,8 @@ void Layer::setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerI mName.string(), to_string(transform).c_str(), to_string(error).c_str(), static_cast<int32_t>(error)); } -#else - if (orientation & Transform::ROT_INVALID) { - // we can only handle simple transformation - layer.setSkip(true); - } else { - layer.setTransform(orientation); - } -#endif } -#ifdef USE_HWC2 void Layer::forceClientComposition(int32_t hwcId) { if (mHwcLayers.count(hwcId) == 0) { ALOGE("forceClientComposition: no HWC layer found (%d)", hwcId); @@ -682,32 +620,7 @@ void Layer::forceClientComposition(int32_t hwcId) { mHwcLayers[hwcId].forceClientComposition = true; } -#else -void Layer::setPerFrameData(const sp<const DisplayDevice>& hw, - HWComposer::HWCLayerInterface& layer) { - // we have to set the visible region on every frame because - // we currently free it during onLayerDisplayed(), which is called - // after HWComposer::commit() -- every frame. - // Apply this display's projection's viewport to the visible region - // before giving it to the HWC HAL. - const Transform& tr = hw->getTransform(); - Region visible = tr.transform(visibleRegion.intersect(hw->getViewport())); - layer.setVisibleRegionScreen(visible); - layer.setSurfaceDamage(surfaceDamageRegion); - mIsGlesComposition = (layer.getCompositionType() == HWC_FRAMEBUFFER); - - if (mSidebandStream.get()) { - layer.setSidebandStream(mSidebandStream); - } else { - // NOTE: buffer can be NULL if the client never drew into this - // layer yet, or if we ran out of memory - layer.setBuffer(mActiveBuffer); - } -} -#endif - -#ifdef USE_HWC2 void Layer::updateCursorPosition(const sp<const DisplayDevice>& displayDevice) { auto hwcId = displayDevice->getHwcDisplayId(); if (mHwcLayers.count(hwcId) == 0 || getCompositionType(hwcId) != HWC2::Composition::Cursor) { @@ -740,28 +653,6 @@ void Layer::updateCursorPosition(const sp<const DisplayDevice>& displayDevice) { mName.string(), position.left, position.top, to_string(error).c_str(), static_cast<int32_t>(error)); } -#else -Rect Layer::getPosition(const sp<const DisplayDevice>& hw) { - // this gives us only the "orientation" component of the transform - const State& s(getCurrentState()); - - // apply the layer's transform, followed by the display's global transform - // here we're guaranteed that the layer's transform preserves rects - Rect win(s.active.w, s.active.h); - if (!s.crop.isEmpty()) { - win.intersect(s.crop, &win); - } - // subtract the transparent region and snap to the bounds - Rect bounds = reduce(win, s.activeTransparentRegion); - Rect frame(getTransform().transform(bounds)); - frame.intersect(hw->getViewport(), &frame); - if (!s.finalCrop.isEmpty()) { - frame.intersect(s.finalCrop, &frame); - } - const Transform& tr(hw->getTransform()); - return Rect(tr.transform(frame)); -} -#endif // --------------------------------------------------------------------------- // drawing... @@ -791,7 +682,6 @@ void Layer::clearWithOpenGL(const RenderArea& renderArea) const { clearWithOpenGL(renderArea, 0, 0, 0, 0); } -#ifdef USE_HWC2 void Layer::setCompositionType(int32_t hwcId, HWC2::Composition type, bool callIntoHwc) { if (mHwcLayers.count(hwcId) == 0) { ALOGE("setCompositionType called without a valid HWC layer"); @@ -843,7 +733,6 @@ bool Layer::getClearClientTarget(int32_t hwcId) const { } return mHwcLayers.at(hwcId).clearClientTarget; } -#endif bool Layer::addSyncPoint(const std::shared_ptr<SyncPoint>& point) { if (point->getFrameNumber() <= mCurrentFrameNumber) { @@ -1496,7 +1385,7 @@ LayerDebugInfo Layer::getLayerDebugInfo() const { info.mContentDirty = contentDirty; return info; } -#ifdef USE_HWC2 + void Layer::miniDumpHeader(String8& result) { result.append("----------------------------------------"); result.append("---------------------------------------\n"); @@ -1539,7 +1428,6 @@ void Layer::miniDump(String8& result, int32_t hwcId) const { result.append("- - - - - - - - - - - - - - - - - - - - "); result.append("- - - - - - - - - - - - - - - - - - - -\n"); } -#endif void Layer::dumpFrameStats(String8& result) const { mFrameTracker.dumpStats(result); diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 0580b9f40f..c125a3c3e1 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -297,7 +297,6 @@ protected: public: virtual void setDefaultBufferSize(uint32_t w, uint32_t h) = 0; -#ifdef USE_HWC2 void setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z); void forceClientComposition(int32_t hwcId); virtual void setPerFrameData(const sp<const DisplayDevice>& displayDevice) = 0; @@ -309,23 +308,11 @@ public: void setClearClientTarget(int32_t hwcId, bool clear); bool getClearClientTarget(int32_t hwcId) const; void updateCursorPosition(const sp<const DisplayDevice>& hw); -#else - void setGeometry(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerInterface& layer); - void setPerFrameData(const sp<const DisplayDevice>& hw, HWComposer::HWCLayerInterface& layer); - virtual void setAcquireFence(const sp<const DisplayDevice>& hw, - HWComposer::HWCLayerInterface& layer) = 0; - Rect getPosition(const sp<const DisplayDevice>& hw); -#endif /* * called after page-flip */ -#ifdef USE_HWC2 virtual void onLayerDisplayed(const sp<Fence>& releaseFence); -#else - virtual void onLayerDisplayed(const sp<const DisplayDevice>& hw, - HWComposer::HWCLayerInterface* layer); -#endif virtual void abandon() = 0; @@ -346,10 +333,8 @@ public: const std::shared_ptr<FenceTime>& presentFence, const CompositorTiming& compositorTiming) = 0; -#ifdef USE_HWC2 // If a buffer was replaced this frame, release the former buffer virtual void releasePendingBuffer(nsecs_t dequeueReadyTime) = 0; -#endif /* * draw - performs some global clipping optimizations @@ -425,7 +410,6 @@ public: int32_t getQueuedFrameCount() const { return mQueuedFrames; } -#ifdef USE_HWC2 // ----------------------------------------------------------------------- bool createHwcLayer(HWComposer* hwc, int32_t hwcId); @@ -441,7 +425,6 @@ public: return mHwcLayers[hwcId].layer; } -#endif // ----------------------------------------------------------------------- void clearWithOpenGL(const RenderArea& renderArea) const; @@ -458,10 +441,8 @@ public: LayerDebugInfo getLayerDebugInfo() const; /* always call base class first */ -#ifdef USE_HWC2 static void miniDumpHeader(String8& result); void miniDump(String8& result, int32_t hwcId) const; -#endif void dumpFrameStats(String8& result) const; void dumpFrameEvents(String8& result); void clearFrameStats(); @@ -673,7 +654,6 @@ protected: bool mPendingRemoval = false; -#ifdef USE_HWC2 // HWC items, accessed from the main thread struct HWCInfo { HWCInfo() @@ -698,9 +678,6 @@ protected: // case we need to keep track. In non-mirror mode, a layer will have only one // HWCInfo. This map key is a display layerStack. std::unordered_map<int32_t, HWCInfo> mHwcLayers; -#else - bool mIsGlesComposition; -#endif // page-flip thread (currently main thread) bool mProtectedByApp; // application requires protected path to external sink diff --git a/services/surfaceflinger/RenderArea.h b/services/surfaceflinger/RenderArea.h index faf1ec64f8..44b9dc9254 100644 --- a/services/surfaceflinger/RenderArea.h +++ b/services/surfaceflinger/RenderArea.h @@ -24,10 +24,8 @@ public: int getReqHeight() const { return mReqHeight; }; int getReqWidth() const { return mReqWidth; }; Transform::orientation_flags getRotationFlags() const { return mRotationFlags; }; -#ifdef USE_HWC2 virtual bool getWideColorSupport() const = 0; virtual android_color_mode_t getActiveColorMode() const = 0; -#endif status_t updateDimensions(); @@ -37,4 +35,4 @@ private: Transform::orientation_flags mRotationFlags; }; -} // namespace android
\ No newline at end of file +} // namespace android diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp index daaa11e1d3..3ae7042230 100644 --- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp +++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp @@ -44,7 +44,6 @@ #include <fstream> // --------------------------------------------------------------------------- -#ifdef USE_HWC2 bool checkGlError(const char* op, int lineNumber) { bool errorFound = false; GLint error = glGetError(); @@ -103,7 +102,6 @@ void writePPM(const char* basename, GLuint width, GLuint height) { } file.write(reinterpret_cast<char*>(outBuffer.data()), outBuffer.size()); } -#endif // --------------------------------------------------------------------------- namespace android { @@ -132,7 +130,6 @@ GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) : //mColorBlindnessCorrection = M; -#ifdef USE_HWC2 if (mPlatformHasWideColor) { // Compute sRGB to DisplayP3 color transform // NOTE: For now, we are limiting wide-color support to @@ -145,7 +142,6 @@ GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) : mat4 gamutTransform(srgbToP3); mSrgbToDisplayP3 = gamutTransform; } -#endif } GLES20RenderEngine::~GLES20RenderEngine() { @@ -222,7 +218,6 @@ void GLES20RenderEngine::setupLayerBlending(bool premultipliedAlpha, } } -#ifdef USE_HWC2 void GLES20RenderEngine::setColorMode(android_color_mode mode) { ALOGV("setColorMode: %s (0x%x)", decodeColorMode(mode).c_str(), mode); @@ -256,7 +251,6 @@ void GLES20RenderEngine::setWideColor(bool hasWideColor) { bool GLES20RenderEngine::usesWideColor() { return mUseWideColor; } -#endif void GLES20RenderEngine::setupLayerTexturing(const Texture& texture) { GLuint target = texture.getTextureTarget(); @@ -344,7 +338,6 @@ void GLES20RenderEngine::drawMesh(const Mesh& mesh) { mesh.getByteStride(), mesh.getPositions()); -#ifdef USE_HWC2 if (usesWideColor()) { Description wideColorState = mState; if (mDataSpace != HAL_DATASPACE_DISPLAY_P3) { @@ -366,11 +359,6 @@ void GLES20RenderEngine::drawMesh(const Mesh& mesh) { glDrawArrays(mesh.getPrimitive(), 0, mesh.getVertexCount()); } -#else - ProgramCache::getInstance().useProgram(mState); - - glDrawArrays(mesh.getPrimitive(), 0, mesh.getVertexCount()); -#endif if (mesh.getTexCoordsSize()) { glDisableVertexAttribArray(Program::texCoords); @@ -379,13 +367,11 @@ void GLES20RenderEngine::drawMesh(const Mesh& mesh) { void GLES20RenderEngine::dump(String8& result) { RenderEngine::dump(result); -#ifdef USE_HWC2 if (usesWideColor()) { result.append("Wide-color: On\n"); } else { result.append("Wide-color: Off\n"); } -#endif } // --------------------------------------------------------------------------- diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h index 5ac12fc3d6..b96bfe0f99 100644 --- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h +++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.h @@ -70,7 +70,6 @@ protected: Transform::orientation_flags rotation); virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, bool disableTexture, const half4& color) override; -#ifdef USE_HWC2 // Color management related functions and state void setColorMode(android_color_mode mode); @@ -91,7 +90,6 @@ protected: // Currently only supporting sRGB and DisplayP3 color spaces mat4 mSrgbToDisplayP3; -#endif bool mPlatformHasWideColor = false; virtual void setupLayerTexturing(const Texture& texture); diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.h b/services/surfaceflinger/RenderEngine/RenderEngine.h index fa65979edd..7e05cec7d6 100644 --- a/services/surfaceflinger/RenderEngine/RenderEngine.h +++ b/services/surfaceflinger/RenderEngine/RenderEngine.h @@ -101,12 +101,10 @@ public: Rect sourceCrop, size_t hwh, bool yswap, Transform::orientation_flags rotation) = 0; virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, bool disableTexture, const half4& color) = 0; -#ifdef USE_HWC2 virtual void setColorMode(android_color_mode mode) = 0; virtual void setSourceDataSpace(android_dataspace source) = 0; virtual void setWideColor(bool hasWideColor) = 0; virtual bool usesWideColor() = 0; -#endif virtual void setupLayerTexturing(const Texture& texture) = 0; virtual void setupLayerBlackedOut() = 0; virtual void setupFillWithColor(float r, float g, float b, float a) = 0; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index d13b188ab8..96ba5fb766 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2675,12 +2675,10 @@ bool SurfaceFlinger::doComposeSurfaces( if (hasClientComposition) { ALOGV("hasClientComposition"); -#ifdef USE_HWC2 mRenderEngine->setWideColor( displayDevice->getWideColorSupport() && !mForceNativeColorMode); mRenderEngine->setColorMode(mForceNativeColorMode ? HAL_COLOR_MODE_NATIVE : displayDevice->getActiveColorMode()); -#endif if (!displayDevice->makeCurrent(mEGLDisplay, mEGLContext)) { ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s", displayDevice->getDisplayName().string()); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index d10b41bd34..67e4607012 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -63,12 +63,8 @@ #include "SurfaceTracing.h" #include "StartPropertySetThread.h" -#ifdef USE_HWC2 #include "DisplayHardware/HWC2.h" #include "DisplayHardware/HWComposer.h" -#else -#include "DisplayHardware/HWComposer_hwc1.h" -#endif #include "Effects/Daltonizer.h" @@ -117,11 +113,7 @@ enum { class SurfaceFlinger : public BnSurfaceComposer, public PriorityDumper, private IBinder::DeathRecipient, -#ifdef USE_HWC2 private HWC2::ComposerCallback -#else - private HWComposer::EventHandler -#endif { public: @@ -217,11 +209,7 @@ public: // enable/disable h/w composer event // TODO: this should be made accessible only to EventThread -#ifdef USE_HWC2 void setVsyncEnabled(int disp, int enabled); -#else - void eventControl(int disp, int event, int enabled); -#endif // called on the main thread by MessageQueue when an internal message // is received @@ -344,18 +332,12 @@ private: /* ------------------------------------------------------------------------ * HWC2::ComposerCallback / HWComposer::EventHandler interface */ -#ifdef USE_HWC2 void onVsyncReceived(int32_t sequenceId, hwc2_display_t display, int64_t timestamp) override; void onHotplugReceived(int32_t sequenceId, hwc2_display_t display, HWC2::Connection connection, bool primaryDisplay) override; void onRefreshReceived(int32_t sequenceId, hwc2_display_t display) override; -#else - void onVSyncReceived(HWComposer* composer, int type, nsecs_t timestamp) override; - void onHotplugReceived(HWComposer* composer, int disp, bool connected) override; - void onInvalidateReceived(HWComposer* composer) override; -#endif /* ------------------------------------------------------------------------ * Message handling @@ -372,12 +354,8 @@ private: // called on the main thread in response to setActiveConfig() void setActiveConfigInternal(const sp<DisplayDevice>& hw, int mode); // called on the main thread in response to setPowerMode() -#ifdef USE_HWC2 void setPowerModeInternal(const sp<DisplayDevice>& hw, int mode, bool stateLockHeld); -#else - void setPowerModeInternal(const sp<DisplayDevice>& hw, int mode); -#endif // Called on the main thread in response to setActiveColorMode() void setActiveColorModeInternal(const sp<DisplayDevice>& hw, android_color_mode_t colorMode); @@ -463,17 +441,10 @@ private: const sp<IGraphicBufferProducer>& producer, bool useIdentityTransform); -#ifdef USE_HWC2 status_t captureScreenImplLocked(const RenderArea& renderArea, TraverseLayersFunction traverseLayers, ANativeWindowBuffer* buffer, bool useIdentityTransform, bool isLocalScreenshot, int* outSyncFd); -#else - status_t captureScreenImplLocked(const RenderArea& renderArea, - TraverseLayersFunction traverseLayers, - const sp<IGraphicBufferProducer>& producer, - bool useIdentityTransform, bool isLocalScreenshot); -#endif void traverseLayersInDisplay(const sp<const DisplayDevice>& display, int32_t minLayerZ, int32_t maxLayerZ, const LayerVector::Visitor& visitor); @@ -540,10 +511,6 @@ private: // region of all screens presenting this layer stack. void invalidateLayerStack(const sp<const Layer>& layer, const Region& dirty); -#ifndef USE_HWC2 - int32_t allocateHwcDisplayId(DisplayDevice::DisplayType type); -#endif - /* ------------------------------------------------------------------------ * H/W composer */ @@ -642,7 +609,6 @@ private: } status_t doDump(int fd, const Vector<String16>& args, bool asProto); -#ifdef USE_HWC2 /* ------------------------------------------------------------------------ * VrFlinger */ @@ -650,7 +616,6 @@ private: // Check to see if we should handoff to vr flinger. void updateVrFlinger(); -#endif /* ------------------------------------------------------------------------ * Attributes @@ -695,9 +660,7 @@ private: // acquiring mStateLock. std::unique_ptr<HWComposer> mHwc; -#ifdef USE_HWC2 const std::string mHwcServiceName; // "default" for real use, something else for testing. -#endif // constant members (no synchronization needed for access) RenderEngine* mRenderEngine; @@ -716,17 +679,11 @@ private: // don't need synchronization State mDrawingState{LayerVector::StateSet::Drawing}; bool mVisibleRegionsDirty; -#ifndef USE_HWC2 - bool mHwWorkListDirty; -#else bool mGeometryInvalid; -#endif bool mAnimCompositionPending; -#ifdef USE_HWC2 std::vector<sp<Layer>> mLayersWithQueuedFrames; sp<Fence> mPreviousPresentFence = Fence::NO_FENCE; bool mHadClientComposition = false; -#endif FenceTimeline mGlCompositionDoneTimeline; FenceTimeline mDisplayTimeline; @@ -745,9 +702,7 @@ private: nsecs_t mLastTransactionTime; bool mBootFinished; bool mForceFullDamage; -#ifdef USE_HWC2 bool mPropagateBackpressure = true; -#endif SurfaceInterceptor mInterceptor; SurfaceTracing mTracing; bool mUseHwcVirtualDisplays = false; @@ -789,9 +744,6 @@ private: bool mInjectVSyncs; Daltonizer mDaltonizer; -#ifndef USE_HWC2 - bool mDaltonize; -#endif mat4 mPreviousColorMatrix; mat4 mColorMatrix; @@ -833,7 +785,6 @@ private: // either AID_GRAPHICS or AID_SYSTEM. status_t CheckTransactCodeCredentials(uint32_t code); -#ifdef USE_HWC2 std::unique_ptr<dvr::VrFlinger> mVrFlinger; std::atomic<bool> mVrFlingerRequestsDisplay; static bool useVrFlinger; @@ -842,7 +793,6 @@ private: // use to differentiate callbacks from different hardware composer // instances. Each hardware composer instance gets a different sequence id. int32_t mComposerSequenceId; -#endif float mSaturation = 1.0f; bool mForceNativeColorMode = false; diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.cpp b/services/surfaceflinger/SurfaceFlingerConsumer.cpp index abc8fde26b..e17bb58b31 100644 --- a/services/surfaceflinger/SurfaceFlingerConsumer.cpp +++ b/services/surfaceflinger/SurfaceFlingerConsumer.cpp @@ -89,11 +89,7 @@ status_t SurfaceFlingerConsumer::updateTexImage(BufferRejecter* rejecter, } // Release the previous buffer. -#ifdef USE_HWC2 err = updateAndReleaseLocked(item, &mPendingRelease); -#else - err = updateAndReleaseLocked(item); -#endif if (err != NO_ERROR) { return err; } @@ -197,7 +193,6 @@ sp<Fence> SurfaceFlingerConsumer::getPrevFinalReleaseFence() const { return ConsumerBase::mPrevFinalReleaseFence; } -#ifdef USE_HWC2 void SurfaceFlingerConsumer::setReleaseFence(const sp<Fence>& fence) { if (!mPendingRelease.isPending) { @@ -230,7 +225,6 @@ bool SurfaceFlingerConsumer::releasePendingBuffer() mPendingRelease = PendingRelease(); return true; } -#endif void SurfaceFlingerConsumer::setContentsChangedListener( const wp<ContentsChangedListener>& listener) { diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.h b/services/surfaceflinger/SurfaceFlingerConsumer.h index 1126233d60..53b4915426 100644 --- a/services/surfaceflinger/SurfaceFlingerConsumer.h +++ b/services/surfaceflinger/SurfaceFlingerConsumer.h @@ -81,10 +81,8 @@ public: nsecs_t computeExpectedPresent(const DispSync& dispSync); sp<Fence> getPrevFinalReleaseFence() const; -#ifdef USE_HWC2 virtual void setReleaseFence(const sp<Fence>& fence) override; bool releasePendingBuffer(); -#endif void onDisconnect() override; void addAndGetFrameTimestamps( @@ -104,11 +102,9 @@ private: // The portion of this surface that has changed since the previous frame Region mSurfaceDamage; -#ifdef USE_HWC2 // A release that is pending on the receipt of a new release fence from // presentDisplay PendingRelease mPendingRelease; -#endif // The layer for this SurfaceFlingerConsumer const wp<Layer> mLayer; diff --git a/services/surfaceflinger/tests/fakehwc/FakeComposerClient.h b/services/surfaceflinger/tests/fakehwc/FakeComposerClient.h index 2a5a8ad03f..b94418281e 100644 --- a/services/surfaceflinger/tests/fakehwc/FakeComposerClient.h +++ b/services/surfaceflinger/tests/fakehwc/FakeComposerClient.h @@ -16,7 +16,11 @@ #pragma once +#define HWC2_USE_CPP11 +#define HWC2_INCLUDE_STRINGIFICATION #include "ComposerClient.h" +#undef HWC2_USE_CPP11 +#undef HWC2_INCLUDE_STRINGIFICATION #include "RenderState.h" // Needed for display type/ID enums |