2018-01-18 21:06:54 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkBlendMode.h"
|
|
|
|
#include "include/core/SkBlurTypes.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkColor.h"
|
|
|
|
#include "include/core/SkCoverageMode.h"
|
|
|
|
#include "include/core/SkFont.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkImage.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkImageFilter.h"
|
|
|
|
#include "include/core/SkImageInfo.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkMaskFilter.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkMatrix.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkPath.h"
|
|
|
|
#include "include/core/SkPicture.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPictureRecorder.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkPoint.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/core/SkScalar.h"
|
|
|
|
#include "include/core/SkShader.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/core/SkSurface.h"
|
|
|
|
#include "include/core/SkTileMode.h"
|
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
#include "include/effects/SkGradientShader.h"
|
2019-08-02 19:21:23 +00:00
|
|
|
#include "include/effects/SkImageFilters.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/effects/SkShaderMaskFilter.h"
|
|
|
|
#include "include/utils/SkTextUtils.h"
|
|
|
|
#include "src/core/SkBlendModePriv.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "tools/Resources.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/ToolUtils.h"
|
2018-01-18 21:06:54 +00:00
|
|
|
|
2019-05-01 21:28:53 +00:00
|
|
|
#include <initializer_list>
|
|
|
|
|
2018-01-18 21:06:54 +00:00
|
|
|
static sk_sp<SkShader> make_shader(const SkRect& r) {
|
|
|
|
const SkPoint pts[] = {
|
|
|
|
{ r.fLeft, r.fTop }, { r.fRight, r.fBottom },
|
|
|
|
};
|
|
|
|
const SkColor colors[] = { 0, SK_ColorWHITE };
|
2019-04-03 14:27:45 +00:00
|
|
|
return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkTileMode::kRepeat);
|
2018-01-18 21:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_SIMPLE_GM(shadermaskfilter_gradient, canvas, 512, 512) {
|
|
|
|
SkRect r = { 0, 0, 100, 150 };
|
|
|
|
auto shader = make_shader(r);
|
|
|
|
auto mf = SkShaderMaskFilter::Make(shader);
|
|
|
|
|
|
|
|
canvas->translate(20, 20);
|
|
|
|
canvas->scale(2, 2);
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setMaskFilter(mf);
|
|
|
|
paint.setColor(SK_ColorRED);
|
2018-02-01 16:24:53 +00:00
|
|
|
paint.setAntiAlias(true);
|
2018-01-18 21:06:54 +00:00
|
|
|
canvas->drawOval(r, paint);
|
|
|
|
}
|