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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 88 } |
89 | 89 |
90 SkISize onISize() override { | 90 SkISize onISize() override { |
91 return SkISize::Make(800, 600); | 91 return SkISize::Make(800, 600); |
92 } | 92 } |
93 | 93 |
94 void onOnceBeforeDraw() 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 sk_sp<SkPicture> picture(recorder.endRecording()); | 98 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); |
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); |
105 sk_sp<SkPicture> offsetPicture(recorder.endRecording()); | 105 sk_sp<SkPicture> offsetPicture(recorder.finishRecordingAsPicture()); |
106 | 106 |
107 for (unsigned i = 0; i < SK_ARRAY_COUNT(tiles); ++i) { | 107 for (unsigned i = 0; i < SK_ARRAY_COUNT(tiles); ++i) { |
108 SkRect tile = SkRect::MakeXYWH(tiles[i].x * kPictureSize, | 108 SkRect tile = SkRect::MakeXYWH(tiles[i].x * kPictureSize, |
109 tiles[i].y * kPictureSize, | 109 tiles[i].y * kPictureSize, |
110 tiles[i].w * kPictureSize, | 110 tiles[i].w * kPictureSize, |
111 tiles[i].h * kPictureSize); | 111 tiles[i].h * kPictureSize); |
112 SkMatrix localMatrix; | 112 SkMatrix localMatrix; |
113 localMatrix.setTranslate(tiles[i].offsetX * kPictureSize, | 113 localMatrix.setTranslate(tiles[i].offsetX * kPictureSize, |
114 tiles[i].offsetY * kPictureSize); | 114 tiles[i].offsetY * kPictureSize); |
115 localMatrix.postScale(kFillSize / (2 * kPictureSize), | 115 localMatrix.postScale(kFillSize / (2 * kPictureSize), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 private: | 150 private: |
151 sk_sp<SkShader> fShaders[SK_ARRAY_COUNT(tiles)]; | 151 sk_sp<SkShader> fShaders[SK_ARRAY_COUNT(tiles)]; |
152 | 152 |
153 typedef GM INHERITED; | 153 typedef GM INHERITED; |
154 }; | 154 }; |
155 | 155 |
156 DEF_GM(return new PictureShaderTileGM;) | 156 DEF_GM(return new PictureShaderTileGM;) |
OLD | NEW |