| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkColorMatrixFilter.h" | 10 #include "SkColorMatrixFilter.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return SkGradientShader::MakeLinear(pts, colors, nullptr, 3, SkShader::kRepe
at_TileMode); | 59 return SkGradientShader::MakeLinear(pts, colors, nullptr, 3, SkShader::kRepe
at_TileMode); |
| 60 } | 60 } |
| 61 | 61 |
| 62 static sk_sp<SkShader> sh_make_lineargradient1() { | 62 static sk_sp<SkShader> sh_make_lineargradient1() { |
| 63 const SkPoint pts[] = { { 0, 0 }, { 100, 100 } }; | 63 const SkPoint pts[] = { { 0, 0 }, { 100, 100 } }; |
| 64 const SkColor colors[] = { SK_ColorRED, 0x0000FF00, SK_ColorBLUE }; | 64 const SkColor colors[] = { SK_ColorRED, 0x0000FF00, SK_ColorBLUE }; |
| 65 return SkGradientShader::MakeLinear(pts, colors, nullptr, 3, SkShader::kRepe
at_TileMode); | 65 return SkGradientShader::MakeLinear(pts, colors, nullptr, 3, SkShader::kRepe
at_TileMode); |
| 66 } | 66 } |
| 67 | 67 |
| 68 static sk_sp<SkShader> sh_make_image() { | 68 static sk_sp<SkShader> sh_make_image() { |
| 69 SkAutoTUnref<SkImage> image(GetResourceAsImage("mandrill_128.png")); | 69 sk_sp<SkImage> image(GetResourceAsImage("mandrill_128.png")); |
| 70 if (!image) { | 70 if (!image) { |
| 71 return nullptr; | 71 return nullptr; |
| 72 } | 72 } |
| 73 return image->makeShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileM
ode); | 73 return image->makeShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileM
ode); |
| 74 } | 74 } |
| 75 | 75 |
| 76 static void sk_gm_get_shaders(SkTDArray<SkShader*>* array) { | 76 static void sk_gm_get_shaders(SkTDArray<SkShader*>* array) { |
| 77 if (auto shader = sh_make_lineargradient0()) { | 77 if (auto shader = sh_make_lineargradient0()) { |
| 78 *array->append() = shader.release(); | 78 *array->append() = shader.release(); |
| 79 } | 79 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 SkColorFilter* filter = x >= 0 ? filters[x] : nullptr; | 213 SkColorFilter* filter = x >= 0 ? filters[x] : nullptr; |
| 214 | 214 |
| 215 paint.setShader(shader->makeWithColorFilter(filter)); | 215 paint.setShader(shader->makeWithColorFilter(filter)); |
| 216 canvas->drawRect(r, paint); | 216 canvas->drawRect(r, paint); |
| 217 canvas->translate(150, 0); | 217 canvas->translate(150, 0); |
| 218 } | 218 } |
| 219 canvas->restore(); | 219 canvas->restore(); |
| 220 canvas->translate(0, 150); | 220 canvas->translate(0, 150); |
| 221 } | 221 } |
| 222 } | 222 } |
| OLD | NEW |