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

Side by Side Diff: gm/perspshaders.cpp

Issue 1793303002: Reland of "more shader-->sp conversions (patchset #5 id:80001 of https://codereview.chromium… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: make pictureRef a value, so its clearer what's going on 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/patch.cpp ('k') | gm/pictureimagegenerator.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 2015 Google Inc. 2 * Copyright 2015 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 "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkImage.h" 10 #include "SkImage.h"
(...skipping 28 matching lines...) Expand all
39 39
40 SkISize onISize() override { 40 SkISize onISize() override {
41 return SkISize::Make(kCellSize*kNumCols, kCellSize*kNumRows); 41 return SkISize::Make(kCellSize*kNumCols, kCellSize*kNumRows);
42 } 42 }
43 43
44 void onOnceBeforeDraw() override { 44 void onOnceBeforeDraw() override {
45 fBitmap = sk_tool_utils::create_checkerboard_bitmap(kCellSize, kCellSize , 45 fBitmap = sk_tool_utils::create_checkerboard_bitmap(kCellSize, kCellSize ,
46 SK_ColorBLUE, SK_Col orYELLOW, 46 SK_ColorBLUE, SK_Col orYELLOW,
47 kCellSize/10); 47 kCellSize/10);
48 48
49 fBitmapShader.reset(SkShader::CreateBitmapShader(fBitmap, 49 fBitmapShader = SkShader::MakeBitmapShader(fBitmap, SkShader::kClamp_Til eMode,
50 SkShader::kClamp_TileMo de, 50 SkShader::kClamp_TileMode);
51 SkShader::kClamp_TileMo de));
52 SkPoint pts1[] = { 51 SkPoint pts1[] = {
53 { 0, 0 }, 52 { 0, 0 },
54 { SkIntToScalar(kCellSize), SkIntToScalar(kCellSize) } 53 { SkIntToScalar(kCellSize), SkIntToScalar(kCellSize) }
55 }; 54 };
56 SkPoint pts2[] = { 55 SkPoint pts2[] = {
57 { 0, 0 }, 56 { 0, 0 },
58 { 0, SkIntToScalar(kCellSize) } 57 { 0, SkIntToScalar(kCellSize) }
59 }; 58 };
60 static const SkColor colors[] = { 59 static const SkColor colors[] = {
61 SK_ColorRED, SK_ColorGREEN, SK_ColorRED, SK_ColorGREEN, SK_ColorRED 60 SK_ColorRED, SK_ColorGREEN, SK_ColorRED, SK_ColorGREEN, SK_ColorRED
62 }; 61 };
63 static const SkScalar pos[] = { 0, 0.25f, 0.5f, 0.75f, SK_Scalar1 }; 62 static const SkScalar pos[] = { 0, 0.25f, 0.5f, 0.75f, SK_Scalar1 };
64 63
65 fLinearGrad1.reset(SkGradientShader::CreateLinear(pts1, colors, pos, 64 fLinearGrad1 = SkGradientShader::MakeLinear(pts1, colors, pos, SK_ARRAY_ COUNT(colors),
66 SK_ARRAY_COUNT(colors) , 65 SkShader::kClamp_TileMode);
67 SkShader::kClamp_TileM ode)); 66 fLinearGrad2 = SkGradientShader::MakeLinear(pts2, colors, pos, SK_ARRAY_ COUNT(colors),
68 fLinearGrad2.reset(SkGradientShader::CreateLinear(pts2, colors, pos, 67 SkShader::kClamp_TileMode);
69 SK_ARRAY_COUNT(colors) ,
70 SkShader::kClamp_TileM ode));
71 68
72 fPerspMatrix.reset(); 69 fPerspMatrix.reset();
73 fPerspMatrix.setPerspY(SK_Scalar1 / 50); 70 fPerspMatrix.setPerspY(SK_Scalar1 / 50);
74 71
75 fPath.moveTo(0, 0); 72 fPath.moveTo(0, 0);
76 fPath.lineTo(0, SkIntToScalar(kCellSize)); 73 fPath.lineTo(0, SkIntToScalar(kCellSize));
77 fPath.lineTo(kCellSize/2.0f, kCellSize/2.0f); 74 fPath.lineTo(kCellSize/2.0f, kCellSize/2.0f);
78 fPath.lineTo(SkIntToScalar(kCellSize), SkIntToScalar(kCellSize)); 75 fPath.lineTo(SkIntToScalar(kCellSize), SkIntToScalar(kCellSize));
79 fPath.lineTo(SkIntToScalar(kCellSize), 0); 76 fPath.lineTo(SkIntToScalar(kCellSize), 0);
80 fPath.close(); 77 fPath.close();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 this->drawRow(canvas, kHigh_SkFilterQuality); 150 this->drawRow(canvas, kHigh_SkFilterQuality);
154 canvas->translate(0, SkIntToScalar(kCellSize)); 151 canvas->translate(0, SkIntToScalar(kCellSize));
155 } 152 }
156 private: 153 private:
157 static const int kCellSize = 50; 154 static const int kCellSize = 50;
158 static const int kNumRows = 4; 155 static const int kNumRows = 4;
159 static const int kNumCols = 6; 156 static const int kNumCols = 6;
160 157
161 bool fDoAA; 158 bool fDoAA;
162 SkPath fPath; 159 SkPath fPath;
163 SkAutoTUnref<SkShader> fBitmapShader; 160 sk_sp<SkShader> fBitmapShader;
164 SkAutoTUnref<SkShader> fLinearGrad1; 161 sk_sp<SkShader> fLinearGrad1;
165 SkAutoTUnref<SkShader> fLinearGrad2; 162 sk_sp<SkShader> fLinearGrad2;
166 SkMatrix fPerspMatrix; 163 SkMatrix fPerspMatrix;
167 SkAutoTUnref<SkImage> fImage; 164 SkAutoTUnref<SkImage> fImage;
168 SkBitmap fBitmap; 165 SkBitmap fBitmap;
169 166
170 typedef GM INHERITED; 167 typedef GM INHERITED;
171 }; 168 };
172 169
173 ////////////////////////////////////////////////////////////////////////////// 170 //////////////////////////////////////////////////////////////////////////////
174 171
175 DEF_GM(return new PerspShadersGM(true);) 172 DEF_GM(return new PerspShadersGM(true);)
176 DEF_GM(return new PerspShadersGM(false);) 173 DEF_GM(return new PerspShadersGM(false);)
177 } 174 }
OLDNEW
« no previous file with comments | « gm/patch.cpp ('k') | gm/pictureimagegenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698