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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 offset->fX = bounds.left(); | 86 offset->fX = bounds.left(); |
87 offset->fY = bounds.top(); | 87 offset->fY = bounds.top(); |
88 | 88 |
89 #if SK_SUPPORT_GPU | 89 #if SK_SUPPORT_GPU |
90 if (source->isTextureBacked()) { | 90 if (source->isTextureBacked()) { |
91 return this->filterImageGPU(source, | 91 return this->filterImageGPU(source, |
92 background, backgroundOffset, | 92 background, backgroundOffset, |
93 foreground, foregroundOffset, | 93 foreground, foregroundOffset, |
94 bounds); | 94 bounds, ctx.outputProperties()); |
95 } | 95 } |
96 #endif | 96 #endif |
97 | 97 |
98 const SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(
), | 98 const SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(
), |
99 kPremul_SkAlphaType); | 99 kPremul_SkAlphaType); |
100 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); | 100 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); |
101 if (!surf) { | 101 if (!surf) { |
102 return nullptr; | 102 return nullptr; |
103 } | 103 } |
104 | 104 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 str->appendf(")"); | 152 str->appendf(")"); |
153 } | 153 } |
154 str->append(")"); | 154 str->append(")"); |
155 } | 155 } |
156 #endif | 156 #endif |
157 | 157 |
158 #if SK_SUPPORT_GPU | 158 #if SK_SUPPORT_GPU |
159 | 159 |
160 #include "SkXfermode_proccoeff.h" | 160 #include "SkXfermode_proccoeff.h" |
161 | 161 |
162 sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
ce, | 162 sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU( |
163 sk_sp<SkSpecialImage
> background, | 163 SkSpecialImage* source, |
164 const SkIPoint& back
groundOffset, | 164 sk_sp<SkSpecialImage> backgro
und, |
165 sk_sp<SkSpecialImage
> foreground, | 165 const SkIPoint& backgroundOff
set, |
166 const SkIPoint& fore
groundOffset, | 166 sk_sp<SkSpecialImage> foregro
und, |
167 const SkIRect& bound
s) const { | 167 const SkIPoint& foregroundOff
set, |
| 168 const SkIRect& bounds, |
| 169 const OutputProperties& outpu
tProperties) const { |
168 SkASSERT(source->isTextureBacked()); | 170 SkASSERT(source->isTextureBacked()); |
169 | 171 |
170 GrContext* context = source->getContext(); | 172 GrContext* context = source->getContext(); |
171 | 173 |
172 sk_sp<GrTexture> backgroundTex, foregroundTex; | 174 sk_sp<GrTexture> backgroundTex, foregroundTex; |
173 | 175 |
174 if (background) { | 176 if (background) { |
175 backgroundTex = background->asTextureRef(context); | 177 backgroundTex = background->asTextureRef(context); |
176 } | 178 } |
177 | 179 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 paint.addColorFragmentProcessor(std::move(xferFP)); | 238 paint.addColorFragmentProcessor(std::move(xferFP)); |
237 } | 239 } |
238 } else { | 240 } else { |
239 paint.addColorFragmentProcessor(std::move(bgFP)); | 241 paint.addColorFragmentProcessor(std::move(bgFP)); |
240 } | 242 } |
241 | 243 |
242 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 244 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
243 | 245 |
244 sk_sp<GrDrawContext> drawContext( | 246 sk_sp<GrDrawContext> drawContext( |
245 context->makeDrawContext(SkBackingFit::kApprox, bounds.width(), bounds.h
eight(), | 247 context->makeDrawContext(SkBackingFit::kApprox, bounds.width(), bounds.h
eight(), |
246 GrRenderableConfigForColorSpace(source->getColo
rSpace()), | 248 GrRenderableConfigForColorSpace(outputPropertie
s.colorSpace()), |
247 sk_ref_sp(source->getColorSpace()))); | 249 sk_ref_sp(outputProperties.colorSpace()))); |
248 if (!drawContext) { | 250 if (!drawContext) { |
249 return nullptr; | 251 return nullptr; |
250 } | 252 } |
251 paint.setAllowSRGBInputs(drawContext->isGammaCorrect()); | 253 paint.setAllowSRGBInputs(drawContext->isGammaCorrect()); |
252 | 254 |
253 SkMatrix matrix; | 255 SkMatrix matrix; |
254 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top
())); | 256 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top
())); |
255 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds)); | 257 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds)); |
256 | 258 |
257 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he
ight()), | 259 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he
ight()), |
258 kNeedNewImageUniqueID_SpecialImage, | 260 kNeedNewImageUniqueID_SpecialImage, |
259 drawContext->asTexture(), | 261 drawContext->asTexture(), |
260 sk_ref_sp(drawContext->getColorSpace())); | 262 sk_ref_sp(drawContext->getColorSpace())); |
261 } | 263 } |
262 | 264 |
263 #endif | 265 #endif |
OLD | NEW |