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 | 8 |
9 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 desc.fConfig = kSkia8888_GrPixelConfig; | 84 desc.fConfig = kSkia8888_GrPixelConfig; |
85 desc.fWidth = 2 * S; | 85 desc.fWidth = 2 * S; |
86 desc.fHeight = 2 * S; | 86 desc.fHeight = 2 * S; |
87 GrTexture* texture = ctx->createTexture(desc, false, gTextureDat
a.get(), 0); | 87 GrTexture* texture = ctx->createTexture(desc, false, gTextureDat
a.get(), 0); |
88 | 88 |
89 if (!texture) { | 89 if (!texture) { |
90 return; | 90 return; |
91 } | 91 } |
92 SkAutoTUnref<GrTexture> au(texture); | 92 SkAutoTUnref<GrTexture> au(texture); |
93 | 93 |
94 // setup new clip | 94 GrContext::AutoClip acs(ctx, SkRect::MakeWH(2*S, 2*S)); |
95 GrClip clip(SkRect::MakeWH(2*S, 2*S)); | |
96 | 95 |
97 GrPaint paint; | 96 GrPaint paint; |
98 paint.setPorterDuffXPFactory(SkXfermode::kSrcOver_Mode); | 97 paint.setPorterDuffXPFactory(SkXfermode::kSrcOver_Mode); |
99 | 98 |
100 SkMatrix vm; | 99 SkMatrix vm; |
101 if (i) { | 100 if (i) { |
102 vm.setRotate(90 * SK_Scalar1, | 101 vm.setRotate(90 * SK_Scalar1, |
103 S * SK_Scalar1, | 102 S * SK_Scalar1, |
104 S * SK_Scalar1); | 103 S * SK_Scalar1); |
105 } else { | 104 } else { |
106 vm.reset(); | 105 vm.reset(); |
107 } | 106 } |
108 SkMatrix tm; | 107 SkMatrix tm; |
109 tm = vm; | 108 tm = vm; |
110 tm.postIDiv(2*S, 2*S); | 109 tm.postIDiv(2*S, 2*S); |
111 paint.addColorTextureProcessor(texture, tm); | 110 paint.addColorTextureProcessor(texture, tm); |
112 | 111 |
113 ctx->drawRect(target, clip, paint, vm, SkRect::MakeWH(2*S, 2*S))
; | 112 ctx->drawRect(target, paint, vm, SkRect::MakeWH(2*S, 2*S)); |
114 | 113 |
115 // now update the lower right of the texture in first pass | 114 // now update the lower right of the texture in first pass |
116 // or upper right in second pass | 115 // or upper right in second pass |
117 offset = 0; | 116 offset = 0; |
118 for (int y = 0; y < S; ++y) { | 117 for (int y = 0; y < S; ++y) { |
119 for (int x = 0; x < S; ++x) { | 118 for (int x = 0; x < S; ++x) { |
120 gTextureData[offset + y * stride + x] = | 119 gTextureData[offset + y * stride + x] = |
121 ((x + y) % 2) ? (i ? green : red) : blue; | 120 ((x + y) % 2) ? (i ? green : red) : blue; |
122 } | 121 } |
123 } | 122 } |
124 texture->writePixels(S, (i ? 0 : S), S, S, | 123 texture->writePixels(S, (i ? 0 : S), S, S, |
125 texture->config(), gTextureData.get(), | 124 texture->config(), gTextureData.get(), |
126 4 * stride); | 125 4 * stride); |
127 ctx->drawRect(target, clip, paint, vm, SkRect::MakeWH(2*S, 2*S))
; | 126 ctx->drawRect(target, paint, vm, SkRect::MakeWH(2*S, 2*S)); |
128 } | 127 } |
129 } else { | 128 } else { |
130 this->drawGpuOnlyMessage(canvas); | 129 this->drawGpuOnlyMessage(canvas); |
131 } | 130 } |
132 } | 131 } |
133 | 132 |
134 private: | 133 private: |
135 typedef GM INHERITED; | 134 typedef GM INHERITED; |
136 }; | 135 }; |
137 | 136 |
138 ////////////////////////////////////////////////////////////////////////////// | 137 ////////////////////////////////////////////////////////////////////////////// |
139 | 138 |
140 static GM* MyFactory(void*) { return new TexDataGM; } | 139 static GM* MyFactory(void*) { return new TexDataGM; } |
141 static GMRegistry reg(MyFactory); | 140 static GMRegistry reg(MyFactory); |
142 | 141 |
143 } | 142 } |
144 | 143 |
145 #endif | 144 #endif |
OLD | NEW |