skia2/gm/radial_gradient_precision.cpp
Mike Klein 1b258182ad move in center of radial_gradient_precision
{1K,1K} ought to work fine for F16 precision.  16 bit floats step by 1.0
between 1024 and 2048, so they should be able to just barely represent
distinct coordinates for each pixel.  If precision drops below 16 bit
we'll start seeing banding because we can't distinguish coordinates.

Swap out the colors a little so that it's clear which images are the 1K
(black+green) and which are the old 100K (black+white).

Change-Id: I92761c3aa67cab57332e6f00a421c63c1d9d990a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201041
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2019-03-14 16:07:21 +00:00

23 lines
705 B
C++

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkGradientShader.h"
// All we're looking for here is that we see a smooth gradient.
DEF_SIMPLE_GM(radial_gradient_precision, canvas, 200, 200) {
SkPoint center = {1000, 1000};
SkScalar radius = 40;
SkColor colors[] = {SK_ColorBLACK, SK_ColorGREEN};
SkPaint p;
p.setShader(SkGradientShader::MakeRadial(center, radius,
colors, nullptr, SK_ARRAY_COUNT(colors),
SkShader::kRepeat_TileMode));
canvas->drawPaint(p);
}