2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #include "GrContext.h"
11 #include "GrContextFactory.h"
18 #include "SkSurface.h"
21 static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
22 // Filling an empty path should not crash.
24 canvas->drawRect(SkRect(), paint);
25 canvas->drawPath(SkPath(), paint);
26 canvas->drawOval(SkRect(), paint);
27 canvas->drawRect(SkRect(), paint);
28 canvas->drawRRect(SkRRect(), paint);
30 // Stroking an empty path should not crash.
31 paint.setAntiAlias(true);
32 paint.setStyle(SkPaint::kStroke_Style);
33 paint.setColor(SK_ColorGRAY);
34 paint.setStrokeWidth(SkIntToScalar(20));
35 paint.setStrokeJoin(SkPaint::kRound_Join);
36 canvas->drawRect(SkRect(), paint);
37 canvas->drawPath(SkPath(), paint);
38 canvas->drawOval(SkRect(), paint);
39 canvas->drawRect(SkRect(), paint);
40 canvas->drawRRect(SkRRect(), paint);
44 DEF_GPUTEST(GpuDrawPath, reporter, factory) {
47 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
48 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
50 GrContext* grContext = factory->get(glType);
51 if (NULL == grContext) {
54 static const int sampleCounts[] = { 0, 4, 16 };
56 for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
57 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
59 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(grContext, info,
60 sampleCounts[i], NULL));
61 test_drawPathEmpty(reporter, surface->getCanvas());