Skip to content

Commit bf09ffb

Browse files
committed
Quick reject empty paths
bug:7260035 Adding a circle of radius 0 to a path is a no-op in skia, so detect this case both in the PathRenderer, and in quickReject(). Change-Id: I7a172db49a5d5351b4734b39d4e4ca6379658096
1 parent bfbf6e1 commit bf09ffb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

libs/hwui/OpenGLRenderer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ bool OpenGLRenderer::quickRejectPreStroke(float left, float top, float right, fl
12651265
}
12661266

12671267
bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) {
1268-
if (mSnapshot->isIgnored()) {
1268+
if (mSnapshot->isIgnored() || bottom <= top || right <= left) {
12691269
return true;
12701270
}
12711271

@@ -1951,6 +1951,11 @@ void OpenGLRenderer::drawConvexPath(const SkPath& path, SkPaint* paint) {
19511951
// TODO: try clipping large paths to viewport
19521952
PathRenderer::convexPathVertices(path, paint, mSnapshot->transform, vertexBuffer);
19531953

1954+
if (!vertexBuffer.getSize()) {
1955+
// no vertices to draw
1956+
return;
1957+
}
1958+
19541959
setupDraw();
19551960
setupDrawNoTexture();
19561961
if (isAA) setupDrawAA();

libs/hwui/PathRenderer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ void PathRenderer::convexPathVertices(const SkPath &path, const SkPaint* paint,
323323
convexPathPerimeterVertices(path, threshInvScaleX * threshInvScaleX,
324324
threshInvScaleY * threshInvScaleY, tempVertices);
325325

326+
if (!tempVertices.size()) {
327+
// path was empty, return without allocating vertex buffer
328+
return;
329+
}
330+
326331
#if VERTEX_DEBUG
327332
for (unsigned int i = 0; i < tempVertices.size(); i++) {
328333
ALOGD("orig path: point at %f %f", tempVertices[i].position[0], tempVertices[i].position[1]);

0 commit comments

Comments
 (0)