| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 | 
|  | 2 /* | 
|  | 3  * Copyright 2013 Google Inc. | 
|  | 4  * | 
|  | 5  * Use of this source code is governed by a BSD-style license that can be | 
|  | 6  * found in the LICENSE file. | 
|  | 7  */ | 
|  | 8 | 
|  | 9 #if SK_SUPPORT_GPU | 
|  | 10 | 
|  | 11 #include "GrContext.h" | 
|  | 12 #include "GrContextFactory.h" | 
|  | 13 #include "SkBitmap.h" | 
|  | 14 #include "SkCanvas.h" | 
|  | 15 #include "SkColor.h" | 
|  | 16 #include "SkGpuDevice.h" | 
|  | 17 #include "SkPaint.h" | 
|  | 18 #include "SkRect.h" | 
|  | 19 #include "SkRRect.h" | 
|  | 20 #include "Test.h" | 
|  | 21 | 
|  | 22 static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) | 
|  | 23 { | 
|  | 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 | 
|  | 46 static void TestGpuDrawPath(skiatest::Reporter* reporter, GrContextFactory* fact
    ory) { | 
|  | 47     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { | 
|  | 48         GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
    LContextType>(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(des
    c, 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 | 
|  | 75 #include "TestClassDef.h" | 
|  | 76 DEFINE_GPUTESTCLASS("GpuDrawPath", TestGpuDrawPathClass, TestGpuDrawPath) | 
|  | 77 | 
|  | 78 #endif | 
| OLD | NEW | 
|---|