1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2011 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#include "include/core/SkCanvas.h"
9cb93a386Sopenharmony_ci#include "include/core/SkColorFilter.h"
10cb93a386Sopenharmony_ci#include "include/core/SkColorPriv.h"
11cb93a386Sopenharmony_ci#include "include/core/SkGraphics.h"
12cb93a386Sopenharmony_ci#include "include/core/SkPath.h"
13cb93a386Sopenharmony_ci#include "include/core/SkRegion.h"
14cb93a386Sopenharmony_ci#include "include/core/SkShader.h"
15cb93a386Sopenharmony_ci#include "include/core/SkTime.h"
16cb93a386Sopenharmony_ci#include "include/core/SkTypeface.h"
17cb93a386Sopenharmony_ci#include "include/effects/SkGradientShader.h"
18cb93a386Sopenharmony_ci#include "include/utils/SkRandom.h"
19cb93a386Sopenharmony_ci#include "samplecode/Sample.h"
20cb93a386Sopenharmony_ci#include "src/core/SkBlurMask.h"
21cb93a386Sopenharmony_ci#include "src/effects/SkEmbossMaskFilter.h"
22cb93a386Sopenharmony_ci#include "src/utils/SkUTF.h"
23cb93a386Sopenharmony_ci
24cb93a386Sopenharmony_ciclass EmbossView : public Sample {
25cb93a386Sopenharmony_ci    SkEmbossMaskFilter::Light   fLight;
26cb93a386Sopenharmony_cipublic:
27cb93a386Sopenharmony_ci    EmbossView() {
28cb93a386Sopenharmony_ci        fLight.fDirection[0] = SK_Scalar1;
29cb93a386Sopenharmony_ci        fLight.fDirection[1] = SK_Scalar1;
30cb93a386Sopenharmony_ci        fLight.fDirection[2] = SK_Scalar1;
31cb93a386Sopenharmony_ci        fLight.fAmbient = 128;
32cb93a386Sopenharmony_ci        fLight.fSpecular = 16*2;
33cb93a386Sopenharmony_ci    }
34cb93a386Sopenharmony_ci
35cb93a386Sopenharmony_ciprotected:
36cb93a386Sopenharmony_ci    SkString name() override { return SkString("Emboss"); }
37cb93a386Sopenharmony_ci
38cb93a386Sopenharmony_ci    void onDrawContent(SkCanvas* canvas) override {
39cb93a386Sopenharmony_ci        SkPaint paint;
40cb93a386Sopenharmony_ci
41cb93a386Sopenharmony_ci        paint.setAntiAlias(true);
42cb93a386Sopenharmony_ci        paint.setStyle(SkPaint::kStroke_Style);
43cb93a386Sopenharmony_ci        paint.setStrokeWidth(SkIntToScalar(10));
44cb93a386Sopenharmony_ci        paint.setMaskFilter(SkEmbossMaskFilter::Make(SkBlurMask::ConvertRadiusToSigma(4), fLight));
45cb93a386Sopenharmony_ci        paint.setShader(SkShaders::Color(SK_ColorBLUE));
46cb93a386Sopenharmony_ci        paint.setDither(true);
47cb93a386Sopenharmony_ci
48cb93a386Sopenharmony_ci        canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
49cb93a386Sopenharmony_ci                           SkIntToScalar(30), paint);
50cb93a386Sopenharmony_ci    }
51cb93a386Sopenharmony_ci
52cb93a386Sopenharmony_ciprivate:
53cb93a386Sopenharmony_ci
54cb93a386Sopenharmony_ci    using INHERITED = Sample;
55cb93a386Sopenharmony_ci};
56cb93a386Sopenharmony_ci
57cb93a386Sopenharmony_ci//////////////////////////////////////////////////////////////////////////////
58cb93a386Sopenharmony_ci
59cb93a386Sopenharmony_ciDEF_SAMPLE( return new EmbossView(); )
60