a6eaac0595
This should make it so the HW tessellation path renderers are never used; it will always select the atlas or direct fixed-count renderers instead. This CL will give us a good indication of what visual diffs to expect, layout tests to rebase, and any performance regressions. If those are acceptable, then we can proceed with the rest of the code removal. Bug: skia:13263 Change-Id: I273bb231461932047768c1c7233ae4291483bc95 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/533810 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
93 lines
3.1 KiB
C++
93 lines
3.1 KiB
C++
/*
|
|
* Copyright 2020 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "gm/gm.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkPath.h"
|
|
#include "include/core/SkPoint.h"
|
|
#include "include/gpu/GrContextOptions.h"
|
|
#include "include/gpu/GrDirectContext.h"
|
|
#include "include/utils/SkRandom.h"
|
|
#include "src/gpu/ganesh/GrCaps.h"
|
|
#include "src/gpu/ganesh/GrDirectContextPriv.h"
|
|
#include "src/gpu/ganesh/GrDrawingManager.h"
|
|
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
|
|
#include "src/gpu/ganesh/ops/TessellationPathRenderer.h"
|
|
|
|
static constexpr float kStrokeWidth = 100;
|
|
static constexpr int kTestWidth = 120 * 4;
|
|
static constexpr int kTestHeight = 120 * 3 + 140;
|
|
|
|
static void draw_strokes(SkCanvas* canvas, SkRandom* rand, const SkPath& path,
|
|
const SkPath& cubic) {
|
|
SkPaint strokePaint;
|
|
strokePaint.setAntiAlias(true);
|
|
strokePaint.setStrokeWidth(kStrokeWidth);
|
|
strokePaint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
SkAutoCanvasRestore arc(canvas, true);
|
|
strokePaint.setStrokeJoin(SkPaint::kBevel_Join);
|
|
strokePaint.setColor(rand->nextU() | 0xff808080);
|
|
canvas->drawPath(path, strokePaint);
|
|
|
|
canvas->translate(120, 0);
|
|
strokePaint.setStrokeJoin(SkPaint::kRound_Join);
|
|
strokePaint.setColor(rand->nextU() | 0xff808080);
|
|
canvas->drawPath(path, strokePaint);
|
|
|
|
canvas->translate(120, 0);
|
|
strokePaint.setStrokeJoin(SkPaint::kMiter_Join);
|
|
strokePaint.setColor(rand->nextU() | 0xff808080);
|
|
canvas->drawPath(path, strokePaint);
|
|
|
|
canvas->translate(120, 0);
|
|
strokePaint.setColor(rand->nextU() | 0xff808080);
|
|
canvas->drawPath(cubic, strokePaint);
|
|
}
|
|
|
|
static void draw_test(SkCanvas* canvas) {
|
|
SkRandom rand;
|
|
|
|
if (canvas->recordingContext() &&
|
|
canvas->recordingContext()->priv().caps()->shaderCaps()->tessellationSupport() &&
|
|
canvas->recordingContext()->priv().caps()->shaderCaps()->maxTessellationSegments() == 5) {
|
|
// The caller successfully overrode the max tessellation segments to 5. Indicate this in the
|
|
// background color.
|
|
canvas->clear(SkColorSetARGB(255, 64, 0, 0));
|
|
} else {
|
|
canvas->clear(SK_ColorBLACK);
|
|
}
|
|
|
|
SkAutoCanvasRestore arc(canvas, true);
|
|
canvas->translate(60, 60);
|
|
|
|
draw_strokes(canvas, &rand,
|
|
SkPath().lineTo(10,0).lineTo(10,10),
|
|
SkPath().cubicTo(10,0, 10,0, 10,10));
|
|
canvas->translate(0, 120);
|
|
|
|
draw_strokes(canvas, &rand,
|
|
SkPath().lineTo(0,-10).lineTo(0,10),
|
|
SkPath().cubicTo(0,-10, 0,-10, 0,10));
|
|
canvas->translate(0, 120);
|
|
|
|
draw_strokes(canvas, &rand,
|
|
SkPath().lineTo(0,-10).lineTo(10,-10).lineTo(10,10).lineTo(0,10),
|
|
SkPath().cubicTo(0,-10, 10,10, 0,10));
|
|
canvas->translate(0, 140);
|
|
|
|
draw_strokes(canvas, &rand,
|
|
SkPath().lineTo(0,-10).lineTo(10,-10).lineTo(10,0).lineTo(0,0),
|
|
SkPath().cubicTo(0,-10, 10,0, 0,0));
|
|
canvas->translate(0, 120);
|
|
}
|
|
|
|
DEF_SIMPLE_GM(widebuttcaps, canvas, kTestWidth, kTestHeight) {
|
|
canvas->clear(SK_ColorBLACK);
|
|
draw_test(canvas);
|
|
}
|