diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 670d049956f91..d6c00534d6551 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -353,6 +353,8 @@ bool OpenGLRenderer::createLayer(sp snapshot, float left, float top, // Layers only make sense if they are in the framebuffer's bounds bounds.intersect(*mSnapshot->clipRect); + bounds.snapToPixelBoundaries(); + if (bounds.isEmpty() || bounds.getWidth() > mMaxTextureSize || bounds.getHeight() > mMaxTextureSize) { return false; diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h index 6b22c2bf02b02..5166ee94963f4 100644 --- a/libs/hwui/Rect.h +++ b/libs/hwui/Rect.h @@ -148,6 +148,13 @@ struct Rect { return false; } + void snapToPixelBoundaries() { + left = floor(left); + top = floor(top); + right = ceil(right); + bottom = ceil(bottom); + } + void dump() const { LOGD("Rect[l=%f t=%f r=%f b=%f]", left, top, right, bottom); }