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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 public: | 133 public: |
134 TestLayer(SkColor c) : fColor(c) {} | 134 TestLayer(SkColor c) : fColor(c) {} |
135 | 135 |
136 protected: | 136 protected: |
137 virtual void onDraw(SkCanvas* canvas, SkScalar opacity) { | 137 virtual void onDraw(SkCanvas* canvas, SkScalar opacity) { |
138 SkRect r; | 138 SkRect r; |
139 r.set(0, 0, this->getWidth(), this->getHeight()); | 139 r.set(0, 0, this->getWidth(), this->getHeight()); |
140 | 140 |
141 SkPaint paint; | 141 SkPaint paint; |
142 paint.setColor(fColor); | 142 paint.setColor(fColor); |
143 paint.setAlpha(SkScalarRound(opacity * 255)); | 143 paint.setAlpha(SkScalarRoundToInt(opacity * 255)); |
144 | 144 |
145 canvas->drawRect(r, paint); | 145 canvas->drawRect(r, paint); |
146 } | 146 } |
147 | 147 |
148 private: | 148 private: |
149 SkColor fColor; | 149 SkColor fColor; |
150 }; | 150 }; |
151 | 151 |
152 class SkLayerView : public SkView { | 152 class SkLayerView : public SkView { |
153 private: | 153 private: |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 | 237 |
238 private: | 238 private: |
239 typedef SkView INHERITED; | 239 typedef SkView INHERITED; |
240 }; | 240 }; |
241 | 241 |
242 /////////////////////////////////////////////////////////////////////////////// | 242 /////////////////////////////////////////////////////////////////////////////// |
243 | 243 |
244 static SkView* MyFactory() { return new SkLayerView; } | 244 static SkView* MyFactory() { return new SkLayerView; } |
245 static SkViewRegister reg(MyFactory); | 245 static SkViewRegister reg(MyFactory); |
OLD | NEW |