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