Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: gm/colorfilterimagefilter.cpp

Issue 1776973003: partial switch over to sp usage of shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move into lua container Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/coloremoji.cpp ('k') | gm/colorfilters.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 *array->append() = cf_make_brightness(0.5f); 46 *array->append() = cf_make_brightness(0.5f);
47 *array->append() = cf_make_grayscale(); 47 *array->append() = cf_make_grayscale();
48 *array->append() = cf_make_colorize(SK_ColorBLUE); 48 *array->append() = cf_make_colorize(SK_ColorBLUE);
49 } 49 }
50 50
51 //////////////////////////////////////////////////////////////////////////////// /////////////////// 51 //////////////////////////////////////////////////////////////////////////////// ///////////////////
52 #include "SkGradientShader.h" 52 #include "SkGradientShader.h"
53 #include "SkImage.h" 53 #include "SkImage.h"
54 #include "Resources.h" 54 #include "Resources.h"
55 55
56 static SkShader* sh_make_lineargradient0() { 56 static sk_sp<SkShader> sh_make_lineargradient0() {
57 const SkPoint pts[] = { { 0, 0 }, { 100, 100 } }; 57 const SkPoint pts[] = { { 0, 0 }, { 100, 100 } };
58 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; 58 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
59 return SkGradientShader::CreateLinear(pts, colors, nullptr, 3, SkShader::kRe peat_TileMode); 59 return SkGradientShader::MakeLinear(pts, colors, nullptr, 3, SkShader::kRepe at_TileMode);
60 } 60 }
61 61
62 static 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::CreateLinear(pts, colors, nullptr, 3, SkShader::kRe peat_TileMode); 65 return SkGradientShader::MakeLinear(pts, colors, nullptr, 3, SkShader::kRepe at_TileMode);
66 } 66 }
67 67
68 static SkShader* sh_make_image() { 68 static sk_sp<SkShader> sh_make_image() {
69 SkAutoTUnref<SkImage> image(GetResourceAsImage("mandrill_128.png")); 69 SkAutoTUnref<SkImage> image(GetResourceAsImage("mandrill_128.png"));
70 if (!image) { 70 if (!image) {
71 return nullptr; 71 return nullptr;
72 } 72 }
73 return image->newShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMo de); 73 return sk_sp<SkShader>(image->newShader(SkShader::kRepeat_TileMode,
74 SkShader::kRepeat_TileMode));
74 } 75 }
75 76
76 static void sk_gm_get_shaders(SkTDArray<SkShader*>* array) { 77 static void sk_gm_get_shaders(SkTDArray<SkShader*>* array) {
77 if (SkShader* shader = sh_make_lineargradient0()) { 78 if (auto shader = sh_make_lineargradient0()) {
78 *array->append() = shader; 79 *array->append() = shader.release();
79 } 80 }
80 if (SkShader* shader = sh_make_lineargradient1()) { 81 if (auto shader = sh_make_lineargradient1()) {
81 *array->append() = shader; 82 *array->append() = shader.release();
82 } 83 }
83 if (SkShader* shader = sh_make_image()) { 84 if (auto shader = sh_make_image()) {
84 *array->append() = shader; 85 *array->append() = shader.release();
85 } 86 }
86 } 87 }
87 88
88 //////////////////////////////////////////////////////////////////////////////// /////////////////// 89 //////////////////////////////////////////////////////////////////////////////// ///////////////////
89 90
90 static SkImageFilter* make_blur(float amount, SkImageFilter* input = nullptr) { 91 static SkImageFilter* make_blur(float amount, SkImageFilter* input = nullptr) {
91 return SkBlurImageFilter::Create(amount, amount, input); 92 return SkBlurImageFilter::Create(amount, amount, input);
92 } 93 }
93 94
94 static SkImageFilter* make_brightness(float amount, SkImageFilter* input = nullp tr) { 95 static SkImageFilter* make_brightness(float amount, SkImageFilter* input = nullp tr) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 SkColorFilter* filter = x >= 0 ? filters[x] : nullptr; 214 SkColorFilter* filter = x >= 0 ? filters[x] : nullptr;
214 215
215 paint.setShader(shader->newWithColorFilter(filter))->unref(); 216 paint.setShader(shader->newWithColorFilter(filter))->unref();
216 canvas->drawRect(r, paint); 217 canvas->drawRect(r, paint);
217 canvas->translate(150, 0); 218 canvas->translate(150, 0);
218 } 219 }
219 canvas->restore(); 220 canvas->restore();
220 canvas->translate(0, 150); 221 canvas->translate(0, 150);
221 } 222 }
222 } 223 }
OLDNEW
« no previous file with comments | « gm/coloremoji.cpp ('k') | gm/colorfilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698