OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 void testImage(SkCanvas* canvas, SkImage* image) { | 96 void testImage(SkCanvas* canvas, SkImage* image) { |
97 SkAutoCanvasRestore acr(canvas, true); | 97 SkAutoCanvasRestore acr(canvas, true); |
98 | 98 |
99 canvas->drawImage(image, 0, 0); | 99 canvas->drawImage(image, 0, 0); |
100 canvas->translate(0, 120); | 100 canvas->translate(0, 120); |
101 | 101 |
102 const SkShader::TileMode tile = SkShader::kRepeat_TileMode; | 102 const SkShader::TileMode tile = SkShader::kRepeat_TileMode; |
103 const SkMatrix localM = SkMatrix::MakeTrans(-50, -50); | 103 const SkMatrix localM = SkMatrix::MakeTrans(-50, -50); |
104 SkAutoTUnref<SkShader> shader(image->newShader(tile, tile, &localM)); | |
105 SkPaint paint; | 104 SkPaint paint; |
| 105 paint.setShader(image->makeShader(tile, tile, &localM)); |
106 paint.setAntiAlias(true); | 106 paint.setAntiAlias(true); |
107 paint.setShader(shader); | |
108 canvas->drawCircle(50, 50, 50, paint); | 107 canvas->drawCircle(50, 50, 50, paint); |
109 } | 108 } |
110 | 109 |
111 void onDraw(SkCanvas* canvas) override { | 110 void onDraw(SkCanvas* canvas) override { |
112 canvas->translate(20, 20); | 111 canvas->translate(20, 20); |
113 | 112 |
114 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 113 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
115 | 114 |
116 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { | 115 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { |
117 SkAutoTUnref<SkImage> image(gProcs[i](canvas->getGrContext(), fPictu
re, info)); | 116 SkAutoTUnref<SkImage> image(gProcs[i](canvas->getGrContext(), fPictu
re, info)); |
118 if (image) { | 117 if (image) { |
119 this->testImage(canvas, image); | 118 this->testImage(canvas, image); |
120 } | 119 } |
121 canvas->translate(120, 0); | 120 canvas->translate(120, 0); |
122 } | 121 } |
123 } | 122 } |
124 | 123 |
125 private: | 124 private: |
126 typedef skiagm::GM INHERITED; | 125 typedef skiagm::GM INHERITED; |
127 }; | 126 }; |
128 DEF_GM( return new ImageShaderGM; ) | 127 DEF_GM( return new ImageShaderGM; ) |
129 | 128 |
OLD | NEW |