Snap layer bounds to pixel boundaries.

Change-Id: I272ceebf469a119f01ea9d73cdd68519afdffa99
This commit is contained in:
Romain Guy
2010-09-16 14:40:17 -07:00
parent b025b9c8b4
commit bf434114cb
2 changed files with 9 additions and 0 deletions

View File

@@ -353,6 +353,8 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> 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;

View File

@@ -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);
}