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

Side by Side Diff: samplecode/SampleTextAlpha.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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 | « samplecode/SampleText.cpp ('k') | samplecode/SampleTextOnPath.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 18 matching lines...) Expand all
29 #include "SkStream.h" 29 #include "SkStream.h"
30 30
31 class TextAlphaView : public SampleView { 31 class TextAlphaView : public SampleView {
32 public: 32 public:
33 TextAlphaView() { 33 TextAlphaView() {
34 fByte = 0xFF; 34 fByte = 0xFF;
35 } 35 }
36 36
37 protected: 37 protected:
38 // overrides from SkEventSink 38 // overrides from SkEventSink
39 virtual bool onQuery(SkEvent* evt) SK_OVERRIDE { 39 bool onQuery(SkEvent* evt) SK_OVERRIDE {
40 if (SampleCode::TitleQ(*evt)) { 40 if (SampleCode::TitleQ(*evt)) {
41 SampleCode::TitleR(evt, "TextAlpha"); 41 SampleCode::TitleR(evt, "TextAlpha");
42 return true; 42 return true;
43 } 43 }
44 return this->INHERITED::onQuery(evt); 44 return this->INHERITED::onQuery(evt);
45 } 45 }
46 46
47 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { 47 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE {
48 const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 48 const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
49 SkPaint paint; 49 SkPaint paint;
50 SkScalar x = SkIntToScalar(10); 50 SkScalar x = SkIntToScalar(10);
51 SkScalar y = SkIntToScalar(20); 51 SkScalar y = SkIntToScalar(20);
52 52
53 paint.setFlags(0x105); 53 paint.setFlags(0x105);
54 54
55 paint.setARGB(fByte, 0xFF, 0xFF, 0xFF); 55 paint.setARGB(fByte, 0xFF, 0xFF, 0xFF);
56 56
57 paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, 57 paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
58 SkBlurMask::ConvertRadiusToSigma(SkIntToScal ar(3)))); 58 SkBlurMask::ConvertRadiusToSigma(SkIntToScal ar(3))));
59 paint.getMaskFilter()->unref(); 59 paint.getMaskFilter()->unref();
60 60
61 SkRandom rand; 61 SkRandom rand;
62 62
63 for (int ps = 6; ps <= 35; ps++) { 63 for (int ps = 6; ps <= 35; ps++) {
64 paint.setColor(rand.nextU() | (0xFF << 24)); 64 paint.setColor(rand.nextU() | (0xFF << 24));
65 paint.setTextSize(SkIntToScalar(ps)); 65 paint.setTextSize(SkIntToScalar(ps));
66 paint.setTextSize(SkIntToScalar(24)); 66 paint.setTextSize(SkIntToScalar(24));
67 canvas->drawText(str, strlen(str), x, y, paint); 67 canvas->drawText(str, strlen(str), x, y, paint);
68 y += paint.getFontMetrics(NULL); 68 y += paint.getFontMetrics(NULL);
69 } 69 }
70 } 70 }
71 71
72 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) SK_OVERRIDE { 72 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) SK_OVERR IDE {
73 return new Click(this); 73 return new Click(this);
74 } 74 }
75 75
76 virtual bool onClick(Click* click) SK_OVERRIDE { 76 bool onClick(Click* click) SK_OVERRIDE {
77 int y = click->fICurr.fY; 77 int y = click->fICurr.fY;
78 if (y < 0) { 78 if (y < 0) {
79 y = 0; 79 y = 0;
80 } else if (y > 255) { 80 } else if (y > 255) {
81 y = 255; 81 y = 255;
82 } 82 }
83 fByte = y; 83 fByte = y;
84 this->inval(NULL); 84 this->inval(NULL);
85 return true; 85 return true;
86 } 86 }
87 87
88 private: 88 private:
89 int fByte; 89 int fByte;
90 90
91 typedef SampleView INHERITED; 91 typedef SampleView INHERITED;
92 }; 92 };
93 93
94 ////////////////////////////////////////////////////////////////////////////// 94 //////////////////////////////////////////////////////////////////////////////
95 95
96 static SkView* MyFactory() { return new TextAlphaView; } 96 static SkView* MyFactory() { return new TextAlphaView; }
97 static SkViewRegister reg(MyFactory); 97 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleText.cpp ('k') | samplecode/SampleTextOnPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698