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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 static const bool gFilters[] = { false, true }; | 90 static const bool gFilters[] = { false, true }; |
91 static const char* gFilterNames[] = { "point",
"bilinear" }; | 91 static const char* gFilterNames[] = { "point",
"bilinear" }; |
92 | 92 |
93 static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode,
SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode }; | 93 static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode,
SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode }; |
94 static const char* gModeNames[] = { "C",
"R", "M" }; | 94 static const char* gModeNames[] = { "C",
"R", "M" }; |
95 | 95 |
96 SkScalar y = SkIntToScalar(24); | 96 SkScalar y = SkIntToScalar(24); |
97 SkScalar x = SkIntToScalar(10); | 97 SkScalar x = SkIntToScalar(10); |
98 | 98 |
99 SkPictureRecorder recorder; | 99 SkPictureRecorder recorder; |
100 SkCanvas* textCanvas = NULL; | 100 SkCanvas* textCanvas = nullptr; |
101 if (NULL == fTextPicture) { | 101 if (nullptr == fTextPicture) { |
102 textCanvas = recorder.beginRecording(1000, 1000, NULL, 0); | 102 textCanvas = recorder.beginRecording(1000, 1000, nullptr, 0); |
103 } | 103 } |
104 | 104 |
105 if (textCanvas) { | 105 if (textCanvas) { |
106 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { | 106 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { |
107 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { | 107 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { |
108 SkPaint p; | 108 SkPaint p; |
109 SkString str; | 109 SkString str; |
110 p.setAntiAlias(true); | 110 p.setAntiAlias(true); |
111 p.setDither(true); | 111 p.setDither(true); |
112 p.setLooper(fLooper); | 112 p.setLooper(fLooper); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 p.setLooper(fLooper); | 146 p.setLooper(fLooper); |
147 str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); | 147 str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); |
148 textCanvas->drawText(str.c_str(), str.size(), x, y + r.heigh
t() * 2 / 3, p); | 148 textCanvas->drawText(str.c_str(), str.size(), x, y + r.heigh
t() * 2 / 3, p); |
149 } | 149 } |
150 | 150 |
151 y += r.height() * 4 / 3; | 151 y += r.height() * 4 / 3; |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 if (textCanvas) { | 155 if (textCanvas) { |
156 SkASSERT(NULL == fTextPicture); | 156 SkASSERT(nullptr == fTextPicture); |
157 fTextPicture.reset(recorder.endRecording()); | 157 fTextPicture.reset(recorder.endRecording()); |
158 } | 158 } |
159 | 159 |
160 SkASSERT(fTextPicture); | 160 SkASSERT(fTextPicture); |
161 canvas->drawPicture(fTextPicture); | 161 canvas->drawPicture(fTextPicture); |
162 } | 162 } |
163 | 163 |
164 private: | 164 private: |
165 typedef SampleView INHERITED; | 165 typedef SampleView INHERITED; |
166 }; | 166 }; |
167 | 167 |
168 ////////////////////////////////////////////////////////////////////////////// | 168 ////////////////////////////////////////////////////////////////////////////// |
169 | 169 |
170 static SkView* MyFactory() { return new TilingView; } | 170 static SkView* MyFactory() { return new TilingView; } |
171 static SkViewRegister reg(MyFactory); | 171 static SkViewRegister reg(MyFactory); |
OLD | NEW |