2013-08-05 13:28:55 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
#include "SkTypes.h"
|
|
|
|
|
2013-08-05 13:28:55 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
#include "GrContext.h"
|
|
|
|
#include "GrContextFactory.h"
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkColor.h"
|
|
|
|
#include "SkPaint.h"
|
|
|
|
#include "SkRRect.h"
|
2014-01-24 20:56:26 +00:00
|
|
|
#include "SkRect.h"
|
2014-09-18 13:09:44 +00:00
|
|
|
#include "SkSurface.h"
|
2013-08-05 13:28:55 +00:00
|
|
|
#include "Test.h"
|
|
|
|
|
2014-01-10 22:08:27 +00:00
|
|
|
static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
|
2013-08-05 13:28:55 +00:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-10 22:08:27 +00:00
|
|
|
DEF_GPUTEST(GpuDrawPath, reporter, factory) {
|
2013-08-05 14:50:31 +00:00
|
|
|
return;
|
|
|
|
|
2013-08-05 13:28:55 +00:00
|
|
|
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
|
|
|
|
GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
|
|
|
|
|
|
|
|
GrContext* grContext = factory->get(glType);
|
2015-08-27 14:41:13 +00:00
|
|
|
if (nullptr == grContext) {
|
2013-08-05 13:28:55 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
static const int sampleCounts[] = { 0, 4, 16 };
|
|
|
|
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
|
2014-09-18 13:09:44 +00:00
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
|
|
|
|
|
2015-01-16 15:32:33 +00:00
|
|
|
SkAutoTUnref<SkSurface> surface(
|
|
|
|
SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, info,
|
2015-08-27 14:41:13 +00:00
|
|
|
sampleCounts[i], nullptr));
|
2014-09-18 13:09:44 +00:00
|
|
|
test_drawPathEmpty(reporter, surface->getCanvas());
|
2013-08-05 13:28:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|