| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #if SK_SUPPORT_GPU | 8 #if SK_SUPPORT_GPU |
| 9 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| 11 #include "GrContextFactory.h" | 11 #include "GrContextFactory.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 14 #include "SkColor.h" | 14 #include "SkColor.h" |
| 15 #include "SkGpuDevice.h" | |
| 16 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 17 #include "SkRRect.h" | 16 #include "SkRRect.h" |
| 18 #include "SkRect.h" | 17 #include "SkRect.h" |
| 18 #include "SkSurface.h" |
| 19 #include "Test.h" | 19 #include "Test.h" |
| 20 | 20 |
| 21 static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) { | 21 static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) { |
| 22 // Filling an empty path should not crash. | 22 // Filling an empty path should not crash. |
| 23 SkPaint paint; | 23 SkPaint paint; |
| 24 canvas->drawRect(SkRect(), paint); | 24 canvas->drawRect(SkRect(), paint); |
| 25 canvas->drawPath(SkPath(), paint); | 25 canvas->drawPath(SkPath(), paint); |
| 26 canvas->drawOval(SkRect(), paint); | 26 canvas->drawOval(SkRect(), paint); |
| 27 canvas->drawRect(SkRect(), paint); | 27 canvas->drawRect(SkRect(), paint); |
| 28 canvas->drawRRect(SkRRect(), paint); | 28 canvas->drawRRect(SkRRect(), paint); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { | 47 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
| 48 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); | 48 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); |
| 49 | 49 |
| 50 GrContext* grContext = factory->get(glType); | 50 GrContext* grContext = factory->get(glType); |
| 51 if (NULL == grContext) { | 51 if (NULL == grContext) { |
| 52 continue; | 52 continue; |
| 53 } | 53 } |
| 54 static const int sampleCounts[] = { 0, 4, 16 }; | 54 static const int sampleCounts[] = { 0, 4, 16 }; |
| 55 | 55 |
| 56 for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) { | 56 for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) { |
| 57 const int W = 255; | 57 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255); |
| 58 const int H = 255; | 58 |
| 59 | 59 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(grContext
, info, sampleCounts[i])); |
| 60 GrTextureDesc desc; | 60 test_drawPathEmpty(reporter, surface->getCanvas()); |
| 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(SkGpuDevice::Create(texture.get()))
; | |
| 68 SkCanvas drawingCanvas(device.get()); | |
| 69 | |
| 70 test_drawPathEmpty(reporter, &drawingCanvas); | |
| 71 } | 61 } |
| 72 } | 62 } |
| 73 } | 63 } |
| 74 | 64 |
| 75 #endif | 65 #endif |
| OLD | NEW |