aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/fadefilter.cpp
blob: 386e32b098c6a351430917d0fef4942e68394b95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * 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.h"
#include "SkColorMatrixFilter.h"
#include "SkColorFilterImageFilter.h"

// This GM renders correctly in 8888, but fails in PDF
DEF_SIMPLE_GM(fadefilter, canvas, 256, 256) {
    SkScalar matrix[20] = { 1, 0, 0, 0, 128.0f,
                            0, 1, 0, 0, 128.0f,
                            0, 0, 1, 0, 128.0f,
                            0, 0, 0, 1, 0 };
    auto colorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
    SkAutoTUnref<SkImageFilter> filter(SkColorFilterImageFilter::Create(colorFilter.get()));
    SkPaint layerPaint;
    layerPaint.setImageFilter(filter);
    canvas->drawRect(SkRect::MakeLTRB(64, 64, 192, 192), layerPaint);
}