Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcb239d3 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

don't filter when capturing a screenshot unless needed

bug: 6919952
Change-Id: Ia6fbe9bc7e533a64cfdd6ef7f0cd6b9f11feb947
parent d3ee231e
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -316,11 +316,9 @@ void LayerBase::draw(const DisplayDevice& hw, const Region& clip) const
    onDraw(hw, clip);
}

void LayerBase::drawForScreenShot(const DisplayDevice& hw)
void LayerBase::draw(const DisplayDevice& hw)
{
    setFiltering(true);
    onDraw( hw, Region(hw.bounds()) );
    setFiltering(false);
}

void LayerBase::clearWithOpenGL(const DisplayDevice& hw, const Region& clip,
+4 −4
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ public:
     * to perform the actual drawing.  
     */
    virtual void draw(const DisplayDevice& hw, const Region& clip) const;
    virtual void drawForScreenShot(const DisplayDevice& hw);
    virtual void draw(const DisplayDevice& hw);
    
    /**
     * onDraw - draws the surface.
@@ -249,14 +249,14 @@ public:

    void clearWithOpenGL(const DisplayDevice& hw, const Region& clip) const;

    void setFiltering(bool filtering);
    bool getFiltering() const;

protected:
          void clearWithOpenGL(const DisplayDevice& hw, const Region& clip,
                  GLclampf r, GLclampf g, GLclampf b, GLclampf alpha) const;
          void drawWithOpenGL(const DisplayDevice& hw, const Region& clip) const;

          void setFiltering(bool filtering);
          bool getFiltering() const;

                sp<SurfaceFlinger> mFlinger;

private:
+6 −3
Original line number Diff line number Diff line
@@ -698,7 +698,7 @@ void SurfaceFlinger::handleMessageRefresh() {
            const size_t count = layers.size();
            for (size_t i=0 ; i<count ; ++i) {
                const sp<LayerBase>& layer(layers[i]);
                layer->drawForScreenShot(hw);
                layer->draw(hw);
            }

            success = eglSwapBuffers(eglGetCurrentDisplay(), externalDisplaySurface);
@@ -2026,7 +2026,7 @@ status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy,
    const size_t count = layers.size();
    for (size_t i=0 ; i<count ; ++i) {
        const sp<LayerBase>& layer(layers[i]);
        layer->drawForScreenShot(hw);
        layer->draw(hw);
    }

    hw.compositionComplete();
@@ -2544,6 +2544,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
    sw = (!sw) ? hw_w : sw;
    sh = (!sh) ? hw_h : sh;
    const size_t size = sw * sh * 4;
    const bool filtering = sw != hw_w || sh != hw_h;

    //ALOGD("screenshot: sw=%d, sh=%d, minZ=%d, maxZ=%d",
    //        sw, sh, minLayerZ, maxLayerZ);
@@ -2586,7 +2587,9 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
            if (!(flags & ISurfaceComposer::eLayerHidden)) {
                const uint32_t z = layer->drawingState().z;
                if (z >= minLayerZ && z <= maxLayerZ) {
                    layer->drawForScreenShot(hw);
                    if (filtering) layer->setFiltering(true);
                    layer->draw(hw);
                    if (filtering) layer->setFiltering(false);
                }
            }
        }