blob: 3dcba52bd93ea364eea9b56ce5efc8165b4042e2 [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
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"
15#include "SkGpuDevice.h"
16#include "SkPaint.h"
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000017#include "SkRRect.h"
tfarina@chromium.org8f6884a2014-01-24 20:56:26 +000018#include "SkRect.h"
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000019#include "Test.h"
20
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000021static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000022 // 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.org4ee16bf2014-01-10 22:08:27 +000044DEF_GPUTEST(GpuDrawPath, reporter, factory) {
jvanverth@google.com2f683ba2013-08-05 14:50:31 +000045 return;
46
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000047 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) {
57 const int W = 255;
58 const int H = 255;
59
60 GrTextureDesc desc;
61 desc.fConfig = kSkia8888_GrPixelConfig;
62 desc.fFlags = kRenderTarget_GrTextureFlagBit;
63 desc.fWidth = W;
64 desc.fHeight = H;
65 desc.fSampleCnt = sampleCounts[i];
66 SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0));
67 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture.get())));
68 SkCanvas drawingCanvas(device.get());
69
70 test_drawPathEmpty(reporter, &drawingCanvas);
71 }
72 }
73}
74
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000075#endif