blob: f2a321f756f3baa854bd0bf997652d4ed39f0650 [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"
17#include "SkRect.h"
18#include "SkRRect.h"
19#include "Test.h"
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000020#include "TestClassDef.h"
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000021
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000022static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000023 // Filling an empty path should not crash.
24 SkPaint paint;
25 canvas->drawRect(SkRect(), paint);
26 canvas->drawPath(SkPath(), paint);
27 canvas->drawOval(SkRect(), paint);
28 canvas->drawRect(SkRect(), paint);
29 canvas->drawRRect(SkRRect(), paint);
30
31 // Stroking an empty path should not crash.
32 paint.setAntiAlias(true);
33 paint.setStyle(SkPaint::kStroke_Style);
34 paint.setColor(SK_ColorGRAY);
35 paint.setStrokeWidth(SkIntToScalar(20));
36 paint.setStrokeJoin(SkPaint::kRound_Join);
37 canvas->drawRect(SkRect(), paint);
38 canvas->drawPath(SkPath(), paint);
39 canvas->drawOval(SkRect(), paint);
40 canvas->drawRect(SkRect(), paint);
41 canvas->drawRRect(SkRRect(), paint);
42}
43
44
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000045DEF_GPUTEST(GpuDrawPath, reporter, factory) {
jvanverth@google.com2f683ba2013-08-05 14:50:31 +000046 return;
47
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000048 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
49 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
50
51 GrContext* grContext = factory->get(glType);
52 if (NULL == grContext) {
53 continue;
54 }
55 static const int sampleCounts[] = { 0, 4, 16 };
56
57 for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
58 const int W = 255;
59 const int H = 255;
60
61 GrTextureDesc desc;
62 desc.fConfig = kSkia8888_GrPixelConfig;
63 desc.fFlags = kRenderTarget_GrTextureFlagBit;
64 desc.fWidth = W;
65 desc.fHeight = H;
66 desc.fSampleCnt = sampleCounts[i];
67 SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0));
68 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture.get())));
69 SkCanvas drawingCanvas(device.get());
70
71 test_drawPathEmpty(reporter, &drawingCanvas);
72 }
73 }
74}
75
commit-bot@chromium.org19dd0172013-08-05 13:28:55 +000076#endif