| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // creates a bitmap with shades of transparent gray. | 60 // creates a bitmap with shades of transparent gray. |
| 61 static SkImage* CreateTransparentBitmap(int width, int height) { | 61 static SkImage* CreateTransparentBitmap(int width, int height) { |
| 62 SkBitmap bm; | 62 SkBitmap bm; |
| 63 bm.allocN32Pixels(width, height); | 63 bm.allocN32Pixels(width, height); |
| 64 SkCanvas canvas(bm); | 64 SkCanvas canvas(bm); |
| 65 canvas.clear(0x0); | 65 canvas.clear(0x0); |
| 66 | 66 |
| 67 SkPoint pts[] = {{0, 0}, {SkIntToScalar(width), SkIntToScalar(height)}}; | 67 SkPoint pts[] = {{0, 0}, {SkIntToScalar(width), SkIntToScalar(height)}}; |
| 68 SkColor colors[] = {0x00000000, 0xFFFFFFFF}; | 68 SkColor colors[] = {0x00000000, 0xFFFFFFFF}; |
| 69 SkPaint paint; | 69 SkPaint paint; |
| 70 paint.setShader(SkGradientShader::CreateLinear(pts, colors, NULL, 2, | 70 paint.setShader(SkGradientShader::CreateLinear(pts, colors, nullptr, 2, |
| 71 SkShader::kClamp_TileMode
))->unref(); | 71 SkShader::kClamp_TileMode
))->unref(); |
| 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::NewFromBitmap(bm); | 73 return SkImage::NewFromBitmap(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.setXfermodeMode(SkXfermode::kSrc_Mode); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 private: | 141 private: |
| 142 SkAutoTUnref<SkImage> fSolidImg; | 142 SkAutoTUnref<SkImage> fSolidImg; |
| 143 SkAutoTUnref<SkImage> fTransparentImg; | 143 SkAutoTUnref<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; ) |
| 148 | 148 |
| OLD | NEW |