diff options
-rw-r--r-- | resources/nov-talk-sequence.txt | 14 | ||||
-rw-r--r-- | samplecode/SampleFilterQuality.cpp | 30 |
2 files changed, 38 insertions, 6 deletions
diff --git a/resources/nov-talk-sequence.txt b/resources/nov-talk-sequence.txt index 7ce66d3a83..391784b9dc 100644 --- a/resources/nov-talk-sequence.txt +++ b/resources/nov-talk-sequence.txt @@ -1,4 +1,10 @@ -Arcs -GM:aaclip -GM:xfermodes -GM:addarc +DrawAtlasSim +DrawAtlas +DrawShipSim +DrawShip +PerlinPatch +FilterQuality +GM:xfermodes2 +GM:aaxfermodes +GM:colortype +AnimatedText diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp index f5558d84f9..1213b75b08 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 |