diff options
| author | 2013-02-27 14:03:19 -0800 | |
|---|---|---|
| committer | 2013-02-27 14:03:19 -0800 | |
| commit | 6c5b9be7450903762f676522c32d65f7545730df (patch) | |
| tree | 4f0930eca0d1481506628100dbc3def1bdf24c45 /libs/hwui/LayerRenderer.cpp | |
| parent | be1a8cda3e8113d1fd3a6e56d8bc6c4f2d350423 (diff) | |
Fix T-junctions in layers' generated meshes
bug:4128442
Currently we fix T-junctions for hardware layers, and for
Canvas.saveLayer if the transform isn't rectAsRect. Ideally, hardware
layers should lazily re-generate T-junction free geometry if the
transform becomes non-rectAsRect
Depends on frameworks/native change:
https://googleplex-android-review.googlesource.com/#/c/277668/
which adds Region::createTJunctionFreeRegion()
Change-Id: Ice75b4a1a4459ff835059ea81d70f7d1563fd96d
Diffstat (limited to 'libs/hwui/LayerRenderer.cpp')
| -rw-r--r-- | libs/hwui/LayerRenderer.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index bc660cd8c2a9..14c7c39b39e3 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -123,13 +123,9 @@ Region* LayerRenderer::getRegion() { return &mLayer->region; } -// TODO: This implementation is flawed and can generate T-junctions -// in the mesh, which will in turn produce cracks when the -// mesh is rotated/skewed. The easiest way to fix this would -// be, for each row, to add new vertices shared with the previous -// row when the two rows share an edge. -// In practice, T-junctions do not appear often so this has yet -// to be fixed. +// TODO: This implementation uses a very simple approach to fixing T-junctions which keeps the +// results as rectangles, and is thus not necessarily efficient in the geometry +// produced. Eventually, it may be better to develop triangle-based mechanism. void LayerRenderer::generateMesh() { if (mLayer->region.isRect() || mLayer->region.isEmpty()) { if (mLayer->mesh) { @@ -145,8 +141,14 @@ void LayerRenderer::generateMesh() { return; } + // avoid T-junctions as they cause artifacts in between the resultant + // geometry when complex transforms occur. + // TODO: generate the safeRegion only if necessary based on drawing transform (see + // OpenGLRenderer::composeLayerRegion()) + Region safeRegion = Region::createTJunctionFreeRegion(mLayer->region); + size_t count; - const android::Rect* rects = mLayer->region.getArray(&count); + const android::Rect* rects = safeRegion.getArray(&count); GLsizei elementCount = count * 6; |