blob: f23f5ef8dcee4d5864f9dc1646eccd7340fb1633 [file] [log] [blame]
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +00001/*
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
halcanary96fcdcc2015-08-27 07:41:13 -07008#include "SkTypes.h"
9
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000010#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.org19dd0172013-08-05 13:28:55 +000017#include "SkPaint.h"
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000018#include "SkRRect.h"
tfarina@chromium.org8f6884a2014-01-24 20:56:26 +000019#include "SkRect.h"
reed69f6f002014-09-18 06:09:44 -070020#include "SkSurface.h"
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000021#include "Test.h"
22
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000023static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000024 // 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.org4ee16bf2014-01-10 22:08:27 +000046DEF_GPUTEST(GpuDrawPath, reporter, factory) {
jvanverth@google.com2f683ba2013-08-05 14:50:31 +000047 return;
48
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000049 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
50 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
51
52 GrContext* grContext = factory->get(glType);
halcanary96fcdcc2015-08-27 07:41:13 -070053 if (nullptr == grContext) {
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000054 continue;
55 }
56 static const int sampleCounts[] = { 0, 4, 16 };
57
58 for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
reed69f6f002014-09-18 06:09:44 -070059 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
60
bsalomonafe30052015-01-16 07:32:33 -080061 SkAutoTUnref<SkSurface> surface(
62 SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, info,
halcanary96fcdcc2015-08-27 07:41:13 -070063 sampleCounts[i], nullptr));
reed69f6f002014-09-18 06:09:44 -070064 test_drawPathEmpty(reporter, surface->getCanvas());
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000065 }
66 }
67}
68
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000069#endif