OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp.width()), | 115 SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp.width()), |
116 SkIntToScalar(fBmp.height())); | 116 SkIntToScalar(fBmp.height())); |
117 renderRect.outset(kDrawPad, kDrawPad); | 117 renderRect.outset(kDrawPad, kDrawPad); |
118 | 118 |
119 SkScalar y = kDrawPad + kTestPad; | 119 SkScalar y = kDrawPad + kTestPad; |
120 for (int tm = 0; tm < textureMatrices.count(); ++tm) { | 120 for (int tm = 0; tm < textureMatrices.count(); ++tm) { |
121 for (size_t d = 0; d < SK_ARRAY_COUNT(texelDomains); ++d) { | 121 for (size_t d = 0; d < SK_ARRAY_COUNT(texelDomains); ++d) { |
122 SkScalar x = kDrawPad + kTestPad; | 122 SkScalar x = kDrawPad + kTestPad; |
123 for (int m = 0; m < GrTextureDomain::kModeCount; ++m) { | 123 for (int m = 0; m < GrTextureDomain::kModeCount; ++m) { |
124 GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m; | 124 GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m; |
125 SkAutoTUnref<GrEffect> effect( | 125 SkAutoTUnref<GrFragmentProcessor> fp( |
126 GrTextureDomainEffect::Create(texture, textureMatrices[t
m], | 126 GrTextureDomainEffect::Create(texture, textureMatrices[t
m], |
127 GrTextureDomain::MakeTexelDomain
(texture, | 127 GrTextureDomain::MakeTexelDomain
(texture, |
128
texelDomains[d]), | 128
texelDomains[d]), |
129 mode, GrTextureParams::kNone_Fil
terMode)); | 129 mode, GrTextureParams::kNone_Fil
terMode)); |
130 | 130 |
131 if (!effect) { | 131 if (!fp) { |
132 continue; | 132 continue; |
133 } | 133 } |
134 SkMatrix viewMatrix; | 134 SkMatrix viewMatrix; |
135 viewMatrix.setTranslate(x, y); | 135 viewMatrix.setTranslate(x, y); |
136 drawState->reset(viewMatrix); | 136 drawState->reset(viewMatrix); |
137 drawState->setRenderTarget(rt); | 137 drawState->setRenderTarget(rt); |
138 drawState->setColor(0xffffffff); | 138 drawState->setColor(0xffffffff); |
139 drawState->addColorEffect(effect); | 139 drawState->addColorProcessor(fp); |
140 | 140 |
141 tt.target()->drawSimpleRect(renderRect); | 141 tt.target()->drawSimpleRect(renderRect); |
142 x += renderRect.width() + kTestPad; | 142 x += renderRect.width() + kTestPad; |
143 } | 143 } |
144 y += renderRect.height() + kTestPad; | 144 y += renderRect.height() + kTestPad; |
145 } | 145 } |
146 } | 146 } |
147 GrUnlockAndUnrefCachedBitmapTexture(texture); | 147 GrUnlockAndUnrefCachedBitmapTexture(texture); |
148 } | 148 } |
149 | 149 |
150 private: | 150 private: |
151 static const SkScalar kDrawPad; | 151 static const SkScalar kDrawPad; |
152 static const SkScalar kTestPad; | 152 static const SkScalar kTestPad; |
153 static const int kTargetWidth = 100; | 153 static const int kTargetWidth = 100; |
154 static const int kTargetHeight = 100; | 154 static const int kTargetHeight = 100; |
155 SkBitmap fBmp; | 155 SkBitmap fBmp; |
156 | 156 |
157 typedef GM INHERITED; | 157 typedef GM INHERITED; |
158 }; | 158 }; |
159 | 159 |
160 // Windows builds did not like SkScalar initialization in class :( | 160 // Windows builds did not like SkScalar initialization in class :( |
161 const SkScalar TextureDomainEffect::kDrawPad = 10.f; | 161 const SkScalar TextureDomainEffect::kDrawPad = 10.f; |
162 const SkScalar TextureDomainEffect::kTestPad = 10.f; | 162 const SkScalar TextureDomainEffect::kTestPad = 10.f; |
163 | 163 |
164 DEF_GM( return SkNEW(TextureDomainEffect); ) | 164 DEF_GM( return SkNEW(TextureDomainEffect); ) |
165 } | 165 } |
166 | 166 |
167 #endif | 167 #endif |
OLD | NEW |