Skip to content

Commit

Permalink
Fix matrix scoping issue in sample
Browse files Browse the repository at this point in the history
Change-Id: Id0023a12a21957ec9236d4ffaa03134995388d60
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278456
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
  • Loading branch information
kjlubick authored and Skia Commit-Bot committed Mar 23, 2020
1 parent 59e7496 commit 6f60a85
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions docs/examples/GradientShader_MakeLinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ void draw(SkCanvas* canvas) {
SkScalar positions[] = { 0.0, 0.65, 1.0 };

for (int i = 0; i < 4; i++) {
SkScalar blockX = (i / 2) * 100;
SkScalar blockY = (i % 2) * 100;
SkScalar blockX = (i % 2) * 100;
SkScalar blockY = (i / 2) * 100;
SkPoint pts[] = { {blockX, blockY}, {blockX + 50, blockY + 100} };

int flags = 0; // interpolate colors in unpremul
Expand All @@ -29,17 +29,15 @@ void draw(SkCanvas* canvas) {
flags = SkGradientShader::Flags::kInterpolateColorsInPremul_Flag;
}

SkMatrix* matr = nullptr;
SkMatrix matr = SkMatrix::I();
if (i / 2 == 1) {
// bottom row will be rotated 45 degrees.
SkMatrix m;
m.setRotate(45, blockX, blockY);
matr = &m;
matr.setRotate(45, blockX, blockY);
}

auto lgs = SkGradientShader::MakeLinear(
pts, colors, positions, 3, SkTileMode::kMirror,
flags, matr);
pts, colors, positions, 3, SkTileMode::kMirror,
flags, &matr);

p.setShader(lgs);
auto r = SkRect::MakeLTRB(blockX, blockY, blockX + 100, blockY + 100);
Expand Down

0 comments on commit 6f60a85

Please sign in to comment.