Loading libs/hwui/ClipArea.cpp +4 −16 Original line number Diff line number Diff line Loading @@ -23,14 +23,6 @@ namespace android { namespace uirenderer { static bool intersect(Rect& r, const Rect& r2) { bool hasIntersection = r.intersect(r2); if (!hasIntersection) { r.setEmpty(); } return hasIntersection; } static void handlePoint(Rect& transformedBounds, const Matrix4& transform, float x, float y) { Vertex v = {x, y}; transform.mapPoint(v.x, v.y); Loading Loading @@ -67,9 +59,8 @@ bool TransformedRectangle::canSimplyIntersectWith( return mTransform == other.mTransform; } bool TransformedRectangle::intersectWith(const TransformedRectangle& other) { Rect translatedBounds(other.mBounds); return intersect(mBounds, translatedBounds); void TransformedRectangle::intersectWith(const TransformedRectangle& other) { mBounds.doIntersect(other.mBounds); } bool TransformedRectangle::isEmpty() const { Loading Loading @@ -146,7 +137,7 @@ Rect RectangleList::calculateBounds() const { if (index == 0) { bounds = tr.transformedBounds(); } else { bounds.intersect(tr.transformedBounds()); bounds.doIntersect(tr.transformedBounds()); } } return bounds; Loading Loading @@ -275,10 +266,7 @@ void ClipArea::rectangleModeClipRectWithTransform(const Rect& r, if (transform->rectToRect()) { Rect transformed(r); transform->mapRect(transformed); bool hasIntersection = mClipRect.intersect(transformed); if (!hasIntersection) { mClipRect.setEmpty(); } mClipRect.doIntersect(transformed); return; } Loading libs/hwui/ClipArea.h +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public: TransformedRectangle(const Rect& bounds, const Matrix4& transform); bool canSimplyIntersectWith(const TransformedRectangle& other) const; bool intersectWith(const TransformedRectangle& other); void intersectWith(const TransformedRectangle& other); bool isEmpty() const; Loading libs/hwui/LayerRenderer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ void LayerRenderer::prepareDirty(int viewportWidth, int viewportHeight, mLayer->region.clear(); dirty.set(0.0f, 0.0f, width, height); } else { dirty.intersect(0.0f, 0.0f, width, height); dirty.doIntersect(0.0f, 0.0f, width, height); android::Rect r(dirty.left, dirty.top, dirty.right, dirty.bottom); mLayer->region.subtractSelf(r); } Loading libs/hwui/OpenGLRenderer.cpp +13 −14 Original line number Diff line number Diff line Loading @@ -488,7 +488,8 @@ void OpenGLRenderer::calculateLayerBoundsAndClip(Rect& bounds, Rect& clip, bool currentTransform()->mapRect(bounds); // Layers only make sense if they are in the framebuffer's bounds if (bounds.intersect(mState.currentClipRect())) { bounds.doIntersect(mState.currentClipRect()); if (!bounds.isEmpty()) { // We cannot work with sub-pixels in this case bounds.snapToPixelBoundaries(); Loading @@ -497,23 +498,20 @@ void OpenGLRenderer::calculateLayerBoundsAndClip(Rect& bounds, Rect& clip, bool // of the framebuffer const Snapshot& previous = *(currentSnapshot()->previous); Rect previousViewport(0, 0, previous.getViewportWidth(), previous.getViewportHeight()); if (!bounds.intersect(previousViewport)) { bounds.setEmpty(); } else if (fboLayer) { bounds.doIntersect(previousViewport); if (!bounds.isEmpty() && fboLayer) { clip.set(bounds); mat4 inverse; inverse.loadInverse(*currentTransform()); inverse.mapRect(clip); clip.snapToPixelBoundaries(); if (clip.intersect(untransformedBounds)) { clip.doIntersect(untransformedBounds); if (!clip.isEmpty()) { clip.translate(-untransformedBounds.left, -untransformedBounds.top); bounds.set(untransformedBounds); } else { clip.setEmpty(); } } } else { bounds.setEmpty(); } } Loading Loading @@ -1038,7 +1036,8 @@ void OpenGLRenderer::dirtyLayer(const float left, const float top, } void OpenGLRenderer::dirtyLayerUnchecked(Rect& bounds, Region* region) { if (CC_LIKELY(!bounds.isEmpty() && bounds.intersect(mState.currentClipRect()))) { bounds.doIntersect(mState.currentClipRect()); if (!bounds.isEmpty()) { bounds.snapToPixelBoundaries(); android::Rect dirty(bounds.left, bounds.top, bounds.right, bounds.bottom); if (!dirty.isEmpty()) { Loading Loading @@ -1112,7 +1111,8 @@ bool OpenGLRenderer::storeDisplayState(DeferredDisplayState& state, int stateDef // is used, it should more closely duplicate the quickReject logic (in how it uses // snapToPixelBoundaries) if (!clippedBounds.intersect(currentClip)) { clippedBounds.doIntersect(currentClip); if (clippedBounds.isEmpty()) { // quick rejected return true; } Loading Loading @@ -1242,9 +1242,8 @@ void OpenGLRenderer::drawRectangleList(const RectangleList& rectangleList) { Rect bounds = tr.getBounds(); if (transform.rectToRect()) { transform.mapRect(bounds); if (!bounds.intersect(scissorBox)) { bounds.setEmpty(); } else { bounds.doIntersect(scissorBox); if (!bounds.isEmpty()) { handlePointNoTransform(rectangleVertices, bounds.left, bounds.top); handlePointNoTransform(rectangleVertices, bounds.right, bounds.top); handlePointNoTransform(rectangleVertices, bounds.left, bounds.bottom); Loading libs/hwui/Rect.h +18 −29 Original line number Diff line number Diff line Loading @@ -125,25 +125,32 @@ public: } bool intersects(float l, float t, float r, float b) const { return !intersectWith(l, t, r, b).isEmpty(); float tempLeft = std::max(left, l); float tempTop = std::max(top, t); float tempRight = std::min(right, r); float tempBottom = std::min(bottom, b); return ((tempLeft < tempRight) && (tempTop < tempBottom)); // !isEmpty } bool intersects(const Rect& r) const { return intersects(r.left, r.top, r.right, r.bottom); } bool intersect(float l, float t, float r, float b) { Rect tmp(l, t, r, b); intersectWith(tmp); if (!tmp.isEmpty()) { set(tmp); return true; } return false; /** * This method is named 'doIntersect' instead of 'intersect' so as not to be confused with * SkRect::intersect / android.graphics.Rect#intersect behavior, which do not modify the object * if the intersection of the rects would be empty. */ void doIntersect(float l, float t, float r, float b) { left = std::max(left, l); top = std::max(top, t); right = std::min(right, r); bottom = std::min(bottom, b); } bool intersect(const Rect& r) { return intersect(r.left, r.top, r.right, r.bottom); void doIntersect(const Rect& r) { doIntersect(r.left, r.top, r.right, r.bottom); } inline bool contains(float l, float t, float r, float b) const { Loading Loading @@ -271,24 +278,6 @@ public: void dump(const char* label = nullptr) const { ALOGD("%s[l=%f t=%f r=%f b=%f]", label ? label : "Rect", left, top, right, bottom); } private: void intersectWith(Rect& tmp) const { tmp.left = std::max(left, tmp.left); tmp.top = std::max(top, tmp.top); tmp.right = std::min(right, tmp.right); tmp.bottom = std::min(bottom, tmp.bottom); } Rect intersectWith(float l, float t, float r, float b) const { Rect tmp; tmp.left = std::max(left, l); tmp.top = std::max(top, t); tmp.right = std::min(right, r); tmp.bottom = std::min(bottom, b); return tmp; } }; // class Rect }; // namespace uirenderer Loading Loading
libs/hwui/ClipArea.cpp +4 −16 Original line number Diff line number Diff line Loading @@ -23,14 +23,6 @@ namespace android { namespace uirenderer { static bool intersect(Rect& r, const Rect& r2) { bool hasIntersection = r.intersect(r2); if (!hasIntersection) { r.setEmpty(); } return hasIntersection; } static void handlePoint(Rect& transformedBounds, const Matrix4& transform, float x, float y) { Vertex v = {x, y}; transform.mapPoint(v.x, v.y); Loading Loading @@ -67,9 +59,8 @@ bool TransformedRectangle::canSimplyIntersectWith( return mTransform == other.mTransform; } bool TransformedRectangle::intersectWith(const TransformedRectangle& other) { Rect translatedBounds(other.mBounds); return intersect(mBounds, translatedBounds); void TransformedRectangle::intersectWith(const TransformedRectangle& other) { mBounds.doIntersect(other.mBounds); } bool TransformedRectangle::isEmpty() const { Loading Loading @@ -146,7 +137,7 @@ Rect RectangleList::calculateBounds() const { if (index == 0) { bounds = tr.transformedBounds(); } else { bounds.intersect(tr.transformedBounds()); bounds.doIntersect(tr.transformedBounds()); } } return bounds; Loading Loading @@ -275,10 +266,7 @@ void ClipArea::rectangleModeClipRectWithTransform(const Rect& r, if (transform->rectToRect()) { Rect transformed(r); transform->mapRect(transformed); bool hasIntersection = mClipRect.intersect(transformed); if (!hasIntersection) { mClipRect.setEmpty(); } mClipRect.doIntersect(transformed); return; } Loading
libs/hwui/ClipArea.h +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public: TransformedRectangle(const Rect& bounds, const Matrix4& transform); bool canSimplyIntersectWith(const TransformedRectangle& other) const; bool intersectWith(const TransformedRectangle& other); void intersectWith(const TransformedRectangle& other); bool isEmpty() const; Loading
libs/hwui/LayerRenderer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ void LayerRenderer::prepareDirty(int viewportWidth, int viewportHeight, mLayer->region.clear(); dirty.set(0.0f, 0.0f, width, height); } else { dirty.intersect(0.0f, 0.0f, width, height); dirty.doIntersect(0.0f, 0.0f, width, height); android::Rect r(dirty.left, dirty.top, dirty.right, dirty.bottom); mLayer->region.subtractSelf(r); } Loading
libs/hwui/OpenGLRenderer.cpp +13 −14 Original line number Diff line number Diff line Loading @@ -488,7 +488,8 @@ void OpenGLRenderer::calculateLayerBoundsAndClip(Rect& bounds, Rect& clip, bool currentTransform()->mapRect(bounds); // Layers only make sense if they are in the framebuffer's bounds if (bounds.intersect(mState.currentClipRect())) { bounds.doIntersect(mState.currentClipRect()); if (!bounds.isEmpty()) { // We cannot work with sub-pixels in this case bounds.snapToPixelBoundaries(); Loading @@ -497,23 +498,20 @@ void OpenGLRenderer::calculateLayerBoundsAndClip(Rect& bounds, Rect& clip, bool // of the framebuffer const Snapshot& previous = *(currentSnapshot()->previous); Rect previousViewport(0, 0, previous.getViewportWidth(), previous.getViewportHeight()); if (!bounds.intersect(previousViewport)) { bounds.setEmpty(); } else if (fboLayer) { bounds.doIntersect(previousViewport); if (!bounds.isEmpty() && fboLayer) { clip.set(bounds); mat4 inverse; inverse.loadInverse(*currentTransform()); inverse.mapRect(clip); clip.snapToPixelBoundaries(); if (clip.intersect(untransformedBounds)) { clip.doIntersect(untransformedBounds); if (!clip.isEmpty()) { clip.translate(-untransformedBounds.left, -untransformedBounds.top); bounds.set(untransformedBounds); } else { clip.setEmpty(); } } } else { bounds.setEmpty(); } } Loading Loading @@ -1038,7 +1036,8 @@ void OpenGLRenderer::dirtyLayer(const float left, const float top, } void OpenGLRenderer::dirtyLayerUnchecked(Rect& bounds, Region* region) { if (CC_LIKELY(!bounds.isEmpty() && bounds.intersect(mState.currentClipRect()))) { bounds.doIntersect(mState.currentClipRect()); if (!bounds.isEmpty()) { bounds.snapToPixelBoundaries(); android::Rect dirty(bounds.left, bounds.top, bounds.right, bounds.bottom); if (!dirty.isEmpty()) { Loading Loading @@ -1112,7 +1111,8 @@ bool OpenGLRenderer::storeDisplayState(DeferredDisplayState& state, int stateDef // is used, it should more closely duplicate the quickReject logic (in how it uses // snapToPixelBoundaries) if (!clippedBounds.intersect(currentClip)) { clippedBounds.doIntersect(currentClip); if (clippedBounds.isEmpty()) { // quick rejected return true; } Loading Loading @@ -1242,9 +1242,8 @@ void OpenGLRenderer::drawRectangleList(const RectangleList& rectangleList) { Rect bounds = tr.getBounds(); if (transform.rectToRect()) { transform.mapRect(bounds); if (!bounds.intersect(scissorBox)) { bounds.setEmpty(); } else { bounds.doIntersect(scissorBox); if (!bounds.isEmpty()) { handlePointNoTransform(rectangleVertices, bounds.left, bounds.top); handlePointNoTransform(rectangleVertices, bounds.right, bounds.top); handlePointNoTransform(rectangleVertices, bounds.left, bounds.bottom); Loading
libs/hwui/Rect.h +18 −29 Original line number Diff line number Diff line Loading @@ -125,25 +125,32 @@ public: } bool intersects(float l, float t, float r, float b) const { return !intersectWith(l, t, r, b).isEmpty(); float tempLeft = std::max(left, l); float tempTop = std::max(top, t); float tempRight = std::min(right, r); float tempBottom = std::min(bottom, b); return ((tempLeft < tempRight) && (tempTop < tempBottom)); // !isEmpty } bool intersects(const Rect& r) const { return intersects(r.left, r.top, r.right, r.bottom); } bool intersect(float l, float t, float r, float b) { Rect tmp(l, t, r, b); intersectWith(tmp); if (!tmp.isEmpty()) { set(tmp); return true; } return false; /** * This method is named 'doIntersect' instead of 'intersect' so as not to be confused with * SkRect::intersect / android.graphics.Rect#intersect behavior, which do not modify the object * if the intersection of the rects would be empty. */ void doIntersect(float l, float t, float r, float b) { left = std::max(left, l); top = std::max(top, t); right = std::min(right, r); bottom = std::min(bottom, b); } bool intersect(const Rect& r) { return intersect(r.left, r.top, r.right, r.bottom); void doIntersect(const Rect& r) { doIntersect(r.left, r.top, r.right, r.bottom); } inline bool contains(float l, float t, float r, float b) const { Loading Loading @@ -271,24 +278,6 @@ public: void dump(const char* label = nullptr) const { ALOGD("%s[l=%f t=%f r=%f b=%f]", label ? label : "Rect", left, top, right, bottom); } private: void intersectWith(Rect& tmp) const { tmp.left = std::max(left, tmp.left); tmp.top = std::max(top, tmp.top); tmp.right = std::min(right, tmp.right); tmp.bottom = std::min(bottom, tmp.bottom); } Rect intersectWith(float l, float t, float r, float b) const { Rect tmp; tmp.left = std::max(left, l); tmp.top = std::max(top, t); tmp.right = std::min(right, r); tmp.bottom = std::min(bottom, b); return tmp; } }; // class Rect }; // namespace uirenderer Loading