OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkColorMatrixFilter.h" | 9 #include "SkColorMatrixFilter.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, | 70 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, |
71 SkShader::kClamp_TileMode))
; | 71 SkShader::kClamp_TileMode))
; |
72 canvas.drawRect(SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh
t)), paint); | 72 canvas.drawRect(SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh
t)), paint); |
73 return SkImage::MakeFromBitmap(bm); | 73 return SkImage::MakeFromBitmap(bm); |
74 } | 74 } |
75 | 75 |
76 void onDraw(SkCanvas* canvas) override { | 76 void onDraw(SkCanvas* canvas) override { |
77 SkPaint paint; | 77 SkPaint paint; |
78 SkColorMatrix matrix; | 78 SkColorMatrix matrix; |
79 | 79 |
80 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 80 paint.setBlendMode(SkBlendMode::kSrc); |
81 const SkImage* bmps[] = { fSolidImg.get(), fTransparentImg.get() }; | 81 const SkImage* bmps[] = { fSolidImg.get(), fTransparentImg.get() }; |
82 | 82 |
83 for (size_t i = 0; i < SK_ARRAY_COUNT(bmps); ++i) { | 83 for (size_t i = 0; i < SK_ARRAY_COUNT(bmps); ++i) { |
84 matrix.setIdentity(); | 84 matrix.setIdentity(); |
85 set_color_matrix(&paint, matrix); | 85 set_color_matrix(&paint, matrix); |
86 canvas->drawImage(bmps[i], 0, 0, &paint); | 86 canvas->drawImage(bmps[i], 0, 0, &paint); |
87 | 87 |
88 matrix.setRotate(SkColorMatrix::kR_Axis, 90); | 88 matrix.setRotate(SkColorMatrix::kR_Axis, 90); |
89 set_color_matrix(&paint, matrix); | 89 set_color_matrix(&paint, matrix); |
90 canvas->drawImage(bmps[i], 80, 0, &paint); | 90 canvas->drawImage(bmps[i], 80, 0, &paint); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 private: | 141 private: |
142 sk_sp<SkImage> fSolidImg; | 142 sk_sp<SkImage> fSolidImg; |
143 sk_sp<SkImage> fTransparentImg; | 143 sk_sp<SkImage> fTransparentImg; |
144 | 144 |
145 typedef skiagm::GM INHERITED; | 145 typedef skiagm::GM INHERITED; |
146 }; | 146 }; |
147 DEF_GM( return new ColorMatrixGM; ) | 147 DEF_GM( return new ColorMatrixGM; ) |
OLD | NEW |