commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #if SK_SUPPORT_GPU |
| 9 | |
| 10 | #include "GrContext.h" |
| 11 | #include "GrContextFactory.h" |
| 12 | #include "SkBitmap.h" |
| 13 | #include "SkCanvas.h" |
| 14 | #include "SkColor.h" |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 15 | #include "SkPaint.h" |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 16 | #include "SkRRect.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 17 | #include "SkRect.h" |
reed | 69f6f00 | 2014-09-18 06:09:44 -0700 | [diff] [blame] | 18 | #include "SkSurface.h" |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 19 | #include "Test.h" |
| 20 | |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 21 | static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) { |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 22 | // Filling an empty path should not crash. |
| 23 | SkPaint paint; |
| 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); |
| 29 | |
| 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); |
| 41 | } |
| 42 | |
| 43 | |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 44 | DEF_GPUTEST(GpuDrawPath, reporter, factory) { |
jvanverth@google.com | 2f683ba | 2013-08-05 14:50:31 +0000 | [diff] [blame] | 45 | return; |
| 46 | |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 47 | for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
| 48 | GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type); |
| 49 | |
| 50 | GrContext* grContext = factory->get(glType); |
| 51 | if (NULL == grContext) { |
| 52 | continue; |
| 53 | } |
| 54 | static const int sampleCounts[] = { 0, 4, 16 }; |
| 55 | |
| 56 | for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) { |
reed | 69f6f00 | 2014-09-18 06:09:44 -0700 | [diff] [blame] | 57 | SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255); |
| 58 | |
bsalomon | afe3005 | 2015-01-16 07:32:33 -0800 | [diff] [blame] | 59 | SkAutoTUnref<SkSurface> surface( |
| 60 | SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, info, |
| 61 | sampleCounts[i], NULL)); |
reed | 69f6f00 | 2014-09-18 06:09:44 -0700 | [diff] [blame] | 62 | test_drawPathEmpty(reporter, surface->getCanvas()); |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 67 | #endif |