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

Side by Side Diff: experimental/SkiaExamples/HelloSkiaExample.cpp

Issue 287063009: Revert of remove unused (by clients) SkUnitMapper (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | experimental/webtry/templates/template.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 2013 Google Inc. 2 * Copyright 2013 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 "SkExample.h" 10 #include "SkExample.h"
11 11
12 #include "SkApplication.h" 12 #include "SkApplication.h"
13 #include "SkDraw.h" 13 #include "SkDraw.h"
14 #include "SkGradientShader.h" 14 #include "SkGradientShader.h"
15 #include "SkGraphics.h" 15 #include "SkGraphics.h"
16 #include "SkUnitMappers.h"
16 17
17 class HelloSkia : public SkExample { 18 class HelloSkia : public SkExample {
18 public: 19 public:
19 HelloSkia(SkExampleWindow* window) : SkExample(window) { 20 HelloSkia(SkExampleWindow* window) : SkExample(window) {
20 fName = "HelloSkia"; 21 fName = "HelloSkia";
21 fBGColor = SK_ColorWHITE; 22 fBGColor = SK_ColorWHITE;
22 fRotationAngle = SkIntToScalar(0); 23 fRotationAngle = SkIntToScalar(0);
23 24
24 fWindow->setupBackend(SkExampleWindow::kGPU_DeviceType); 25 fWindow->setupBackend(SkExampleWindow::kGPU_DeviceType);
25 // Another option is software rendering: 26 // Another option is software rendering:
(...skipping 16 matching lines...) Expand all
42 canvas->drawRect(rect, paint); 43 canvas->drawRect(rect, paint);
43 44
44 // Set up a linear gradient and draw a circle 45 // Set up a linear gradient and draw a circle
45 { 46 {
46 SkPoint linearPoints[] = { 47 SkPoint linearPoints[] = {
47 {SkIntToScalar(0), SkIntToScalar(0)}, 48 {SkIntToScalar(0), SkIntToScalar(0)},
48 {SkIntToScalar(300), SkIntToScalar(300)} 49 {SkIntToScalar(300), SkIntToScalar(300)}
49 }; 50 };
50 SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK}; 51 SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK};
51 52
53 SkUnitMapper* linearMapper = new SkDiscreteMapper(100);
54 SkAutoUnref lm_deleter(linearMapper);
55
52 SkShader* shader = SkGradientShader::CreateLinear( 56 SkShader* shader = SkGradientShader::CreateLinear(
53 linearPoints, linearColors, NULL, 2, 57 linearPoints, linearColors, NULL, 2,
54 SkShader::kMirror_TileMode); 58 SkShader::kMirror_TileMode, linearMapper);
55 SkAutoUnref shader_deleter(shader); 59 SkAutoUnref shader_deleter(shader);
56 60
57 paint.setShader(shader); 61 paint.setShader(shader);
58 paint.setFlags(SkPaint::kAntiAlias_Flag); 62 paint.setFlags(SkPaint::kAntiAlias_Flag);
59 63
60 canvas->drawCircle(SkIntToScalar(200), SkIntToScalar(200), 64 canvas->drawCircle(SkIntToScalar(200), SkIntToScalar(200),
61 SkIntToScalar(64), paint); 65 SkIntToScalar(64), paint);
62 66
63 // Detach shader 67 // Detach shader
64 paint.setShader(NULL); 68 paint.setShader(NULL);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 SkScalar fRotationAngle; 101 SkScalar fRotationAngle;
98 SkColor fBGColor; 102 SkColor fBGColor;
99 }; 103 };
100 104
101 static SkExample* MyFactory(SkExampleWindow* window) { 105 static SkExample* MyFactory(SkExampleWindow* window) {
102 return new HelloSkia(window); 106 return new HelloSkia(window);
103 } 107 }
104 108
105 // Register this class as a Skia Example. 109 // Register this class as a Skia Example.
106 SkExample::Registry registry(MyFactory); 110 SkExample::Registry registry(MyFactory);
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | experimental/webtry/templates/template.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698