OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 The Android Open Source Project |
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 "SkXfermodeImageFilter.h" | 8 #include "SkXfermodeImageFilter.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 foregroundTex = foreground->asTextureRef(context); | 178 foregroundTex = foreground->asTextureRef(context); |
179 } | 179 } |
180 | 180 |
181 GrPaint paint; | 181 GrPaint paint; |
182 // SRGBTODO: AllowSRGBInputs? | 182 // SRGBTODO: AllowSRGBInputs? |
183 sk_sp<GrFragmentProcessor> bgFP; | 183 sk_sp<GrFragmentProcessor> bgFP; |
184 | 184 |
185 if (backgroundTex) { | 185 if (backgroundTex) { |
186 SkMatrix backgroundMatrix; | 186 SkMatrix backgroundMatrix; |
187 backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height()
); | 187 backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height()
); |
188 backgroundMatrix.preTranslate(SkIntToScalar(-backgroundOffset.fX), | 188 backgroundMatrix.preTranslate(-SkIntToScalar(backgroundOffset.fX), |
189 SkIntToScalar(-backgroundOffset.fY)); | 189 -SkIntToScalar(backgroundOffset.fY)); |
190 bgFP = GrTextureDomainEffect::Make( | 190 bgFP = GrTextureDomainEffect::Make( |
191 backgroundTex.get(), nullptr, backgroundMatrix, | 191 backgroundTex.get(), nullptr, backgroundMatrix, |
192 GrTextureDomain::MakeTexelDomain(backgroundTex.get()
, | 192 GrTextureDomain::MakeTexelDomain(backgroundTex.get()
, |
193 background->subset(
)), | 193 background->subset(
)), |
194 GrTextureDomain::kDecal_Mode, | 194 GrTextureDomain::kDecal_Mode, |
195 GrTextureParams::kNone_FilterMode); | 195 GrTextureParams::kNone_FilterMode); |
196 } else { | 196 } else { |
197 bgFP = GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK, | 197 bgFP = GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK, |
198 GrConstColorProcessor::kIgnore_Inpu
tMode); | 198 GrConstColorProcessor::kIgnore_Inpu
tMode); |
199 } | 199 } |
200 | 200 |
201 if (foregroundTex) { | 201 if (foregroundTex) { |
202 SkMatrix foregroundMatrix; | 202 SkMatrix foregroundMatrix; |
203 foregroundMatrix.setIDiv(foregroundTex->width(), foregroundTex->height()
); | 203 foregroundMatrix.setIDiv(foregroundTex->width(), foregroundTex->height()
); |
204 foregroundMatrix.preTranslate(SkIntToScalar(-foregroundOffset.fX), | 204 foregroundMatrix.preTranslate(-SkIntToScalar(foregroundOffset.fX), |
205 SkIntToScalar(-foregroundOffset.fY)); | 205 -SkIntToScalar(foregroundOffset.fY)); |
206 | 206 |
207 sk_sp<GrFragmentProcessor> foregroundFP; | 207 sk_sp<GrFragmentProcessor> foregroundFP; |
208 | 208 |
209 foregroundFP = GrTextureDomainEffect::Make( | 209 foregroundFP = GrTextureDomainEffect::Make( |
210 foregroundTex.get(), nullptr, foregroundMatrix, | 210 foregroundTex.get(), nullptr, foregroundMatrix, |
211 GrTextureDomain::MakeTexelDomain(foregroundTex.get()
, | 211 GrTextureDomain::MakeTexelDomain(foregroundTex.get()
, |
212 foreground->subset(
)), | 212 foreground->subset(
)), |
213 GrTextureDomain::kDecal_Mode, | 213 GrTextureDomain::kDecal_Mode, |
214 GrTextureParams::kNone_FilterMode); | 214 GrTextureParams::kNone_FilterMode); |
215 | 215 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top
())); | 253 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top
())); |
254 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds)); | 254 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds)); |
255 | 255 |
256 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he
ight()), | 256 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he
ight()), |
257 kNeedNewImageUniqueID_SpecialImage, | 257 kNeedNewImageUniqueID_SpecialImage, |
258 drawContext->asTexture(), | 258 drawContext->asTexture(), |
259 sk_ref_sp(drawContext->getColorSpace())); | 259 sk_ref_sp(drawContext->getColorSpace())); |
260 } | 260 } |
261 | 261 |
262 #endif | 262 #endif |
OLD | NEW |