From 73f6cfc1814f5063c13d2c5178e14f14031a640c Mon Sep 17 00:00:00 2001 From: reed Date: Mon, 9 Nov 2015 08:36:05 -0800 Subject: 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 --- samplecode/SampleFilterQuality.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'samplecode/SampleFilterQuality.cpp') 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 data(SkData::NewFromFileName(resourcePath.c_str())); + SkAutoTUnref 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 -- cgit v1.2.3