Loading libs/renderengine/gl/GLESRenderEngine.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -424,6 +424,7 @@ GLESRenderEngine::GLESRenderEngine(uint32_t featureFlags, EGLDisplay display, EG mTraceGpuCompletion = true; mFlushTracer = std::make_unique<FlushTracer>(this); } mDrawingBuffer = createFramebuffer(); } GLESRenderEngine::~GLESRenderEngine() { Loading @@ -439,6 +440,10 @@ std::unique_ptr<Image> GLESRenderEngine::createImage() { return std::make_unique<GLImage>(*this); } Framebuffer* GLESRenderEngine::getFramebufferForDrawing() { return mDrawingBuffer.get(); } void GLESRenderEngine::primeCache() const { ProgramCache::getInstance().primeCache(mInProtectedContext ? mProtectedEGLContext : mEGLContext, mFeatureFlags & USE_COLOR_MANAGEMENT); Loading Loading @@ -678,6 +683,7 @@ status_t GLESRenderEngine::bindExternalTextureBuffer(uint32_t texName, sp<Graphi } void GLESRenderEngine::evictImages(const std::vector<LayerSettings>& layers) { ATRACE_CALL(); // destroy old image references that we're not going to draw with. std::unordered_set<uint64_t> bufIds; for (auto layer : layers) { Loading Loading @@ -744,6 +750,7 @@ status_t GLESRenderEngine::bindFrameBuffer(Framebuffer* framebuffer) { } void GLESRenderEngine::unbindFrameBuffer(Framebuffer* /* framebuffer */) { ATRACE_CALL(); mFboHeight = 0; // back to main framebuffer Loading libs/renderengine/gl/GLESRenderEngine.h +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ public: EGLConfig getEGLConfig() const { return mEGLConfig; } protected: Framebuffer* getFramebufferForDrawing() override; void dump(std::string& result) override; void setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop, ui::Transform::orientation_flags rotation) override; Loading Loading @@ -191,6 +192,8 @@ private: // more complicated interface. std::unordered_map<uint64_t, std::unique_ptr<Image>> mImageCache; std::unique_ptr<Framebuffer> mDrawingBuffer; class FlushTracer { public: FlushTracer(GLESRenderEngine* engine); Loading libs/renderengine/include/renderengine/RenderEngine.h +12 −12 Original line number Diff line number Diff line Loading @@ -174,37 +174,37 @@ public: // fence. // @return An error code indicating whether drawing was successful. For // now, this always returns NO_ERROR. // TODO(alecmouri): Consider making this a multi-display API, so that the // caller deoes not need to handle multiple fences. virtual status_t drawLayers(const DisplaySettings& display, const std::vector<LayerSettings>& layers, ANativeWindowBuffer* buffer, base::unique_fd* drawFence) = 0; // TODO(alecmouri): Expose something like bindTexImage() so that devices // that don't support native sync fences can get rid of code duplicated // between BufferStateLayer and BufferQueueLayer for binding an external // texture. // TODO(alecmouri): Add API to help with managing a texture pool. protected: // Gets a framebuffer to render to. This framebuffer may or may not be // cached depending on the implementation. // // Note that this method does not transfer ownership, so the caller most not // live longer than RenderEngine. virtual Framebuffer* getFramebufferForDrawing() = 0; friend class BindNativeBufferAsFramebuffer; }; class BindNativeBufferAsFramebuffer { public: BindNativeBufferAsFramebuffer(RenderEngine& engine, ANativeWindowBuffer* buffer) : mEngine(engine), mFramebuffer(mEngine.createFramebuffer()), mStatus(NO_ERROR) { : mEngine(engine), mFramebuffer(mEngine.getFramebufferForDrawing()), mStatus(NO_ERROR) { mStatus = mFramebuffer->setNativeWindowBuffer(buffer, mEngine.isProtected()) ? mEngine.bindFrameBuffer(mFramebuffer.get()) ? mEngine.bindFrameBuffer(mFramebuffer) : NO_MEMORY; } ~BindNativeBufferAsFramebuffer() { mFramebuffer->setNativeWindowBuffer(nullptr, false); mEngine.unbindFrameBuffer(mFramebuffer.get()); mEngine.unbindFrameBuffer(mFramebuffer); } status_t getStatus() const { return mStatus; } private: RenderEngine& mEngine; std::unique_ptr<Framebuffer> mFramebuffer; Framebuffer* mFramebuffer; status_t mStatus; }; Loading libs/renderengine/include/renderengine/mock/RenderEngine.h +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ public: MOCK_METHOD0(createFramebuffer, std::unique_ptr<renderengine::Framebuffer>()); MOCK_METHOD0(createImage, std::unique_ptr<renderengine::Image>()); MOCK_METHOD0(getFramebufferForDrawing, Framebuffer*()); MOCK_CONST_METHOD0(primeCache, void()); MOCK_METHOD1(dump, void(std::string&)); MOCK_CONST_METHOD0(useNativeFenceSync, bool()); Loading services/surfaceflinger/SurfaceFlinger.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -3328,7 +3328,6 @@ void SurfaceFlinger::invalidateHwcGeometry() void SurfaceFlinger::doDisplayComposition(const sp<DisplayDevice>& displayDevice, const Region& inDirtyRegion) { auto display = displayDevice->getCompositionDisplay(); // We only need to actually compose the display if: // 1) It is being handled by hardware composer, which may need this to // keep its virtual display state machine in sync, or Loading @@ -3348,6 +3347,7 @@ void SurfaceFlinger::doDisplayComposition(const sp<DisplayDevice>& displayDevice bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& displayDevice, const Region& debugRegion, base::unique_fd* readyFence) { ATRACE_CALL(); ALOGV("doComposeSurfaces"); auto display = displayDevice->getCompositionDisplay(); Loading Loading @@ -3474,6 +3474,7 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& displayDevice, firstLayer = false; } // Perform some cleanup steps if we used client composition. if (hasClientComposition) { clientCompositionDisplay.clearRegion = clearRegion; if (!debugRegion.isEmpty()) { Loading Loading
libs/renderengine/gl/GLESRenderEngine.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -424,6 +424,7 @@ GLESRenderEngine::GLESRenderEngine(uint32_t featureFlags, EGLDisplay display, EG mTraceGpuCompletion = true; mFlushTracer = std::make_unique<FlushTracer>(this); } mDrawingBuffer = createFramebuffer(); } GLESRenderEngine::~GLESRenderEngine() { Loading @@ -439,6 +440,10 @@ std::unique_ptr<Image> GLESRenderEngine::createImage() { return std::make_unique<GLImage>(*this); } Framebuffer* GLESRenderEngine::getFramebufferForDrawing() { return mDrawingBuffer.get(); } void GLESRenderEngine::primeCache() const { ProgramCache::getInstance().primeCache(mInProtectedContext ? mProtectedEGLContext : mEGLContext, mFeatureFlags & USE_COLOR_MANAGEMENT); Loading Loading @@ -678,6 +683,7 @@ status_t GLESRenderEngine::bindExternalTextureBuffer(uint32_t texName, sp<Graphi } void GLESRenderEngine::evictImages(const std::vector<LayerSettings>& layers) { ATRACE_CALL(); // destroy old image references that we're not going to draw with. std::unordered_set<uint64_t> bufIds; for (auto layer : layers) { Loading Loading @@ -744,6 +750,7 @@ status_t GLESRenderEngine::bindFrameBuffer(Framebuffer* framebuffer) { } void GLESRenderEngine::unbindFrameBuffer(Framebuffer* /* framebuffer */) { ATRACE_CALL(); mFboHeight = 0; // back to main framebuffer Loading
libs/renderengine/gl/GLESRenderEngine.h +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ public: EGLConfig getEGLConfig() const { return mEGLConfig; } protected: Framebuffer* getFramebufferForDrawing() override; void dump(std::string& result) override; void setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop, ui::Transform::orientation_flags rotation) override; Loading Loading @@ -191,6 +192,8 @@ private: // more complicated interface. std::unordered_map<uint64_t, std::unique_ptr<Image>> mImageCache; std::unique_ptr<Framebuffer> mDrawingBuffer; class FlushTracer { public: FlushTracer(GLESRenderEngine* engine); Loading
libs/renderengine/include/renderengine/RenderEngine.h +12 −12 Original line number Diff line number Diff line Loading @@ -174,37 +174,37 @@ public: // fence. // @return An error code indicating whether drawing was successful. For // now, this always returns NO_ERROR. // TODO(alecmouri): Consider making this a multi-display API, so that the // caller deoes not need to handle multiple fences. virtual status_t drawLayers(const DisplaySettings& display, const std::vector<LayerSettings>& layers, ANativeWindowBuffer* buffer, base::unique_fd* drawFence) = 0; // TODO(alecmouri): Expose something like bindTexImage() so that devices // that don't support native sync fences can get rid of code duplicated // between BufferStateLayer and BufferQueueLayer for binding an external // texture. // TODO(alecmouri): Add API to help with managing a texture pool. protected: // Gets a framebuffer to render to. This framebuffer may or may not be // cached depending on the implementation. // // Note that this method does not transfer ownership, so the caller most not // live longer than RenderEngine. virtual Framebuffer* getFramebufferForDrawing() = 0; friend class BindNativeBufferAsFramebuffer; }; class BindNativeBufferAsFramebuffer { public: BindNativeBufferAsFramebuffer(RenderEngine& engine, ANativeWindowBuffer* buffer) : mEngine(engine), mFramebuffer(mEngine.createFramebuffer()), mStatus(NO_ERROR) { : mEngine(engine), mFramebuffer(mEngine.getFramebufferForDrawing()), mStatus(NO_ERROR) { mStatus = mFramebuffer->setNativeWindowBuffer(buffer, mEngine.isProtected()) ? mEngine.bindFrameBuffer(mFramebuffer.get()) ? mEngine.bindFrameBuffer(mFramebuffer) : NO_MEMORY; } ~BindNativeBufferAsFramebuffer() { mFramebuffer->setNativeWindowBuffer(nullptr, false); mEngine.unbindFrameBuffer(mFramebuffer.get()); mEngine.unbindFrameBuffer(mFramebuffer); } status_t getStatus() const { return mStatus; } private: RenderEngine& mEngine; std::unique_ptr<Framebuffer> mFramebuffer; Framebuffer* mFramebuffer; status_t mStatus; }; Loading
libs/renderengine/include/renderengine/mock/RenderEngine.h +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ public: MOCK_METHOD0(createFramebuffer, std::unique_ptr<renderengine::Framebuffer>()); MOCK_METHOD0(createImage, std::unique_ptr<renderengine::Image>()); MOCK_METHOD0(getFramebufferForDrawing, Framebuffer*()); MOCK_CONST_METHOD0(primeCache, void()); MOCK_METHOD1(dump, void(std::string&)); MOCK_CONST_METHOD0(useNativeFenceSync, bool()); Loading
services/surfaceflinger/SurfaceFlinger.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -3328,7 +3328,6 @@ void SurfaceFlinger::invalidateHwcGeometry() void SurfaceFlinger::doDisplayComposition(const sp<DisplayDevice>& displayDevice, const Region& inDirtyRegion) { auto display = displayDevice->getCompositionDisplay(); // We only need to actually compose the display if: // 1) It is being handled by hardware composer, which may need this to // keep its virtual display state machine in sync, or Loading @@ -3348,6 +3347,7 @@ void SurfaceFlinger::doDisplayComposition(const sp<DisplayDevice>& displayDevice bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& displayDevice, const Region& debugRegion, base::unique_fd* readyFence) { ATRACE_CALL(); ALOGV("doComposeSurfaces"); auto display = displayDevice->getCompositionDisplay(); Loading Loading @@ -3474,6 +3474,7 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& displayDevice, firstLayer = false; } // Perform some cleanup steps if we used client composition. if (hasClientComposition) { clientCompositionDisplay.clearRegion = clearRegion; if (!debugRegion.isEmpty()) { Loading