Loading libs/renderengine/gl/GLES20RenderEngine.cpp +21 −10 Original line number Diff line number Diff line Loading @@ -275,8 +275,6 @@ std::unique_ptr<GLES20RenderEngine> GLES20RenderEngine::create(int hwcFormat, // now figure out what version of GL did we actually get // NOTE: a dummy surface is not needed if KHR_create_context is supported // TODO(alecmouri): don't create this surface if EGL_KHR_surfaceless_context // is supported. EGLConfig dummyConfig = config; if (dummyConfig == EGL_NO_CONFIG) { Loading @@ -303,10 +301,10 @@ std::unique_ptr<GLES20RenderEngine> GLES20RenderEngine::create(int hwcFormat, break; case GLES_VERSION_2_0: case GLES_VERSION_3_0: engine = std::make_unique<GLES20RenderEngine>(featureFlags, display, config, ctxt, dummy); engine = std::make_unique<GLES20RenderEngine>(featureFlags); break; } engine->setEGLHandles(display, config, ctxt); ALOGI("OpenGL ES informations:"); ALOGI("vendor : %s", extensions.getVendor()); Loading @@ -316,6 +314,9 @@ std::unique_ptr<GLES20RenderEngine> GLES20RenderEngine::create(int hwcFormat, ALOGI("GL_MAX_TEXTURE_SIZE = %zu", engine->getMaxTextureSize()); ALOGI("GL_MAX_VIEWPORT_DIMS = %zu", engine->getMaxViewportDims()); eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroySurface(display, dummy); return engine; } Loading Loading @@ -358,13 +359,11 @@ EGLConfig GLES20RenderEngine::chooseEglConfig(EGLDisplay display, int format, bo return config; } GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags, EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy) GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) : renderengine::impl::RenderEngine(featureFlags), mEGLDisplay(display), mEGLConfig(config), mEGLContext(ctxt), mDummySurface(dummy), mEGLDisplay(EGL_NO_DISPLAY), mEGLConfig(nullptr), mEGLContext(EGL_NO_CONTEXT), mVpWidth(0), mVpHeight(0), mUseColorManagement(featureFlags & USE_COLOR_MANAGEMENT) { Loading Loading @@ -637,6 +636,12 @@ void GLES20RenderEngine::unbindFrameBuffer(Framebuffer* /* framebuffer */) { // back to main framebuffer glBindFramebuffer(GL_FRAMEBUFFER, 0); // Workaround for b/77935566 to force the EGL driver to release the // screenshot buffer setScissor(Rect::EMPTY_RECT); clearWithColor(0.0, 0.0, 0.0, 0.0); disableScissor(); } void GLES20RenderEngine::checkErrors() const { Loading Loading @@ -969,6 +974,12 @@ bool GLES20RenderEngine::needsXYZTransformMatrix() const { return (isInputHdrDataSpace || isOutputHdrDataSpace) && inputTransfer != outputTransfer; } void GLES20RenderEngine::setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt) { mEGLDisplay = display; mEGLConfig = config; mEGLContext = ctxt; } } // namespace gl } // namespace renderengine } // namespace android libs/renderengine/gl/GLES20RenderEngine.h +2 −4 Original line number Diff line number Diff line Loading @@ -47,8 +47,7 @@ public: static std::unique_ptr<GLES20RenderEngine> create(int hwcFormat, uint32_t featureFlags); static EGLConfig chooseEglConfig(EGLDisplay display, int format, bool logConfig); GLES20RenderEngine(uint32_t featureFlags, // See RenderEngine::FeatureFlag EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy); GLES20RenderEngine(uint32_t featureFlags); // See RenderEngine::FeatureFlag ~GLES20RenderEngine() override; std::unique_ptr<Framebuffer> createFramebuffer() override; Loading Loading @@ -121,12 +120,11 @@ private: // with PQ or HLG transfer function. bool isHdrDataSpace(const ui::Dataspace dataSpace) const; bool needsXYZTransformMatrix() const; void setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy); void setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt); EGLDisplay mEGLDisplay; EGLConfig mEGLConfig; EGLContext mEGLContext; EGLSurface mDummySurface; GLuint mProtectedTexName; GLint mMaxViewportDims[2]; GLint mMaxTextureSize; Loading services/surfaceflinger/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -184,7 +184,6 @@ cc_defaults { "libhidltransport", "liblayers_proto", "liblog", "libsync", "libtimestats_proto", "libutils", ], Loading services/surfaceflinger/DisplayDevice.cpp +4 −79 Original line number Diff line number Diff line Loading @@ -35,8 +35,6 @@ #include <gui/Surface.h> #include <hardware/gralloc.h> #include <renderengine/RenderEngine.h> #include <sync/sync.h> #include <system/window.h> #include <ui/DebugUtils.h> #include <ui/DisplayInfo.h> #include <ui/PixelFormat.h> Loading Loading @@ -223,7 +221,6 @@ DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args) mDisplayToken(args.displayToken), mId(args.displayId), mNativeWindow(args.nativeWindow), mGraphicBuffer(nullptr), mDisplaySurface(args.displaySurface), mSurface{std::move(args.renderSurface)}, mDisplayInstallOrientation(args.displayInstallOrientation), Loading Loading @@ -287,10 +284,6 @@ DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args) mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance); ANativeWindow* const window = mNativeWindow.get(); int status = native_window_api_connect(mNativeWindow.get(), NATIVE_WINDOW_API_EGL); ALOGE_IF(status != NO_ERROR, "Unable to connect BQ producer: %d", status); mDisplayWidth = ANativeWindow_getWidth(window); mDisplayHeight = ANativeWindow_getHeight(window); Loading Loading @@ -328,6 +321,7 @@ uint32_t DisplayDevice::getPageFlipCount() const { void DisplayDevice::flip() const { mFlinger->getRenderEngine().checkErrors(); mPageFlipCount++; } Loading Loading @@ -362,71 +356,9 @@ status_t DisplayDevice::prepareFrame(HWComposer& hwc, return mDisplaySurface->prepareFrame(compositionType); } sp<GraphicBuffer> DisplayDevice::dequeueBuffer() { int fd; ANativeWindowBuffer* buffer; status_t res = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buffer, &fd); if (res != NO_ERROR) { ALOGE("ANativeWindow::dequeueBuffer failed for display [%s] with error: %d", getDisplayName().c_str(), res); // Return fast here as we can't do much more - any rendering we do // now will just be wrong. return mGraphicBuffer; } ALOGW_IF(mGraphicBuffer != nullptr, "Clobbering a non-null pointer to a buffer [%p].", mGraphicBuffer->getNativeBuffer()->handle); mGraphicBuffer = GraphicBuffer::from(buffer); // Block until the buffer is ready // TODO(alecmouri): it's perhaps more appropriate to block renderengine so // that the gl driver can block instead. if (fd >= 0) { sync_wait(fd, -1); close(fd); } return mGraphicBuffer; } void DisplayDevice::queueBuffer(HWComposer& hwc) { void DisplayDevice::swapBuffers(HWComposer& hwc) const { if (hwc.hasClientComposition(mId) || hwc.hasFlipClientTargetRequest(mId)) { // hasFlipClientTargetRequest could return true even if we haven't // dequeued a buffer before. Try dequeueing one if we don't have a // buffer ready. if (mGraphicBuffer == nullptr) { ALOGI("Attempting to queue a client composited buffer without one " "previously dequeued for display [%s]. Attempting to dequeue " "a scratch buffer now", mDisplayName.c_str()); // We shouldn't deadlock here, since mGraphicBuffer == nullptr only // after a successful call to queueBuffer, or if dequeueBuffer has // never been called. dequeueBuffer(); } if (mGraphicBuffer == nullptr) { ALOGE("No buffer is ready for display [%s]", mDisplayName.c_str()); } else { int fd = mBufferReady.release(); status_t res = mNativeWindow->queueBuffer(mNativeWindow.get(), mGraphicBuffer->getNativeBuffer(), fd); if (res != NO_ERROR) { ALOGE("Error when queueing buffer for display [%s]: %d", mDisplayName.c_str(), res); // We risk blocking on dequeueBuffer if the primary display failed // to queue up its buffer, so crash here. if (isPrimary()) { LOG_ALWAYS_FATAL("ANativeWindow::queueBuffer failed with error: %d", res); } else { mNativeWindow->cancelBuffer(mNativeWindow.get(), mGraphicBuffer->getNativeBuffer(), fd); } } mGraphicBuffer = nullptr; } mSurface->swapBuffers(); } status_t result = mDisplaySurface->advanceFrame(); Loading @@ -435,7 +367,7 @@ void DisplayDevice::queueBuffer(HWComposer& hwc) { } } void DisplayDevice::onPresentDisplayCompleted() { void DisplayDevice::onSwapBuffersCompleted() const { mDisplaySurface->onFrameCommitted(); } Loading @@ -452,13 +384,6 @@ void DisplayDevice::setViewportAndProjection() const { mFlinger->getRenderEngine().setViewportAndProjection(w, h, sourceCrop, ui::Transform::ROT_0); } void DisplayDevice::finishBuffer() { mBufferReady = mFlinger->getRenderEngine().flush(); if (mBufferReady.get() < 0) { mFlinger->getRenderEngine().finish(); } } const sp<Fence>& DisplayDevice::getClientTargetAcquireFence() const { return mDisplaySurface->getClientTargetAcquireFence(); } Loading services/surfaceflinger/DisplayDevice.h +3 −17 Original line number Diff line number Diff line Loading @@ -28,14 +28,13 @@ #include <gui/LayerState.h> #include <hardware/hwcomposer_defs.h> #include <math/mat4.h> #include <renderengine/RenderEngine.h> #include <renderengine/Surface.h> #include <ui/GraphicTypes.h> #include <ui/HdrCapabilities.h> #include <ui/Region.h> #include <ui/Transform.h> #include <utils/Mutex.h> #include <utils/RefBase.h> #include <utils/Mutex.h> #include <utils/String8.h> #include <utils/Timers.h> Loading Loading @@ -147,13 +146,10 @@ public: ui::Dataspace* outDataspace, ui::ColorMode* outMode, ui::RenderIntent* outIntent) const; // Queues the drawn buffer for consumption by HWC. void queueBuffer(HWComposer& hwc); // Allocates a buffer as scratch space for GPU composition sp<GraphicBuffer> dequeueBuffer(); void swapBuffers(HWComposer& hwc) const; // called after h/w composer has completed its set() call void onPresentDisplayCompleted(); void onSwapBuffersCompleted() const; Rect getBounds() const { return Rect(mDisplayWidth, mDisplayHeight); Loading @@ -164,11 +160,6 @@ public: const std::string& getDisplayName() const { return mDisplayName; } bool makeCurrent() const; // Acquires a new buffer for GPU composition. void readyNewBuffer(); // Marks the current buffer has finished, so that it can be presented and // swapped out. void finishBuffer(); void setViewportAndProjection() const; const sp<Fence>& getClientTargetAcquireFence() const; Loading Loading @@ -213,12 +204,7 @@ private: // ANativeWindow this display is rendering into sp<ANativeWindow> mNativeWindow; // Current buffer that this display can render to. sp<GraphicBuffer> mGraphicBuffer; sp<DisplaySurface> mDisplaySurface; // File descriptor indicating that mGraphicBuffer is ready for display, i.e. // that drawing to the buffer is now complete. base::unique_fd mBufferReady; std::unique_ptr<renderengine::Surface> mSurface; int mDisplayWidth; Loading Loading
libs/renderengine/gl/GLES20RenderEngine.cpp +21 −10 Original line number Diff line number Diff line Loading @@ -275,8 +275,6 @@ std::unique_ptr<GLES20RenderEngine> GLES20RenderEngine::create(int hwcFormat, // now figure out what version of GL did we actually get // NOTE: a dummy surface is not needed if KHR_create_context is supported // TODO(alecmouri): don't create this surface if EGL_KHR_surfaceless_context // is supported. EGLConfig dummyConfig = config; if (dummyConfig == EGL_NO_CONFIG) { Loading @@ -303,10 +301,10 @@ std::unique_ptr<GLES20RenderEngine> GLES20RenderEngine::create(int hwcFormat, break; case GLES_VERSION_2_0: case GLES_VERSION_3_0: engine = std::make_unique<GLES20RenderEngine>(featureFlags, display, config, ctxt, dummy); engine = std::make_unique<GLES20RenderEngine>(featureFlags); break; } engine->setEGLHandles(display, config, ctxt); ALOGI("OpenGL ES informations:"); ALOGI("vendor : %s", extensions.getVendor()); Loading @@ -316,6 +314,9 @@ std::unique_ptr<GLES20RenderEngine> GLES20RenderEngine::create(int hwcFormat, ALOGI("GL_MAX_TEXTURE_SIZE = %zu", engine->getMaxTextureSize()); ALOGI("GL_MAX_VIEWPORT_DIMS = %zu", engine->getMaxViewportDims()); eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroySurface(display, dummy); return engine; } Loading Loading @@ -358,13 +359,11 @@ EGLConfig GLES20RenderEngine::chooseEglConfig(EGLDisplay display, int format, bo return config; } GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags, EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy) GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags) : renderengine::impl::RenderEngine(featureFlags), mEGLDisplay(display), mEGLConfig(config), mEGLContext(ctxt), mDummySurface(dummy), mEGLDisplay(EGL_NO_DISPLAY), mEGLConfig(nullptr), mEGLContext(EGL_NO_CONTEXT), mVpWidth(0), mVpHeight(0), mUseColorManagement(featureFlags & USE_COLOR_MANAGEMENT) { Loading Loading @@ -637,6 +636,12 @@ void GLES20RenderEngine::unbindFrameBuffer(Framebuffer* /* framebuffer */) { // back to main framebuffer glBindFramebuffer(GL_FRAMEBUFFER, 0); // Workaround for b/77935566 to force the EGL driver to release the // screenshot buffer setScissor(Rect::EMPTY_RECT); clearWithColor(0.0, 0.0, 0.0, 0.0); disableScissor(); } void GLES20RenderEngine::checkErrors() const { Loading Loading @@ -969,6 +974,12 @@ bool GLES20RenderEngine::needsXYZTransformMatrix() const { return (isInputHdrDataSpace || isOutputHdrDataSpace) && inputTransfer != outputTransfer; } void GLES20RenderEngine::setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt) { mEGLDisplay = display; mEGLConfig = config; mEGLContext = ctxt; } } // namespace gl } // namespace renderengine } // namespace android
libs/renderengine/gl/GLES20RenderEngine.h +2 −4 Original line number Diff line number Diff line Loading @@ -47,8 +47,7 @@ public: static std::unique_ptr<GLES20RenderEngine> create(int hwcFormat, uint32_t featureFlags); static EGLConfig chooseEglConfig(EGLDisplay display, int format, bool logConfig); GLES20RenderEngine(uint32_t featureFlags, // See RenderEngine::FeatureFlag EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy); GLES20RenderEngine(uint32_t featureFlags); // See RenderEngine::FeatureFlag ~GLES20RenderEngine() override; std::unique_ptr<Framebuffer> createFramebuffer() override; Loading Loading @@ -121,12 +120,11 @@ private: // with PQ or HLG transfer function. bool isHdrDataSpace(const ui::Dataspace dataSpace) const; bool needsXYZTransformMatrix() const; void setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt, EGLSurface dummy); void setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt); EGLDisplay mEGLDisplay; EGLConfig mEGLConfig; EGLContext mEGLContext; EGLSurface mDummySurface; GLuint mProtectedTexName; GLint mMaxViewportDims[2]; GLint mMaxTextureSize; Loading
services/surfaceflinger/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -184,7 +184,6 @@ cc_defaults { "libhidltransport", "liblayers_proto", "liblog", "libsync", "libtimestats_proto", "libutils", ], Loading
services/surfaceflinger/DisplayDevice.cpp +4 −79 Original line number Diff line number Diff line Loading @@ -35,8 +35,6 @@ #include <gui/Surface.h> #include <hardware/gralloc.h> #include <renderengine/RenderEngine.h> #include <sync/sync.h> #include <system/window.h> #include <ui/DebugUtils.h> #include <ui/DisplayInfo.h> #include <ui/PixelFormat.h> Loading Loading @@ -223,7 +221,6 @@ DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args) mDisplayToken(args.displayToken), mId(args.displayId), mNativeWindow(args.nativeWindow), mGraphicBuffer(nullptr), mDisplaySurface(args.displaySurface), mSurface{std::move(args.renderSurface)}, mDisplayInstallOrientation(args.displayInstallOrientation), Loading Loading @@ -287,10 +284,6 @@ DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args) mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance); ANativeWindow* const window = mNativeWindow.get(); int status = native_window_api_connect(mNativeWindow.get(), NATIVE_WINDOW_API_EGL); ALOGE_IF(status != NO_ERROR, "Unable to connect BQ producer: %d", status); mDisplayWidth = ANativeWindow_getWidth(window); mDisplayHeight = ANativeWindow_getHeight(window); Loading Loading @@ -328,6 +321,7 @@ uint32_t DisplayDevice::getPageFlipCount() const { void DisplayDevice::flip() const { mFlinger->getRenderEngine().checkErrors(); mPageFlipCount++; } Loading Loading @@ -362,71 +356,9 @@ status_t DisplayDevice::prepareFrame(HWComposer& hwc, return mDisplaySurface->prepareFrame(compositionType); } sp<GraphicBuffer> DisplayDevice::dequeueBuffer() { int fd; ANativeWindowBuffer* buffer; status_t res = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buffer, &fd); if (res != NO_ERROR) { ALOGE("ANativeWindow::dequeueBuffer failed for display [%s] with error: %d", getDisplayName().c_str(), res); // Return fast here as we can't do much more - any rendering we do // now will just be wrong. return mGraphicBuffer; } ALOGW_IF(mGraphicBuffer != nullptr, "Clobbering a non-null pointer to a buffer [%p].", mGraphicBuffer->getNativeBuffer()->handle); mGraphicBuffer = GraphicBuffer::from(buffer); // Block until the buffer is ready // TODO(alecmouri): it's perhaps more appropriate to block renderengine so // that the gl driver can block instead. if (fd >= 0) { sync_wait(fd, -1); close(fd); } return mGraphicBuffer; } void DisplayDevice::queueBuffer(HWComposer& hwc) { void DisplayDevice::swapBuffers(HWComposer& hwc) const { if (hwc.hasClientComposition(mId) || hwc.hasFlipClientTargetRequest(mId)) { // hasFlipClientTargetRequest could return true even if we haven't // dequeued a buffer before. Try dequeueing one if we don't have a // buffer ready. if (mGraphicBuffer == nullptr) { ALOGI("Attempting to queue a client composited buffer without one " "previously dequeued for display [%s]. Attempting to dequeue " "a scratch buffer now", mDisplayName.c_str()); // We shouldn't deadlock here, since mGraphicBuffer == nullptr only // after a successful call to queueBuffer, or if dequeueBuffer has // never been called. dequeueBuffer(); } if (mGraphicBuffer == nullptr) { ALOGE("No buffer is ready for display [%s]", mDisplayName.c_str()); } else { int fd = mBufferReady.release(); status_t res = mNativeWindow->queueBuffer(mNativeWindow.get(), mGraphicBuffer->getNativeBuffer(), fd); if (res != NO_ERROR) { ALOGE("Error when queueing buffer for display [%s]: %d", mDisplayName.c_str(), res); // We risk blocking on dequeueBuffer if the primary display failed // to queue up its buffer, so crash here. if (isPrimary()) { LOG_ALWAYS_FATAL("ANativeWindow::queueBuffer failed with error: %d", res); } else { mNativeWindow->cancelBuffer(mNativeWindow.get(), mGraphicBuffer->getNativeBuffer(), fd); } } mGraphicBuffer = nullptr; } mSurface->swapBuffers(); } status_t result = mDisplaySurface->advanceFrame(); Loading @@ -435,7 +367,7 @@ void DisplayDevice::queueBuffer(HWComposer& hwc) { } } void DisplayDevice::onPresentDisplayCompleted() { void DisplayDevice::onSwapBuffersCompleted() const { mDisplaySurface->onFrameCommitted(); } Loading @@ -452,13 +384,6 @@ void DisplayDevice::setViewportAndProjection() const { mFlinger->getRenderEngine().setViewportAndProjection(w, h, sourceCrop, ui::Transform::ROT_0); } void DisplayDevice::finishBuffer() { mBufferReady = mFlinger->getRenderEngine().flush(); if (mBufferReady.get() < 0) { mFlinger->getRenderEngine().finish(); } } const sp<Fence>& DisplayDevice::getClientTargetAcquireFence() const { return mDisplaySurface->getClientTargetAcquireFence(); } Loading
services/surfaceflinger/DisplayDevice.h +3 −17 Original line number Diff line number Diff line Loading @@ -28,14 +28,13 @@ #include <gui/LayerState.h> #include <hardware/hwcomposer_defs.h> #include <math/mat4.h> #include <renderengine/RenderEngine.h> #include <renderengine/Surface.h> #include <ui/GraphicTypes.h> #include <ui/HdrCapabilities.h> #include <ui/Region.h> #include <ui/Transform.h> #include <utils/Mutex.h> #include <utils/RefBase.h> #include <utils/Mutex.h> #include <utils/String8.h> #include <utils/Timers.h> Loading Loading @@ -147,13 +146,10 @@ public: ui::Dataspace* outDataspace, ui::ColorMode* outMode, ui::RenderIntent* outIntent) const; // Queues the drawn buffer for consumption by HWC. void queueBuffer(HWComposer& hwc); // Allocates a buffer as scratch space for GPU composition sp<GraphicBuffer> dequeueBuffer(); void swapBuffers(HWComposer& hwc) const; // called after h/w composer has completed its set() call void onPresentDisplayCompleted(); void onSwapBuffersCompleted() const; Rect getBounds() const { return Rect(mDisplayWidth, mDisplayHeight); Loading @@ -164,11 +160,6 @@ public: const std::string& getDisplayName() const { return mDisplayName; } bool makeCurrent() const; // Acquires a new buffer for GPU composition. void readyNewBuffer(); // Marks the current buffer has finished, so that it can be presented and // swapped out. void finishBuffer(); void setViewportAndProjection() const; const sp<Fence>& getClientTargetAcquireFence() const; Loading Loading @@ -213,12 +204,7 @@ private: // ANativeWindow this display is rendering into sp<ANativeWindow> mNativeWindow; // Current buffer that this display can render to. sp<GraphicBuffer> mGraphicBuffer; sp<DisplaySurface> mDisplaySurface; // File descriptor indicating that mGraphicBuffer is ready for display, i.e. // that drawing to the buffer is now complete. base::unique_fd mBufferReady; std::unique_ptr<renderengine::Surface> mSurface; int mDisplayWidth; Loading