OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 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 "SkImageFilter.h" | 8 #include "SkImageFilter.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, | 229 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, |
230 SkBitmap*, SkIPoint*) const { | 230 SkBitmap*, SkIPoint*) const { |
231 return false; | 231 return false; |
232 } | 232 } |
233 | 233 |
234 bool SkImageFilter::canFilterImageGPU() const { | 234 bool SkImageFilter::canFilterImageGPU() const { |
235 return this->asFragmentProcessor(NULL, NULL, SkMatrix::I(), SkIRect()); | 235 return this->asFragmentProcessor(NULL, NULL, NULL, SkMatrix::I(), SkIRect())
; |
236 } | 236 } |
237 | 237 |
238 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
ext& ctx, | 238 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
ext& ctx, |
239 SkBitmap* result, SkIPoint* offset) const { | 239 SkBitmap* result, SkIPoint* offset) const { |
240 #if SK_SUPPORT_GPU | 240 #if SK_SUPPORT_GPU |
241 SkBitmap input = src; | 241 SkBitmap input = src; |
242 SkASSERT(fInputCount == 1); | 242 SkASSERT(fInputCount == 1); |
243 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 243 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
244 if (this->getInput(0) && | 244 if (this->getInput(0) && |
245 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffse
t)) { | 245 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffse
t)) { |
(...skipping 22 matching lines...) Expand all Loading... |
268 | 268 |
269 // setup new clip | 269 // setup new clip |
270 GrClip clip(dstRect); | 270 GrClip clip(dstRect); |
271 | 271 |
272 GrFragmentProcessor* fp; | 272 GrFragmentProcessor* fp; |
273 offset->fX = bounds.left(); | 273 offset->fX = bounds.left(); |
274 offset->fY = bounds.top(); | 274 offset->fY = bounds.top(); |
275 bounds.offset(-srcOffset); | 275 bounds.offset(-srcOffset); |
276 SkMatrix matrix(ctx.ctm()); | 276 SkMatrix matrix(ctx.ctm()); |
277 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); | 277 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); |
278 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { | 278 GrPaint paint; |
| 279 if (this->asFragmentProcessor(&fp, paint.getShaderDataManager(), srcTexture,
matrix, bounds)) { |
279 SkASSERT(fp); | 280 SkASSERT(fp); |
280 GrPaint paint; | |
281 paint.addColorProcessor(fp)->unref(); | 281 paint.addColorProcessor(fp)->unref(); |
282 | 282 |
283 GrDrawContext* drawContext = context->drawContext(); | 283 GrDrawContext* drawContext = context->drawContext(); |
284 if (drawContext) { | 284 if (drawContext) { |
285 drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint,
SkMatrix::I(), | 285 drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint,
SkMatrix::I(), |
286 dstRect, srcRect); | 286 dstRect, srcRect); |
287 | 287 |
288 WrapTexture(dst, bounds.width(), bounds.height(), result); | 288 WrapTexture(dst, bounds.width(), bounds.height(), result); |
289 return true; | 289 return true; |
290 } | 290 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 bounds.join(rect); | 367 bounds.join(rect); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 // don't modify dst until now, so we don't accidentally change it in the | 371 // don't modify dst until now, so we don't accidentally change it in the |
372 // loop, but then return false on the next filter. | 372 // loop, but then return false on the next filter. |
373 *dst = bounds; | 373 *dst = bounds; |
374 return true; | 374 return true; |
375 } | 375 } |
376 | 376 |
377 bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const
SkMatrix&, | 377 bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManag
er*, GrTexture*, |
378 const SkIRect&) const { | 378 const SkMatrix&, const SkIRect&) const { |
379 return false; | 379 return false; |
380 } | 380 } |
381 | 381 |
382 SkImageFilter* SkImageFilter::CreateMatrixFilter(const SkMatrix& matrix, | 382 SkImageFilter* SkImageFilter::CreateMatrixFilter(const SkMatrix& matrix, |
383 SkFilterQuality filterQuality, | 383 SkFilterQuality filterQuality, |
384 SkImageFilter* input) { | 384 SkImageFilter* input) { |
385 return SkMatrixImageFilter::Create(matrix, filterQuality, input); | 385 return SkMatrixImageFilter::Create(matrix, filterQuality, input); |
386 } | 386 } |
387 | 387 |
388 #if SK_SUPPORT_GPU | 388 #if SK_SUPPORT_GPU |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 } | 541 } |
542 return dev; | 542 return dev; |
543 } | 543 } |
544 | 544 |
545 bool SkImageFilter::Proxy::filterImage(const SkImageFilter* filter, const SkBitm
ap& src, | 545 bool SkImageFilter::Proxy::filterImage(const SkImageFilter* filter, const SkBitm
ap& src, |
546 const SkImageFilter::Context& ctx, | 546 const SkImageFilter::Context& ctx, |
547 SkBitmap* result, SkIPoint* offset) { | 547 SkBitmap* result, SkIPoint* offset) { |
548 return fDevice->filterImage(filter, src, ctx, result, offset); | 548 return fDevice->filterImage(filter, src, ctx, result, offset); |
549 } | 549 } |
550 | 550 |
OLD | NEW |