OLD | NEW |
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 Loading... |
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 = { | 96 SkRect rect = SkRect::MakeXYWH(10, 10, 128, 128); |
97 10, 10, | |
98 128, 128 | |
99 }; | |
100 canvas->drawRect(rect, paint); | 97 canvas->drawRect(rect, paint); |
101 | 98 |
102 // Set up a linear gradient and draw a circle | 99 // Set up a linear gradient and draw a circle |
103 { | 100 { |
104 SkPoint linearPoints[] = { | 101 SkPoint linearPoints[] = { |
105 {0, 0}, | 102 {0, 0}, |
106 {300, 300} | 103 {300, 300} |
107 }; | 104 }; |
108 SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK}; | 105 SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK}; |
109 | 106 |
110 SkShader* shader = SkGradientShader::CreateLinear( | 107 paint.setShader(SkGradientShader::MakeLinear( |
111 linearPoints, linearColors, NULL, 2, | 108 linearPoints, linearColors, nullptr, 2, |
112 SkShader::kMirror_TileMode); | 109 SkShader::kMirror_TileMode)); |
113 SkAutoUnref shader_deleter(shader); | |
114 | |
115 paint.setShader(shader); | |
116 paint.setFlags(SkPaint::kAntiAlias_Flag); | 110 paint.setFlags(SkPaint::kAntiAlias_Flag); |
117 | 111 |
118 canvas->drawCircle(200, 200, 64, paint); | 112 canvas->drawCircle(200, 200, 64, paint); |
119 | 113 |
120 // Detach shader | 114 // Detach shader |
121 paint.setShader(NULL); | 115 paint.setShader(nullptr); |
122 } | 116 } |
123 | 117 |
124 // Draw a message with a nice black paint. | 118 // Draw a message with a nice black paint. |
125 paint.setFlags( | 119 paint.setFlags( |
126 SkPaint::kAntiAlias_Flag | | 120 SkPaint::kAntiAlias_Flag | |
127 SkPaint::kSubpixelText_Flag | // ... avoid waggly text when rotatin
g. | 121 SkPaint::kSubpixelText_Flag | // ... avoid waggly text when rotatin
g. |
128 SkPaint::kUnderlineText_Flag); | 122 SkPaint::kUnderlineText_Flag); |
129 paint.setColor(SK_ColorBLACK); | 123 paint.setColor(SK_ColorBLACK); |
130 paint.setTextSize(20); | 124 paint.setTextSize(20); |
131 | 125 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 setUpBackend(); | 177 setUpBackend(); |
184 this->setTitle(); | 178 this->setTitle(); |
185 this->inval(NULL); | 179 this->inval(NULL); |
186 } | 180 } |
187 return true; | 181 return true; |
188 } | 182 } |
189 | 183 |
190 SkOSWindow* create_sk_window(void* hwnd, int , char** ) { | 184 SkOSWindow* create_sk_window(void* hwnd, int , char** ) { |
191 return new HelloWorldWindow(hwnd); | 185 return new HelloWorldWindow(hwnd); |
192 } | 186 } |
OLD | NEW |