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

Commit 60ac446e authored by Michael Lentine's avatar Michael Lentine Committed by Android Git Automerger
Browse files

am 47e45405: Allow for resizing of Virtual Displays.

* commit '47e45405':
  Allow for resizing of Virtual Displays.
parents 57d73004 47e45405
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ status_t DisplayState::write(Parcel& output) const {
    output.writeInt32(orientation);
    output.write(viewport);
    output.write(frame);
    output.writeInt32(width);
    output.writeInt32(height);
    return NO_ERROR;
}

@@ -92,6 +94,8 @@ status_t DisplayState::read(const Parcel& input) {
    orientation = input.readInt32();
    input.read(viewport);
    input.read(frame);
    width = input.readInt32();
    height = input.readInt32();
    return NO_ERROR;
}

+17 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ DisplayDevice::DisplayDevice(
    if (mType >= DisplayDevice::DISPLAY_VIRTUAL)
        window->setSwapInterval(window, 0);

    mConfig = config;
    mDisplay = display;
    mSurface = surface;
    mFormat  = format;
@@ -397,6 +398,22 @@ status_t DisplayDevice::orientationToTransfrom(
    return NO_ERROR;
}

void DisplayDevice::setDisplaySize(const int newWidth, const int newHeight) {
    dirtyRegion.set(getBounds());

    mDisplaySurface->resizeBuffers(newWidth, newHeight);

    ANativeWindow* const window = mNativeWindow.get();
    mSurface = eglCreateWindowSurface(mDisplay, mConfig, window, NULL);
    eglQuerySurface(mDisplay, mSurface, EGL_WIDTH,  &mDisplayWidth);
    eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mDisplayHeight);

    LOG_FATAL_IF(mDisplayWidth != newWidth,
                "Unable to set new width to %d", newWidth);
    LOG_FATAL_IF(mDisplayHeight != newHeight,
                "Unable to set new height to %d", newHeight);
}

void DisplayDevice::setProjection(int orientation,
        const Rect& newViewport, const Rect& newFrame) {
    Rect viewport(newViewport);
+2 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public:
    Region                  getDirtyRegion(bool repaintEverything) const;

    void                    setLayerStack(uint32_t stack);
    void                    setDisplaySize(const int newWidth, const int newHeight);
    void                    setProjection(int orientation, const Rect& viewport, const Rect& frame);

    int                     getOrientation() const { return mOrientation; }
@@ -181,6 +182,7 @@ private:
    sp<ANativeWindow> mNativeWindow;
    sp<DisplaySurface> mDisplaySurface;

    EGLConfig       mConfig;
    EGLDisplay      mDisplay;
    EGLSurface      mSurface;
    int             mDisplayWidth;
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ public:

    virtual void dump(String8& result) const = 0;

    virtual void resizeBuffers(const uint32_t w, const uint32_t h) = 0;

protected:
    DisplaySurface() {}
    virtual ~DisplaySurface() {}
+4 −0
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@ public:
    // has a non-virtual dump() with the same signature.
    virtual void dump(String8& result) const;

    // Cannot resize a buffers in a FramebufferSurface. Only works with virtual
    // displays.
    virtual void resizeBuffers(const uint32_t /*w*/, const uint32_t /*h*/) { };

private:
    virtual ~FramebufferSurface() { }; // this class cannot be overloaded

Loading