| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 static const char* gFilterNames[] = { "point",
"bilinear" }; | 98 static const char* gFilterNames[] = { "point",
"bilinear" }; |
| 99 | 99 |
| 100 static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode,
SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode }; | 100 static const SkShader::TileMode gModes[] = { SkShader::kClamp_TileMode,
SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode }; |
| 101 static const char* gModeNames[] = { "C",
"R", "M" }; | 101 static const char* gModeNames[] = { "C",
"R", "M" }; |
| 102 | 102 |
| 103 SkScalar y = SkIntToScalar(24); | 103 SkScalar y = SkIntToScalar(24); |
| 104 SkScalar x = SkIntToScalar(10); | 104 SkScalar x = SkIntToScalar(10); |
| 105 | 105 |
| 106 SkPictureRecorder recorder; | 106 SkPictureRecorder recorder; |
| 107 SkCanvas* textCanvas = NULL; | 107 SkCanvas* textCanvas = NULL; |
| 108 if (fTextPicture->width() == 0) { | 108 if (NULL == fTextPicture) { |
| 109 textCanvas = recorder.beginRecording(1000, 1000); | 109 textCanvas = recorder.beginRecording(1000, 1000); |
| 110 } | 110 } |
| 111 | 111 |
| 112 if (NULL != textCanvas) { | 112 if (NULL != textCanvas) { |
| 113 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { | 113 for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { |
| 114 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { | 114 for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) { |
| 115 SkPaint p; | 115 SkPaint p; |
| 116 SkString str; | 116 SkString str; |
| 117 p.setAntiAlias(true); | 117 p.setAntiAlias(true); |
| 118 p.setDither(true); | 118 p.setDither(true); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 139 paint.setDither(true); | 139 paint.setDither(true); |
| 140 | 140 |
| 141 canvas->save(); | 141 canvas->save(); |
| 142 canvas->translate(x, y); | 142 canvas->translate(x, y); |
| 143 canvas->drawRect(r, paint); | 143 canvas->drawRect(r, paint); |
| 144 canvas->restore(); | 144 canvas->restore(); |
| 145 | 145 |
| 146 x += r.width() * 4 / 3; | 146 x += r.width() * 4 / 3; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 if (textCanvas) { | 149 if (NULL != textCanvas) { |
| 150 SkPaint p; | 150 SkPaint p; |
| 151 SkString str; | 151 SkString str; |
| 152 p.setAntiAlias(true); | 152 p.setAntiAlias(true); |
| 153 p.setLooper(fLooper); | 153 p.setLooper(fLooper); |
| 154 str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); | 154 str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); |
| 155 textCanvas->drawText(str.c_str(), str.size(), x, y + r.heigh
t() * 2 / 3, p); | 155 textCanvas->drawText(str.c_str(), str.size(), x, y + r.heigh
t() * 2 / 3, p); |
| 156 } | 156 } |
| 157 | 157 |
| 158 y += r.height() * 4 / 3; | 158 y += r.height() * 4 / 3; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 fTextPicture.reset(recorder.endRecording()); | 162 if (NULL != textCanvas) { |
| 163 SkASSERT(NULL == fTextPicture); |
| 164 fTextPicture.reset(recorder.endRecording()); |
| 165 } |
| 163 | 166 |
| 167 SkASSERT(NULL != fTextPicture); |
| 164 canvas->drawPicture(*fTextPicture); | 168 canvas->drawPicture(*fTextPicture); |
| 165 } | 169 } |
| 166 | 170 |
| 167 private: | 171 private: |
| 168 typedef SampleView INHERITED; | 172 typedef SampleView INHERITED; |
| 169 }; | 173 }; |
| 170 | 174 |
| 171 ////////////////////////////////////////////////////////////////////////////// | 175 ////////////////////////////////////////////////////////////////////////////// |
| 172 | 176 |
| 173 static SkView* MyFactory() { return new TilingView; } | 177 static SkView* MyFactory() { return new TilingView; } |
| 174 static SkViewRegister reg(MyFactory); | 178 static SkViewRegister reg(MyFactory); |
| OLD | NEW |