Loading services/surfaceflinger/BufferLayer.cpp +9 −12 Original line number Diff line number Diff line Loading @@ -624,19 +624,16 @@ void BufferLayer::drawWithOpenGL(const RenderArea& renderArea, bool useIdentityT * minimal value)? Or, we could make GL behave like HWC -- but this feel * like more of a hack. */ const Rect bounds{computeBounds()}; // Rounds from FloatRect // Convert to Rect so that bounds are clipped to integers. const Rect win{computeCrop(Rect::INVALID_RECT)}; // computeCrop() returns the cropping rectangle in buffer space, so we // shouldn't use getBufferSize() since that may return a rectangle specified // in layer space. Otherwise we may compute incorrect texture coordinates. const float bufWidth = float(mActiveBuffer->getWidth()); const float bufHeight = float(mActiveBuffer->getHeight()); const float left = win.left / bufWidth; const float top = win.top / bufHeight; const float right = win.right / bufWidth; const float bottom = win.bottom / bufHeight; Rect win = bounds; const int bufferWidth = getBufferSize(s).getWidth(); const int bufferHeight = getBufferSize(s).getHeight(); const float left = float(win.left) / float(bufferWidth); const float top = float(win.top) / float(bufferHeight); const float right = float(win.right) / float(bufferWidth); const float bottom = float(win.bottom) / float(bufferHeight); // TODO: we probably want to generate the texture coords with the mesh // here we assume that we only have 4 vertices Loading services/surfaceflinger/ColorLayer.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: bool onPreComposition(nsecs_t /*refreshStartTime*/) override { return false; } protected: FloatRect computeCrop(const Rect& /*windowbounds*/) const override { return {}; } FloatRect computeCrop(const sp<const DisplayDevice>& /*display*/) const override { return {}; } }; } // namespace android services/surfaceflinger/Layer.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -381,7 +381,7 @@ Rect Layer::getCroppedBufferSize(const State& s) const { return size; } Rect Layer::computeInitialCrop(const Rect& windowBounds) const { Rect Layer::computeInitialCrop(const sp<const DisplayDevice>& display) const { // the crop is the area of the window that gets cropped, but not // scaled in any ways. const State& s(getDrawingState()); Loading @@ -392,17 +392,12 @@ Rect Layer::computeInitialCrop(const Rect& windowBounds) const { // pixels in the buffer. FloatRect activeCropFloat = computeBounds(); // If we have valid window boundaries then we need to crop to the window // boundaries in layer space. if (windowBounds.isValid()) { const ui::Transform t = getTransform(); ui::Transform t = getTransform(); // Transform to screen space. activeCropFloat = t.transform(activeCropFloat); activeCropFloat = activeCropFloat.intersect(windowBounds.toFloatRect()); activeCropFloat = activeCropFloat.intersect(display->getViewport().toFloatRect()); // Back to layer space to work with the content crop. activeCropFloat = t.inverse().transform(activeCropFloat); } // This needs to be here as transform.transform(Rect) computes the // transformed rect and then takes the bounding box of the result before // returning. This means Loading Loading @@ -432,7 +427,7 @@ void Layer::setupRoundedCornersCropCoordinates(Rect win, cropCoords[3] = vec2(win.right, win.top); } FloatRect Layer::computeCrop(const Rect& windowBounds) const { FloatRect Layer::computeCrop(const sp<const DisplayDevice>& display) const { // the content crop is the area of the content that gets scaled to the // layer's size. This is in buffer space. FloatRect crop = getContentCrop().toFloatRect(); Loading @@ -440,7 +435,7 @@ FloatRect Layer::computeCrop(const Rect& windowBounds) const { // In addition there is a WM-specified crop we pull from our drawing state. const State& s(getDrawingState()); Rect activeCrop = computeInitialCrop(windowBounds); Rect activeCrop = computeInitialCrop(display); Rect bufferSize = getBufferSize(s); // Transform the window crop to match the buffer coordinate system, Loading services/surfaceflinger/Layer.h +2 −12 Original line number Diff line number Diff line Loading @@ -679,22 +679,12 @@ protected: uint32_t getEffectiveUsage(uint32_t usage) const; // Computes the crop applied to this layer. windowBounds is the boundary of // layer-stack space, so the cropping rectangle will be clipped to those // bounds in that space. The crop rectangle is returned in buffer space. If // windowBounds is invalid, then it is ignored. virtual FloatRect computeCrop(const Rect& windowBounds) const; // See the above method, but pulls the window boundaries from the display. FloatRect computeCrop(const sp<const DisplayDevice>& display) const { return computeCrop(display->getViewport()); } virtual FloatRect computeCrop(const sp<const DisplayDevice>& display) const; // Compute the initial crop as specified by parent layers and the // SurfaceControl for this layer. Does not include buffer crop from the // IGraphicBufferProducer client, as that should not affect child clipping. // Returns in screen space. Rect computeInitialCrop(const Rect& windowBounds) const; Rect computeInitialCrop(const sp<const DisplayDevice>& display) const; /** * Setup rounded corners coordinates of this layer, taking into account the layer bounds and * crop coordinates, transforming them into layer space. Loading Loading
services/surfaceflinger/BufferLayer.cpp +9 −12 Original line number Diff line number Diff line Loading @@ -624,19 +624,16 @@ void BufferLayer::drawWithOpenGL(const RenderArea& renderArea, bool useIdentityT * minimal value)? Or, we could make GL behave like HWC -- but this feel * like more of a hack. */ const Rect bounds{computeBounds()}; // Rounds from FloatRect // Convert to Rect so that bounds are clipped to integers. const Rect win{computeCrop(Rect::INVALID_RECT)}; // computeCrop() returns the cropping rectangle in buffer space, so we // shouldn't use getBufferSize() since that may return a rectangle specified // in layer space. Otherwise we may compute incorrect texture coordinates. const float bufWidth = float(mActiveBuffer->getWidth()); const float bufHeight = float(mActiveBuffer->getHeight()); const float left = win.left / bufWidth; const float top = win.top / bufHeight; const float right = win.right / bufWidth; const float bottom = win.bottom / bufHeight; Rect win = bounds; const int bufferWidth = getBufferSize(s).getWidth(); const int bufferHeight = getBufferSize(s).getHeight(); const float left = float(win.left) / float(bufferWidth); const float top = float(win.top) / float(bufferHeight); const float right = float(win.right) / float(bufferWidth); const float bottom = float(win.bottom) / float(bufferHeight); // TODO: we probably want to generate the texture coords with the mesh // here we assume that we only have 4 vertices Loading
services/surfaceflinger/ColorLayer.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: bool onPreComposition(nsecs_t /*refreshStartTime*/) override { return false; } protected: FloatRect computeCrop(const Rect& /*windowbounds*/) const override { return {}; } FloatRect computeCrop(const sp<const DisplayDevice>& /*display*/) const override { return {}; } }; } // namespace android
services/surfaceflinger/Layer.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -381,7 +381,7 @@ Rect Layer::getCroppedBufferSize(const State& s) const { return size; } Rect Layer::computeInitialCrop(const Rect& windowBounds) const { Rect Layer::computeInitialCrop(const sp<const DisplayDevice>& display) const { // the crop is the area of the window that gets cropped, but not // scaled in any ways. const State& s(getDrawingState()); Loading @@ -392,17 +392,12 @@ Rect Layer::computeInitialCrop(const Rect& windowBounds) const { // pixels in the buffer. FloatRect activeCropFloat = computeBounds(); // If we have valid window boundaries then we need to crop to the window // boundaries in layer space. if (windowBounds.isValid()) { const ui::Transform t = getTransform(); ui::Transform t = getTransform(); // Transform to screen space. activeCropFloat = t.transform(activeCropFloat); activeCropFloat = activeCropFloat.intersect(windowBounds.toFloatRect()); activeCropFloat = activeCropFloat.intersect(display->getViewport().toFloatRect()); // Back to layer space to work with the content crop. activeCropFloat = t.inverse().transform(activeCropFloat); } // This needs to be here as transform.transform(Rect) computes the // transformed rect and then takes the bounding box of the result before // returning. This means Loading Loading @@ -432,7 +427,7 @@ void Layer::setupRoundedCornersCropCoordinates(Rect win, cropCoords[3] = vec2(win.right, win.top); } FloatRect Layer::computeCrop(const Rect& windowBounds) const { FloatRect Layer::computeCrop(const sp<const DisplayDevice>& display) const { // the content crop is the area of the content that gets scaled to the // layer's size. This is in buffer space. FloatRect crop = getContentCrop().toFloatRect(); Loading @@ -440,7 +435,7 @@ FloatRect Layer::computeCrop(const Rect& windowBounds) const { // In addition there is a WM-specified crop we pull from our drawing state. const State& s(getDrawingState()); Rect activeCrop = computeInitialCrop(windowBounds); Rect activeCrop = computeInitialCrop(display); Rect bufferSize = getBufferSize(s); // Transform the window crop to match the buffer coordinate system, Loading
services/surfaceflinger/Layer.h +2 −12 Original line number Diff line number Diff line Loading @@ -679,22 +679,12 @@ protected: uint32_t getEffectiveUsage(uint32_t usage) const; // Computes the crop applied to this layer. windowBounds is the boundary of // layer-stack space, so the cropping rectangle will be clipped to those // bounds in that space. The crop rectangle is returned in buffer space. If // windowBounds is invalid, then it is ignored. virtual FloatRect computeCrop(const Rect& windowBounds) const; // See the above method, but pulls the window boundaries from the display. FloatRect computeCrop(const sp<const DisplayDevice>& display) const { return computeCrop(display->getViewport()); } virtual FloatRect computeCrop(const sp<const DisplayDevice>& display) const; // Compute the initial crop as specified by parent layers and the // SurfaceControl for this layer. Does not include buffer crop from the // IGraphicBufferProducer client, as that should not affect child clipping. // Returns in screen space. Rect computeInitialCrop(const Rect& windowBounds) const; Rect computeInitialCrop(const sp<const DisplayDevice>& display) const; /** * Setup rounded corners coordinates of this layer, taking into account the layer bounds and * crop coordinates, transforming them into layer space. Loading