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

Side by Side Diff: gm/patch.cpp

Issue 1789633002: more shader-->sp conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "gm.h" 9 #include "gm.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
11 #include "SkPatchUtils.h" 11 #include "SkPatchUtils.h"
12 12
13 static SkShader* make_shader() { 13 static sk_sp<SkShader> make_shader() {
14 const SkColor colors[] = { 14 const SkColor colors[] = {
15 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, SK_ColorMAGENTA , SK_ColorBLUE, 15 SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, SK_ColorMAGENTA , SK_ColorBLUE,
16 SK_ColorYELLOW, 16 SK_ColorYELLOW,
17 }; 17 };
18 const SkPoint pts[] = { { 100.f / 4.f, 0.f }, { 3.f * 100.f / 4.f, 100.f } } ; 18 const SkPoint pts[] = { { 100.f / 4.f, 0.f }, { 3.f * 100.f / 4.f, 100.f } } ;
19 19
20 return SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(c olors), 20 return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(col ors),
21 SkShader::kMirror_TileMode); 21 SkShader::kMirror_TileMode);
22 } 22 }
23 23
24 static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) { 24 static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) {
25 //draw control points 25 //draw control points
26 SkPaint paint; 26 SkPaint paint;
27 SkPoint bottom[SkPatchUtils::kNumPtsCubic]; 27 SkPoint bottom[SkPatchUtils::kNumPtsCubic];
28 SkPatchUtils::getBottomCubic(cubics, bottom); 28 SkPatchUtils::getBottomCubic(cubics, bottom);
29 SkPoint top[SkPatchUtils::kNumPtsCubic]; 29 SkPoint top[SkPatchUtils::kNumPtsCubic];
30 SkPatchUtils::getTopCubic(cubics, top); 30 SkPatchUtils::getTopCubic(cubics, top);
31 SkPoint left[SkPatchUtils::kNumPtsCubic]; 31 SkPoint left[SkPatchUtils::kNumPtsCubic];
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const SkPoint texCoords[SkPatchUtils::kNumCorners] = { 85 const SkPoint texCoords[SkPatchUtils::kNumCorners] = {
86 {0.0f, 0.0f}, {100.0f, 0.0f}, {100.0f,100.0f}, {0.0f, 100.0f}} 86 {0.0f, 0.0f}, {100.0f, 0.0f}, {100.0f,100.0f}, {0.0f, 100.0f}}
87 ; 87 ;
88 88
89 const SkXfermode::Mode modes[] = { 89 const SkXfermode::Mode modes[] = {
90 SkXfermode::kSrc_Mode, 90 SkXfermode::kSrc_Mode,
91 SkXfermode::kDst_Mode, 91 SkXfermode::kDst_Mode,
92 SkXfermode::kModulate_Mode, 92 SkXfermode::kModulate_Mode,
93 }; 93 };
94 94
95 SkAutoTUnref<SkShader> shader(make_shader()); 95 sk_sp<SkShader> shader(make_shader());
96 96
97 canvas->save(); 97 canvas->save();
98 for (int y = 0; y < 3; y++) { 98 for (int y = 0; y < 3; y++) {
99 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(modes[y])); 99 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(modes[y]));
100 100
101 for (int x = 0; x < 4; x++) { 101 for (int x = 0; x < 4; x++) {
102 canvas->save(); 102 canvas->save();
103 canvas->translate(x * 350.0f, y * 350.0f); 103 canvas->translate(x * 350.0f, y * 350.0f);
104 switch (x) { 104 switch (x) {
105 case 0: 105 case 0:
(...skipping 15 matching lines...) Expand all
121 default: 121 default:
122 break; 122 break;
123 } 123 }
124 124
125 draw_control_points(canvas, cubics); 125 draw_control_points(canvas, cubics);
126 canvas->restore(); 126 canvas->restore();
127 } 127 }
128 } 128 }
129 canvas->restore(); 129 canvas->restore();
130 } 130 }
OLDNEW
« no previous file with comments | « gm/ovals.cpp ('k') | gm/perspshaders.cpp » ('j') | gm/pictureshadertile.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698