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 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame^] | 8 | #include "SkTypes.h" |
| 9 | |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 10 | #if SK_SUPPORT_GPU |
| 11 | |
| 12 | #include "GrContext.h" |
| 13 | #include "GrContextFactory.h" |
| 14 | #include "SkBitmap.h" |
| 15 | #include "SkCanvas.h" |
| 16 | #include "SkColor.h" |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 17 | #include "SkPaint.h" |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 18 | #include "SkRRect.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 19 | #include "SkRect.h" |
reed | 69f6f00 | 2014-09-18 06:09:44 -0700 | [diff] [blame] | 20 | #include "SkSurface.h" |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 21 | #include "Test.h" |
| 22 | |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 23 | static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) { |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 24 | // Filling an empty path should not crash. |
| 25 | SkPaint paint; |
| 26 | canvas->drawRect(SkRect(), paint); |
| 27 | canvas->drawPath(SkPath(), paint); |
| 28 | canvas->drawOval(SkRect(), paint); |
| 29 | canvas->drawRect(SkRect(), paint); |
| 30 | canvas->drawRRect(SkRRect(), paint); |
| 31 | |
| 32 | // Stroking an empty path should not crash. |
| 33 | paint.setAntiAlias(true); |
| 34 | paint.setStyle(SkPaint::kStroke_Style); |
| 35 | paint.setColor(SK_ColorGRAY); |
| 36 | paint.setStrokeWidth(SkIntToScalar(20)); |
| 37 | paint.setStrokeJoin(SkPaint::kRound_Join); |
| 38 | canvas->drawRect(SkRect(), paint); |
| 39 | canvas->drawPath(SkPath(), paint); |
| 40 | canvas->drawOval(SkRect(), paint); |
| 41 | canvas->drawRect(SkRect(), paint); |
| 42 | canvas->drawRRect(SkRRect(), paint); |
| 43 | } |
| 44 | |
| 45 | |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 46 | DEF_GPUTEST(GpuDrawPath, reporter, factory) { |
jvanverth@google.com | 2f683ba | 2013-08-05 14:50:31 +0000 | [diff] [blame] | 47 | return; |
| 48 | |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 49 | for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
| 50 | GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type); |
| 51 | |
| 52 | GrContext* grContext = factory->get(glType); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame^] | 53 | if (nullptr == grContext) { |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 54 | continue; |
| 55 | } |
| 56 | static const int sampleCounts[] = { 0, 4, 16 }; |
| 57 | |
| 58 | for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) { |
reed | 69f6f00 | 2014-09-18 06:09:44 -0700 | [diff] [blame] | 59 | SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255); |
| 60 | |
bsalomon | afe3005 | 2015-01-16 07:32:33 -0800 | [diff] [blame] | 61 | SkAutoTUnref<SkSurface> surface( |
| 62 | SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, info, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame^] | 63 | sampleCounts[i], nullptr)); |
reed | 69f6f00 | 2014-09-18 06:09:44 -0700 | [diff] [blame] | 64 | test_drawPathEmpty(reporter, surface->getCanvas()); |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
commit-bot@chromium.org | 19dd017 | 2013-08-05 13:28:55 +0000 | [diff] [blame] | 69 | #endif |