diff options
author | reed <reed@google.com> | 2015-11-09 08:36:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-09 08:36:05 -0800 |
commit | 73f6cfc1814f5063c13d2c5178e14f14031a640c (patch) | |
tree | 18a6f53ac873953f710381ab07aaf06ee50554b5 /samplecode/SampleFilterQuality.cpp | |
parent | 6f797092d2054f79374fb98fc1d57ca3554c7db4 (diff) |
tweaks for nov demo
Add this flag to SampleApp, and it will run with the specified restricted sequence
--sequence /skia/trunk/resources/nov-talk-sequence.txt
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/1410243009
Diffstat (limited to 'samplecode/SampleFilterQuality.cpp')
-rw-r--r-- | samplecode/SampleFilterQuality.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
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 |