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

Side by Side Diff: example/HelloWorld.cpp

Issue 1798133003: Revert of Finish conversion to sk_sp<SkShader> (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
« no previous file with comments | « bench/TileBench.cpp ('k') | gyp/skia_for_android_framework_defines.gypi » ('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 * 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 9
10 #include "HelloWorld.h" 10 #include "HelloWorld.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 void HelloWorldWindow::drawContents(SkCanvas* canvas) { 88 void HelloWorldWindow::drawContents(SkCanvas* canvas) {
89 // Clear background 89 // Clear background
90 canvas->drawColor(SK_ColorWHITE); 90 canvas->drawColor(SK_ColorWHITE);
91 91
92 SkPaint paint; 92 SkPaint paint;
93 paint.setColor(SK_ColorRED); 93 paint.setColor(SK_ColorRED);
94 94
95 // Draw a rectangle with red paint 95 // Draw a rectangle with red paint
96 SkRect rect = SkRect::MakeXYWH(10, 10, 128, 128); 96 SkRect rect = {
97 10, 10,
98 128, 128
99 };
97 canvas->drawRect(rect, paint); 100 canvas->drawRect(rect, paint);
98 101
99 // Set up a linear gradient and draw a circle 102 // Set up a linear gradient and draw a circle
100 { 103 {
101 SkPoint linearPoints[] = { 104 SkPoint linearPoints[] = {
102 {0, 0}, 105 {0, 0},
103 {300, 300} 106 {300, 300}
104 }; 107 };
105 SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK}; 108 SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK};
106 109
107 paint.setShader(SkGradientShader::MakeLinear( 110 SkShader* shader = SkGradientShader::CreateLinear(
108 linearPoints, linearColors, nullptr, 2, 111 linearPoints, linearColors, NULL, 2,
109 SkShader::kMirror_TileMode)); 112 SkShader::kMirror_TileMode);
113 SkAutoUnref shader_deleter(shader);
114
115 paint.setShader(shader);
110 paint.setFlags(SkPaint::kAntiAlias_Flag); 116 paint.setFlags(SkPaint::kAntiAlias_Flag);
111 117
112 canvas->drawCircle(200, 200, 64, paint); 118 canvas->drawCircle(200, 200, 64, paint);
113 119
114 // Detach shader 120 // Detach shader
115 paint.setShader(nullptr); 121 paint.setShader(NULL);
116 } 122 }
117 123
118 // Draw a message with a nice black paint. 124 // Draw a message with a nice black paint.
119 paint.setFlags( 125 paint.setFlags(
120 SkPaint::kAntiAlias_Flag | 126 SkPaint::kAntiAlias_Flag |
121 SkPaint::kSubpixelText_Flag | // ... avoid waggly text when rotatin g. 127 SkPaint::kSubpixelText_Flag | // ... avoid waggly text when rotatin g.
122 SkPaint::kUnderlineText_Flag); 128 SkPaint::kUnderlineText_Flag);
123 paint.setColor(SK_ColorBLACK); 129 paint.setColor(SK_ColorBLACK);
124 paint.setTextSize(20); 130 paint.setTextSize(20);
125 131
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 setUpBackend(); 183 setUpBackend();
178 this->setTitle(); 184 this->setTitle();
179 this->inval(NULL); 185 this->inval(NULL);
180 } 186 }
181 return true; 187 return true;
182 } 188 }
183 189
184 SkOSWindow* create_sk_window(void* hwnd, int , char** ) { 190 SkOSWindow* create_sk_window(void* hwnd, int , char** ) {
185 return new HelloWorldWindow(hwnd); 191 return new HelloWorldWindow(hwnd);
186 } 192 }
OLDNEW
« no previous file with comments | « bench/TileBench.cpp ('k') | gyp/skia_for_android_framework_defines.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698