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

Side by Side Diff: samplecode/SampleQuadStroker.cpp

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites 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 * 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SampleCode.h" 9 #include "SampleCode.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 enum { 102 enum {
103 kCount = 18 103 kCount = 18
104 }; 104 };
105 SkPoint fPts[kCount]; 105 SkPoint fPts[kCount];
106 SkRect fWeightControl; 106 SkRect fWeightControl;
107 SkRect fRadiusControl; 107 SkRect fRadiusControl;
108 SkRect fErrorControl; 108 SkRect fErrorControl;
109 SkRect fWidthControl; 109 SkRect fWidthControl;
110 SkRect fBounds; 110 SkRect fBounds;
111 SkMatrix fMatrix, fInverse; 111 SkMatrix fMatrix, fInverse;
112 SkAutoTUnref<SkShader> fShader; 112 sk_sp<SkShader> fShader;
113 SkAutoTUnref<SkSurface> fMinSurface; 113 SkAutoTUnref<SkSurface> fMinSurface;
114 SkAutoTUnref<SkSurface> fMaxSurface; 114 SkAutoTUnref<SkSurface> fMaxSurface;
115 StrokeTypeButton fCubicButton; 115 StrokeTypeButton fCubicButton;
116 StrokeTypeButton fConicButton; 116 StrokeTypeButton fConicButton;
117 StrokeTypeButton fQuadButton; 117 StrokeTypeButton fQuadButton;
118 StrokeTypeButton fArcButton; 118 StrokeTypeButton fArcButton;
119 StrokeTypeButton fRRectButton; 119 StrokeTypeButton fRRectButton;
120 CircleTypeButton fCircleButton; 120 CircleTypeButton fCircleButton;
121 StrokeTypeButton fTextButton; 121 StrokeTypeButton fTextButton;
122 SkString fText; 122 SkString fText;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 SkScalar x = SkIntToScalar(ix * fZoom); 257 SkScalar x = SkIntToScalar(ix * fZoom);
258 canvas->drawLine(x - SK_ScalarHalf, 0, x - SK_ScalarHalf, 999, paint ); 258 canvas->drawLine(x - SK_ScalarHalf, 0, x - SK_ScalarHalf, 999, paint );
259 } 259 }
260 } 260 }
261 261
262 void setWHZ(int width, int height, int zoom) { 262 void setWHZ(int width, int height, int zoom) {
263 fZoom = zoom; 263 fZoom = zoom;
264 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo om)); 264 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo om));
265 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); 265 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
266 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); 266 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
267 fShader.reset(sk_tool_utils::create_checkerboard_shader( 267 fShader = sk_tool_utils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFF FF, zoom);
268 0xFFCCCCCC, 0xFFFFFFFF, zoom));
269 268
270 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 269 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
271 fMinSurface.reset(SkSurface::NewRaster(info)); 270 fMinSurface.reset(SkSurface::NewRaster(info));
272 info = info.makeWH(width * zoom, height * zoom); 271 info = info.makeWH(width * zoom, height * zoom);
273 fMaxSurface.reset(SkSurface::NewRaster(info)); 272 fMaxSurface.reset(SkSurface::NewRaster(info));
274 } 273 }
275 274
276 void draw_points(SkCanvas* canvas, const SkPath& path, SkColor color, 275 void draw_points(SkCanvas* canvas, const SkPath& path, SkColor color,
277 bool show_lines) { 276 bool show_lines) {
278 SkPaint paint; 277 SkPaint paint;
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 792 }
794 793
795 private: 794 private:
796 typedef SkView INHERITED; 795 typedef SkView INHERITED;
797 }; 796 };
798 797
799 /////////////////////////////////////////////////////////////////////////////// 798 ///////////////////////////////////////////////////////////////////////////////
800 799
801 static SkView* F2() { return new QuadStrokerView; } 800 static SkView* F2() { return new QuadStrokerView; }
802 static SkViewRegister gR2(F2); 801 static SkViewRegister gR2(F2);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698