Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Unified Diff: tests/GpuDrawPathTest.cpp

Issue 22173002: Fix a crash on stroking empty paths with nv_path_rendering enabled (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLPath.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GpuDrawPathTest.cpp
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3ec87d47773df12b801d2ebb9c79fbe28987717c
--- /dev/null
+++ b/tests/GpuDrawPathTest.cpp
@@ -0,0 +1,78 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#if SK_SUPPORT_GPU
+
+#include "GrContext.h"
+#include "GrContextFactory.h"
+#include "SkBitmap.h"
+#include "SkCanvas.h"
+#include "SkColor.h"
+#include "SkGpuDevice.h"
+#include "SkPaint.h"
+#include "SkRect.h"
+#include "SkRRect.h"
+#include "Test.h"
+
+static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas)
+{
+ // Filling an empty path should not crash.
+ SkPaint paint;
+ canvas->drawRect(SkRect(), paint);
+ canvas->drawPath(SkPath(), paint);
+ canvas->drawOval(SkRect(), paint);
+ canvas->drawRect(SkRect(), paint);
+ canvas->drawRRect(SkRRect(), paint);
+
+ // Stroking an empty path should not crash.
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setColor(SK_ColorGRAY);
+ paint.setStrokeWidth(SkIntToScalar(20));
+ paint.setStrokeJoin(SkPaint::kRound_Join);
+ canvas->drawRect(SkRect(), paint);
+ canvas->drawPath(SkPath(), paint);
+ canvas->drawOval(SkRect(), paint);
+ canvas->drawRect(SkRect(), paint);
+ canvas->drawRRect(SkRRect(), paint);
+}
+
+
+static void TestGpuDrawPath(skiatest::Reporter* reporter, GrContextFactory* factory) {
+ for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
+ GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
+
+ GrContext* grContext = factory->get(glType);
+ if (NULL == grContext) {
+ continue;
+ }
+ static const int sampleCounts[] = { 0, 4, 16 };
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
+ const int W = 255;
+ const int H = 255;
+
+ GrTextureDesc desc;
+ desc.fConfig = kSkia8888_GrPixelConfig;
+ desc.fFlags = kRenderTarget_GrTextureFlagBit;
+ desc.fWidth = W;
+ desc.fHeight = H;
+ desc.fSampleCnt = sampleCounts[i];
+ SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0));
+ SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture.get())));
+ SkCanvas drawingCanvas(device.get());
+
+ test_drawPathEmpty(reporter, &drawingCanvas);
+ }
+ }
+}
+
+#include "TestClassDef.h"
+DEFINE_GPUTESTCLASS("GpuDrawPath", TestGpuDrawPathClass, TestGpuDrawPath)
+
+#endif
« no previous file with comments | « src/gpu/gl/GrGLPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698