| Index: samplecode/SampleFilterQuality.cpp
|
| diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp
|
| index f5558d84f904f84a067beecf0b9f8521956e09ac..1213b75b082d6e80f938b8d9cb0b8def5ea60d70 100644
|
| --- a/samplecode/SampleFilterQuality.cpp
|
| +++ b/samplecode/SampleFilterQuality.cpp
|
| @@ -12,6 +12,8 @@
|
| #include "SkAnimTimer.h"
|
| #include "SkCanvas.h"
|
| #include "SkInterpolator.h"
|
| +#include "SkGradientShader.h"
|
| +#include "SkData.h"
|
| #include "SkPath.h"
|
| #include "SkSurface.h"
|
| #include "SkRandom.h"
|
| @@ -25,6 +27,27 @@ static SkSurface* make_surface(SkCanvas* canvas, const SkImageInfo& info) {
|
| return surface;
|
| }
|
|
|
| +static SkShader* make_shader(const SkRect& bounds) {
|
| +#if 0
|
| + const SkPoint pts[] = {
|
| + { bounds.left(), bounds.top() },
|
| + { bounds.right(), bounds.bottom() },
|
| + };
|
| + const SkColor colors[] = {
|
| + SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorBLACK,
|
| + SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorYELLOW,
|
| + };
|
| + return SkGradientShader::CreateLinear(pts,
|
| + colors, nullptr, SK_ARRAY_COUNT(colors),
|
| + SkShader::kClamp_TileMode);
|
| +#else
|
| + SkString resourcePath = GetResourcePath("mandrill_128.png");
|
| + SkAutoTUnref<SkData> data(SkData::NewFromFileName(resourcePath.c_str()));
|
| + SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(data));
|
| + return image->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
|
| +#endif
|
| +}
|
| +
|
| #define N 128
|
| #define ANGLE_DELTA 3
|
| #define SCALE_DELTA (SK_Scalar1 / 32)
|
| @@ -42,12 +65,15 @@ static SkImage* make_image() {
|
| path.addRect(SkRect::MakeWH(N, N/2));
|
| path.moveTo(0, 0); path.lineTo(N, 0); path.lineTo(0, N); path.close();
|
|
|
| - canvas->drawPath(path, SkPaint());
|
| + SkPaint paint;
|
| + paint.setShader(make_shader(SkRect::MakeWH(N, N)))->unref();
|
| +
|
| + canvas->drawPath(path, paint);
|
| return surface->newImageSnapshot();
|
| }
|
|
|
| static SkImage* zoom_up(SkSurface* origSurf, SkImage* orig) {
|
| - const SkScalar S = 8; // amount to scale up
|
| + const SkScalar S = 16; // amount to scale up
|
| const int D = 2; // dimension scaling for the offscreen
|
| // since we only view the center, don't need to produce the entire thing
|
|
|
|
|