| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 SkISize onISize() override { | 82 SkISize onISize() override { |
| 83 return SkISize::Make(640, 480); | 83 return SkISize::Make(640, 480); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void onDraw(SkCanvas* canvas) override { | 86 void onDraw(SkCanvas* canvas) override { |
| 87 SkPaint p; | 87 SkPaint p; |
| 88 p.setStyle(SkPaint::kFill_Style); | 88 p.setStyle(SkPaint::kFill_Style); |
| 89 p.setShader(fShader); | 89 p.setShader(fShader); |
| 90 | 90 |
| 91 SkISize sz = this->onISize(); | 91 SkISize sz = this->onISize(); |
| 92 static const int kXCount = 4; | 92 constexpr int kXCount = 4; |
| 93 static const int kYCount = 3; | 93 constexpr int kYCount = 3; |
| 94 for (int i = 0; i < kXCount; ++i) { | 94 for (int i = 0; i < kXCount; ++i) { |
| 95 for (int j = 0; j < kYCount; ++j) { | 95 for (int j = 0; j < kYCount; ++j) { |
| 96 canvas->drawTextBlob(fBlob, | 96 canvas->drawTextBlob(fBlob, |
| 97 SkIntToScalar(i * sz.width() / kXCount), | 97 SkIntToScalar(i * sz.width() / kXCount), |
| 98 SkIntToScalar(j * sz.height() / kYCount), | 98 SkIntToScalar(j * sz.height() / kYCount), |
| 99 p); | 99 p); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 SkTDArray<uint16_t> fGlyphs; | 105 SkTDArray<uint16_t> fGlyphs; |
| 106 SkAutoTUnref<const SkTextBlob> fBlob; | 106 SkAutoTUnref<const SkTextBlob> fBlob; |
| 107 sk_sp<SkShader> fShader; | 107 sk_sp<SkShader> fShader; |
| 108 | 108 |
| 109 typedef skiagm::GM INHERITED; | 109 typedef skiagm::GM INHERITED; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 DEF_GM(return new TextBlobShaderGM("Blobber");) | 112 DEF_GM(return new TextBlobShaderGM("Blobber");) |
| OLD | NEW |