OLD | NEW |
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 "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 shaderA->unref(); | 76 shaderA->unref(); |
77 shaderB->unref(); | 77 shaderB->unref(); |
78 mode->unref(); | 78 mode->unref(); |
79 } | 79 } |
80 virtual ~ShaderView() { | 80 virtual ~ShaderView() { |
81 SkSafeUnref(fShader); | 81 SkSafeUnref(fShader); |
82 } | 82 } |
83 | 83 |
84 protected: | 84 protected: |
85 // overrides from SkEventSink | 85 // overrides from SkEventSink |
86 virtual bool onQuery(SkEvent* evt) SK_OVERRIDE { | 86 bool onQuery(SkEvent* evt) SK_OVERRIDE { |
87 if (SampleCode::TitleQ(*evt)) { | 87 if (SampleCode::TitleQ(*evt)) { |
88 SampleCode::TitleR(evt, "Shaders"); | 88 SampleCode::TitleR(evt, "Shaders"); |
89 return true; | 89 return true; |
90 } | 90 } |
91 return this->INHERITED::onQuery(evt); | 91 return this->INHERITED::onQuery(evt); |
92 } | 92 } |
93 | 93 |
94 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 94 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { |
95 canvas->drawBitmap(fBitmap, 0, 0); | 95 canvas->drawBitmap(fBitmap, 0, 0); |
96 | 96 |
97 canvas->translate(SkIntToScalar(20), SkIntToScalar(120)); | 97 canvas->translate(SkIntToScalar(20), SkIntToScalar(120)); |
98 | 98 |
99 SkPaint paint; | 99 SkPaint paint; |
100 SkRect r; | 100 SkRect r; |
101 | 101 |
102 paint.setColor(SK_ColorGREEN); | 102 paint.setColor(SK_ColorGREEN); |
103 canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), pai
nt); | 103 canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), pai
nt); |
104 paint.setShader(fShader); | 104 paint.setShader(fShader); |
(...skipping 15 matching lines...) Expand all Loading... |
120 paint.setShader(new SkTransparentShader)->unref(); | 120 paint.setShader(new SkTransparentShader)->unref(); |
121 canvas->drawRect(r, paint); | 121 canvas->drawRect(r, paint); |
122 } | 122 } |
123 | 123 |
124 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, | 124 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, |
125 unsigned modi) SK_OVERRIDE { | 125 unsigned modi) SK_OVERRIDE { |
126 this->inval(NULL); | 126 this->inval(NULL); |
127 return this->INHERITED::onFindClickHandler(x, y, modi); | 127 return this->INHERITED::onFindClickHandler(x, y, modi); |
128 } | 128 } |
129 | 129 |
130 virtual bool onClick(Click* click) SK_OVERRIDE { | 130 bool onClick(Click* click) SK_OVERRIDE { |
131 return this->INHERITED::onClick(click); | 131 return this->INHERITED::onClick(click); |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 typedef SampleView INHERITED; | 135 typedef SampleView INHERITED; |
136 }; | 136 }; |
137 | 137 |
138 ////////////////////////////////////////////////////////////////////////////// | 138 ////////////////////////////////////////////////////////////////////////////// |
139 | 139 |
140 static SkView* MyFactory() { return new ShaderView; } | 140 static SkView* MyFactory() { return new ShaderView; } |
141 static SkViewRegister reg(MyFactory); | 141 static SkViewRegister reg(MyFactory); |
OLD | NEW |