skia2/tests/GpuDrawPathTest.cpp
tfarina@chromium.org 8f6884aab8 Cleanup: Sanitize the order of includes under tests/
Initially this was to make sure Test.h appeared after the Sk*.h includes.

Patch generated by the following command line:

$ ~/chromium/src/tools/sort-headers.py tests/*.cpp

BUG=None
TEST=tests
R=robertphillips@google.com

Review URL: https://codereview.chromium.org/145313004

git-svn-id: http://skia.googlecode.com/svn/trunk@13177 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-01-24 20:56:26 +00:00

76 lines
2.2 KiB
C++

/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextFactory.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkColor.h"
#include "SkGpuDevice.h"
#include "SkPaint.h"
#include "SkRRect.h"
#include "SkRect.h"
#include "Test.h"
static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
// Filling an empty path should not crash.
SkPaint paint;
canvas->drawRect(SkRect(), paint);
canvas->drawPath(SkPath(), paint);
canvas->drawOval(SkRect(), paint);
canvas->drawRect(SkRect(), paint);
canvas->drawRRect(SkRRect(), paint);
// Stroking an empty path should not crash.
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(SK_ColorGRAY);
paint.setStrokeWidth(SkIntToScalar(20));
paint.setStrokeJoin(SkPaint::kRound_Join);
canvas->drawRect(SkRect(), paint);
canvas->drawPath(SkPath(), paint);
canvas->drawOval(SkRect(), paint);
canvas->drawRect(SkRect(), paint);
canvas->drawRRect(SkRRect(), paint);
}
DEF_GPUTEST(GpuDrawPath, reporter, factory) {
return;
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
GrContext* grContext = factory->get(glType);
if (NULL == grContext) {
continue;
}
static const int sampleCounts[] = { 0, 4, 16 };
for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
const int W = 255;
const int H = 255;
GrTextureDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrTextureFlagBit;
desc.fWidth = W;
desc.fHeight = H;
desc.fSampleCnt = sampleCounts[i];
SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0));
SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture.get())));
SkCanvas drawingCanvas(device.get());
test_drawPathEmpty(reporter, &drawingCanvas);
}
}
}
#endif