c0bd9f9fe5
Current strategy: everything from the top Things to look at first are the manual changes: - added tools/rewrite_includes.py - removed -Idirectives from BUILD.gn - various compile.sh simplifications - tweak tools/embed_resources.py - update gn/find_headers.py to write paths from the top - update gn/gn_to_bp.py SkUserConfig.h layout so that #include "include/config/SkUserConfig.h" always gets the header we want. No-Presubmit: true Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
117 lines
3.1 KiB
C++
117 lines
3.1 KiB
C++
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkPaint.h"
|
|
#include "include/effects/SkColorMatrixFilter.h"
|
|
#include "include/effects/SkDiscretePathEffect.h"
|
|
#include "include/effects/SkGradientShader.h"
|
|
#include "samplecode/Sample.h"
|
|
#include "src/core/SkBlurMask.h"
|
|
#include "src/effects/SkEmbossMaskFilter.h"
|
|
|
|
|
|
//#define COLOR 0xFFFF8844
|
|
#define COLOR 0xFF888888
|
|
|
|
static void paint_proc0(SkPaint*) {
|
|
}
|
|
|
|
static void paint_proc1(SkPaint* paint) {
|
|
paint->setMaskFilter(SkMaskFilter::MakeBlur(
|
|
kNormal_SkBlurStyle,
|
|
SkBlurMask::ConvertRadiusToSigma(2)));
|
|
}
|
|
|
|
static void paint_proc2(SkPaint* paint) {
|
|
paint->setMaskFilter(SkEmbossMaskFilter::Make(
|
|
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)),
|
|
{ { SK_Scalar1, SK_Scalar1, SK_Scalar1 }, 0, 64, 16 }));
|
|
}
|
|
|
|
static void paint_proc3(SkPaint* paint) {
|
|
SkColor colors[] = { SK_ColorRED, COLOR, SK_ColorBLUE };
|
|
SkPoint pts[] = { { 3, 0 }, { 7, 5 } };
|
|
paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
|
|
SkTileMode::kMirror));
|
|
}
|
|
|
|
static void paint_proc5(SkPaint* paint) {
|
|
paint_proc3(paint);
|
|
paint_proc2(paint);
|
|
}
|
|
|
|
typedef void (*PaintProc)(SkPaint*);
|
|
const PaintProc gPaintProcs[] = {
|
|
paint_proc0,
|
|
paint_proc1,
|
|
paint_proc2,
|
|
paint_proc3,
|
|
paint_proc5,
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
class EffectsView : public Sample {
|
|
public:
|
|
SkPath fPath;
|
|
SkPaint fPaint[SK_ARRAY_COUNT(gPaintProcs)];
|
|
|
|
EffectsView() {
|
|
size_t i;
|
|
const float pts[] = {
|
|
0, 0,
|
|
10, 0,
|
|
10, 5,
|
|
20, -5,
|
|
10, -15,
|
|
10, -10,
|
|
0, -10
|
|
};
|
|
fPath.moveTo(pts[0], pts[1]);
|
|
for (i = 2; i < SK_ARRAY_COUNT(pts); i += 2) {
|
|
fPath.lineTo(pts[i], pts[i+1]);
|
|
}
|
|
|
|
for (i = 0; i < SK_ARRAY_COUNT(gPaintProcs); i++) {
|
|
fPaint[i].setAntiAlias(true);
|
|
fPaint[i].setColor(COLOR);
|
|
gPaintProcs[i](&fPaint[i]);
|
|
}
|
|
|
|
SkColorMatrix cm;
|
|
cm.setRotate(SkColorMatrix::kG_Axis, 180);
|
|
cm.setIdentity();
|
|
|
|
this->setBGColor(0xFFDDDDDD);
|
|
}
|
|
|
|
protected:
|
|
virtual bool onQuery(Sample::Event* evt) {
|
|
if (Sample::TitleQ(*evt)) {
|
|
Sample::TitleR(evt, "Effects");
|
|
return true;
|
|
}
|
|
return this->INHERITED::onQuery(evt);
|
|
}
|
|
|
|
virtual void onDrawContent(SkCanvas* canvas) {
|
|
canvas->scale(3, 3);
|
|
canvas->translate(10, 30);
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(fPaint); i++) {
|
|
canvas->drawPath(fPath, fPaint[i]);
|
|
canvas->translate(32, 0);
|
|
}
|
|
}
|
|
|
|
private:
|
|
typedef Sample INHERITED;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_SAMPLE( return new EffectsView(); )
|