Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: samplecode/SampleLayers.cpp

Issue 245963010: Move SkShader::fLocalMatrix into SkShader constructor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleHairModes.cpp ('k') | samplecode/SampleXfermodesBlur.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleLayers.cpp
diff --git a/samplecode/SampleLayers.cpp b/samplecode/SampleLayers.cpp
index 3ae543915c253dda4a406688784ba8fa49cc8ee4..51f02a1adef5d8a0043585ace6138d1c3a2f7c91 100644
--- a/samplecode/SampleLayers.cpp
+++ b/samplecode/SampleLayers.cpp
@@ -27,10 +27,11 @@
#include "SkXfermode.h"
#include "SkDrawFilter.h"
-static void make_paint(SkPaint* paint) {
+static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) {
SkColor colors[] = { 0, SK_ColorWHITE };
SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } };
- SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
+ SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode,
+ NULL, 0, &localMatrix);
paint->setShader(s)->unref();
paint->setXfermodeMode(SkXfermode::kDstIn_Mode);
@@ -104,19 +105,16 @@ static void test_fade(SkCanvas* canvas) {
dump_layers("outside layer alpha", canvas);
// now apply an effect
+ SkMatrix m;
+ m.setScale(SK_Scalar1, -SK_Scalar1);
+ m.postTranslate(0, SkIntToScalar(100));
SkPaint paint;
- make_paint(&paint);
+ make_paint(&paint, m);
r.set(0, 0, SkIntToScalar(100), SkIntToScalar(20));
// SkDebugf("--------- draw top grad\n");
canvas->drawRect(r, paint);
- SkMatrix m;
- SkShader* s = paint.getShader();
- m.setScale(SK_Scalar1, -SK_Scalar1);
- m.postTranslate(0, SkIntToScalar(100));
- s->setLocalMatrix(m);
-
r.fTop = SkIntToScalar(80);
r.fBottom = SkIntToScalar(100);
// SkDebugf("--------- draw bot grad\n");
« no previous file with comments | « samplecode/SampleHairModes.cpp ('k') | samplecode/SampleXfermodesBlur.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698