skia2/gm/fadefilter.cpp
Michael Ludwig 898bbfac2e Update gms to use new image filter factories
Bug: skia:9280
Change-Id: Ic7ca3a9c86025128bc45b89ea90aa4553287b8c9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230879
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-08-02 21:08:40 +00:00

30 lines
977 B
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/effects/SkImageFilters.h"
#include <utility>
// This GM renders correctly in 8888, but fails in PDF
DEF_SIMPLE_GM(fadefilter, canvas, 256, 256) {
float matrix[20] = { 1, 0, 0, 0, 0.5f,
0, 1, 0, 0, 0.5f,
0, 0, 1, 0, 0.5f,
0, 0, 0, 1, 0 };
sk_sp<SkColorFilter> colorFilter(SkColorFilters::Matrix(matrix));
SkPaint layerPaint;
layerPaint.setImageFilter(SkImageFilters::ColorFilter(std::move(colorFilter), nullptr));
canvas->drawRect(SkRect::MakeLTRB(64, 64, 192, 192), layerPaint);
}