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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return; | 83 return; |
84 } | 84 } |
85 | 85 |
86 GrTestTarget tt; | 86 GrTestTarget tt; |
87 context->getTestTarget(&tt); | 87 context->getTestTarget(&tt); |
88 if (NULL == tt.target()) { | 88 if (NULL == tt.target()) { |
89 SkDEBUGFAIL("Couldn't get Gr test target."); | 89 SkDEBUGFAIL("Couldn't get Gr test target."); |
90 return; | 90 return; |
91 } | 91 } |
92 | 92 |
93 GrDrawState* drawState = tt.target()->drawState(); | |
94 | |
95 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp,
NULL)); | 93 SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp,
NULL)); |
96 if (!texture) { | 94 if (!texture) { |
97 return; | 95 return; |
98 } | 96 } |
99 | 97 |
100 SkTArray<SkMatrix> textureMatrices; | 98 SkTArray<SkMatrix> textureMatrices; |
101 textureMatrices.push_back().setIDiv(texture->width(), texture->height())
; | 99 textureMatrices.push_back().setIDiv(texture->width(), texture->height())
; |
102 textureMatrices.push_back() = textureMatrices[0]; | 100 textureMatrices.push_back() = textureMatrices[0]; |
103 textureMatrices.back().postScale(1.5f, 0.85f); | 101 textureMatrices.back().postScale(1.5f, 0.85f); |
104 textureMatrices.push_back() = textureMatrices[0]; | 102 textureMatrices.push_back() = textureMatrices[0]; |
(...skipping 20 matching lines...) Expand all Loading... |
125 GrTextureDomainEffect::Create(texture, textureMatrices[t
m], | 123 GrTextureDomainEffect::Create(texture, textureMatrices[t
m], |
126 GrTextureDomain::MakeTexelDomain
(texture, | 124 GrTextureDomain::MakeTexelDomain
(texture, |
127
texelDomains[d]), | 125
texelDomains[d]), |
128 mode, GrTextureParams::kNone_Fil
terMode)); | 126 mode, GrTextureParams::kNone_Fil
terMode)); |
129 | 127 |
130 if (!fp) { | 128 if (!fp) { |
131 continue; | 129 continue; |
132 } | 130 } |
133 SkMatrix viewMatrix; | 131 SkMatrix viewMatrix; |
134 viewMatrix.setTranslate(x, y); | 132 viewMatrix.setTranslate(x, y); |
135 drawState->reset(viewMatrix); | 133 GrDrawState drawState(viewMatrix); |
136 drawState->setRenderTarget(rt); | 134 drawState.setRenderTarget(rt); |
137 drawState->setColor(0xffffffff); | 135 drawState.setColor(0xffffffff); |
138 drawState->addColorProcessor(fp); | 136 drawState.addColorProcessor(fp); |
139 | 137 |
140 tt.target()->drawSimpleRect(renderRect); | 138 tt.target()->drawSimpleRect(&drawState, renderRect); |
141 x += renderRect.width() + kTestPad; | 139 x += renderRect.width() + kTestPad; |
142 } | 140 } |
143 y += renderRect.height() + kTestPad; | 141 y += renderRect.height() + kTestPad; |
144 } | 142 } |
145 } | 143 } |
146 } | 144 } |
147 | 145 |
148 private: | 146 private: |
149 static const SkScalar kDrawPad; | 147 static const SkScalar kDrawPad; |
150 static const SkScalar kTestPad; | 148 static const SkScalar kTestPad; |
151 static const int kTargetWidth = 100; | 149 static const int kTargetWidth = 100; |
152 static const int kTargetHeight = 100; | 150 static const int kTargetHeight = 100; |
153 SkBitmap fBmp; | 151 SkBitmap fBmp; |
154 | 152 |
155 typedef GM INHERITED; | 153 typedef GM INHERITED; |
156 }; | 154 }; |
157 | 155 |
158 // Windows builds did not like SkScalar initialization in class :( | 156 // Windows builds did not like SkScalar initialization in class :( |
159 const SkScalar TextureDomainEffect::kDrawPad = 10.f; | 157 const SkScalar TextureDomainEffect::kDrawPad = 10.f; |
160 const SkScalar TextureDomainEffect::kTestPad = 10.f; | 158 const SkScalar TextureDomainEffect::kTestPad = 10.f; |
161 | 159 |
162 DEF_GM( return SkNEW(TextureDomainEffect); ) | 160 DEF_GM( return SkNEW(TextureDomainEffect); ) |
163 } | 161 } |
164 | 162 |
165 #endif | 163 #endif |
OLD | NEW |