Fix a crash on stroking empty paths with nv_path_rendering enabled
Fix the crash by defining that GrPathRenderer::drawPath and
GrPathRenderer::stencilPath are called only with non-empty paths.
Adds a new test "GpuDrawPath" and tests the condition.
BUG=1477
R=bsalomon@google.com
Author: kkinnunen@nvidia.com
Review URL: https://chromiumcodereview.appspot.com/22173002
git-svn-id: http://skia.googlecode.com/svn/trunk@10528 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 0d98ecd..20c633d 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -25,6 +25,7 @@
#include "GrStencilBuffer.h"
#include "GrTextStrike.h"
#include "SkRTConf.h"
+#include "SkRRect.h"
#include "SkStrokeRec.h"
#include "SkTLazy.h"
#include "SkTLS.h"
@@ -952,6 +953,9 @@
void GrContext::drawRRect(const GrPaint& paint,
const SkRRect& rect,
const SkStrokeRec& stroke) {
+ if (rect.isEmpty()) {
+ return;
+ }
AutoRestoreEffects are;
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are);
@@ -972,6 +976,9 @@
void GrContext::drawOval(const GrPaint& paint,
const SkRect& oval,
const SkStrokeRec& stroke) {
+ if (oval.isEmpty()) {
+ return;
+ }
AutoRestoreEffects are;
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are);
@@ -1082,6 +1089,7 @@
void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path,
const SkStrokeRec& stroke) {
+ SkASSERT(!path.isEmpty());
// An Assumption here is that path renderer would use some form of tweaking
// the src color (either the input alpha or in the frag shader) to implement
@@ -1112,6 +1120,10 @@
strokeRec.setFillStyle();
}
}
+ if (pathPtr->isEmpty()) {
+ return;
+ }
+
// This time, allow SW renderer
pr = this->getPathRenderer(*pathPtr, strokeRec, target, true, type);
}