summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2013-02-27 23:47:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-02-27 23:47:55 +0000
commitd80806b305ce337283c24f14522cc58fea090b8c (patch)
tree701d3e4ea59f356c20b273c3061b6206782206b9
parent122f4051b5c4d61044ba377b4b5fa10133ab7b37 (diff)
parent6c5b9be7450903762f676522c32d65f7545730df (diff)
downloadframeworks_base-d80806b305ce337283c24f14522cc58fea090b8c.zip
frameworks_base-d80806b305ce337283c24f14522cc58fea090b8c.tar.gz
frameworks_base-d80806b305ce337283c24f14522cc58fea090b8c.tar.bz2
Merge "Fix T-junctions in layers' generated meshes" into jb-mr2-dev
-rw-r--r--libs/hwui/LayerRenderer.cpp18
-rw-r--r--libs/hwui/OpenGLRenderer.cpp9
2 files changed, 18 insertions, 9 deletions
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index bc660cd..14c7c39 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;
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 6c8f38d..d683c27 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1022,7 +1022,14 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
// information about this implementation
if (CC_LIKELY(!layer->region.isEmpty())) {
size_t count;
- const android::Rect* rects = layer->region.getArray(&count);
+ const android::Rect* rects;
+ Region safeRegion;
+ if (CC_LIKELY(hasRectToRectTransform())) {
+ rects = layer->region.getArray(&count);
+ } else {
+ safeRegion = Region::createTJunctionFreeRegion(layer->region);
+ rects = safeRegion.getArray(&count);
+ }
const float alpha = layer->getAlpha() / 255.0f;
const float texX = 1.0f / float(layer->getWidth());