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 "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 pictureSize * 2 / 3, pictureSize / 2, paint); | 76 pictureSize * 2 / 3, pictureSize / 2, paint); |
77 | 77 |
78 paint.setColor(SK_ColorBLACK); | 78 paint.setColor(SK_ColorBLACK); |
79 paint.setStyle(SkPaint::kStroke_Style); | 79 paint.setStyle(SkPaint::kStroke_Style); |
80 canvas->drawRect(SkRect::MakeWH(pictureSize, pictureSize), paint); | 80 canvas->drawRect(SkRect::MakeWH(pictureSize, pictureSize), paint); |
81 } | 81 } |
82 | 82 |
83 class PictureShaderTileGM : public skiagm::GM { | 83 class PictureShaderTileGM : public skiagm::GM { |
84 protected: | 84 protected: |
85 | 85 |
86 SkString onShortName() SK_OVERRIDE { | 86 SkString onShortName() override { |
87 return SkString("pictureshadertile"); | 87 return SkString("pictureshadertile"); |
88 } | 88 } |
89 | 89 |
90 SkISize onISize() SK_OVERRIDE { | 90 SkISize onISize() override { |
91 return SkISize::Make(800, 600); | 91 return SkISize::Make(800, 600); |
92 } | 92 } |
93 | 93 |
94 void onOnceBeforeDraw() SK_OVERRIDE { | 94 void onOnceBeforeDraw() override { |
95 SkPictureRecorder recorder; | 95 SkPictureRecorder recorder; |
96 SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPicture
Size); | 96 SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPicture
Size); |
97 draw_scene(pictureCanvas, kPictureSize); | 97 draw_scene(pictureCanvas, kPictureSize); |
98 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 98 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
99 | 99 |
100 SkPoint offset = SkPoint::Make(100, 100); | 100 SkPoint offset = SkPoint::Make(100, 100); |
101 pictureCanvas = recorder.beginRecording(SkRect::MakeXYWH(offset.x(), off
set.y(), | 101 pictureCanvas = recorder.beginRecording(SkRect::MakeXYWH(offset.x(), off
set.y(), |
102 kPictureSize, k
PictureSize)); | 102 kPictureSize, k
PictureSize)); |
103 pictureCanvas->translate(offset.x(), offset.y()); | 103 pictureCanvas->translate(offset.x(), offset.y()); |
104 draw_scene(pictureCanvas, kPictureSize); | 104 draw_scene(pictureCanvas, kPictureSize); |
(...skipping 20 matching lines...) Expand all Loading... |
125 } | 125 } |
126 | 126 |
127 fShaders[i].reset(SkShader::CreatePictureShader(picturePtr, | 127 fShaders[i].reset(SkShader::CreatePictureShader(picturePtr, |
128 SkShader::kRepeat_Ti
leMode, | 128 SkShader::kRepeat_Ti
leMode, |
129 SkShader::kRepeat_Ti
leMode, | 129 SkShader::kRepeat_Ti
leMode, |
130 &localMatrix, | 130 &localMatrix, |
131 tilePtr)); | 131 tilePtr)); |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 135 void onDraw(SkCanvas* canvas) override { |
136 canvas->clear(SK_ColorBLACK); | 136 canvas->clear(SK_ColorBLACK); |
137 | 137 |
138 SkPaint paint; | 138 SkPaint paint; |
139 paint.setStyle(SkPaint::kFill_Style); | 139 paint.setStyle(SkPaint::kFill_Style); |
140 | 140 |
141 for (unsigned i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { | 141 for (unsigned i = 0; i < SK_ARRAY_COUNT(fShaders); ++i) { |
142 paint.setShader(fShaders[i]); | 142 paint.setShader(fShaders[i]); |
143 | 143 |
144 canvas->save(); | 144 canvas->save(); |
145 canvas->translate((i % kRowSize) * kFillSize * 1.1f, | 145 canvas->translate((i % kRowSize) * kFillSize * 1.1f, |
146 (i / kRowSize) * kFillSize * 1.1f); | 146 (i / kRowSize) * kFillSize * 1.1f); |
147 canvas->drawRect(SkRect::MakeWH(kFillSize, kFillSize), paint); | 147 canvas->drawRect(SkRect::MakeWH(kFillSize, kFillSize), paint); |
148 canvas->restore(); | 148 canvas->restore(); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 private: | 152 private: |
153 SkAutoTUnref<SkShader> fShaders[SK_ARRAY_COUNT(tiles)]; | 153 SkAutoTUnref<SkShader> fShaders[SK_ARRAY_COUNT(tiles)]; |
154 | 154 |
155 typedef GM INHERITED; | 155 typedef GM INHERITED; |
156 }; | 156 }; |
157 | 157 |
158 DEF_GM( return SkNEW(PictureShaderTileGM); ) | 158 DEF_GM( return SkNEW(PictureShaderTileGM); ) |
OLD | NEW |