OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 "SkColorFilter.h" | 8 #include "SkColorFilter.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 402 } |
403 | 403 |
404 ////////////////////////////////////////////////////////////////////////////////
////////// | 404 ////////////////////////////////////////////////////////////////////////////////
////////// |
405 | 405 |
406 void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm
ap, | 406 void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm
ap, |
407 int x, int y, | 407 int x, int y, |
408 const SkPaint& paint) { | 408 const SkPaint& paint) { |
409 SkImageFilter* filter = paint.getImageFilter(); | 409 SkImageFilter* filter = paint.getImageFilter(); |
410 SkASSERT(filter); | 410 SkASSERT(filter); |
411 | 411 |
412 SkImageFilter::DeviceProxy proxy(this); | 412 if (!this->canHandleImageFilter(filter)) { |
413 SkIPoint offset = SkIPoint::Make(0, 0); | 413 SkImageFilter::DeviceProxy proxy(this); |
414 SkMatrix matrix = *draw.fMatrix; | 414 SkIPoint offset = SkIPoint::Make(0, 0); |
415 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 415 SkMatrix matrix = *draw.fMatrix; |
416 const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y); | 416 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
417 SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache()); | 417 const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y); |
418 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 418 SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache()); |
| 419 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
419 | 420 |
420 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, bitmap, | 421 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, bit
map, |
421 &this->surfaceP
rops())); | 422 &this->surf
aceProps())); |
422 if (!srcImg) { | 423 if (!srcImg) { |
423 return; // something disastrous happened | 424 return; // something disastrous happened |
424 } | 425 } |
425 | 426 |
426 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offs
et)); | 427 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &
offset)); |
427 if (resultImg) { | 428 if (resultImg) { |
428 SkPaint tmpUnfiltered(paint); | 429 SkPaint tmpUnfiltered(paint); |
429 tmpUnfiltered.setImageFilter(nullptr); | 430 tmpUnfiltered.setImageFilter(nullptr); |
430 SkBitmap resultBM; | 431 SkBitmap resultBM; |
431 if (resultImg->internal_getBM(&resultBM)) { | 432 if (resultImg->internal_getBM(&resultBM)) { |
432 // TODO: add drawSprite(SkSpecialImage) to SkDevice? (see skbug.com/
5073) | 433 // TODO: add drawSprite(SkSpecialImage) to SkDevice? (see skbug.
com/5073) |
433 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(), tmp
Unfiltered); | 434 this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(),
tmpUnfiltered); |
| 435 } |
434 } | 436 } |
| 437 } else { |
| 438 this->drawSprite(draw, bitmap, x, y, paint); |
435 } | 439 } |
436 } | 440 } |
437 | 441 |
438 uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { | 442 uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { |
439 uint32_t flags = paint.getFlags(); | 443 uint32_t flags = paint.getFlags(); |
440 | 444 |
441 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { | 445 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { |
442 return flags; | 446 return flags; |
443 } | 447 } |
444 | 448 |
445 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() | 449 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() |
446 || this->onShouldDisableLCD(paint)) { | 450 || this->onShouldDisableLCD(paint)) { |
447 | 451 |
448 flags &= ~SkPaint::kLCDRenderText_Flag; | 452 flags &= ~SkPaint::kLCDRenderText_Flag; |
449 flags |= SkPaint::kGenA8FromLCD_Flag; | 453 flags |= SkPaint::kGenA8FromLCD_Flag; |
450 } | 454 } |
451 | 455 |
452 return flags; | 456 return flags; |
453 } | 457 } |
454 | 458 |
455 sk_sp<SkSurface> SkBaseDevice::makeSurface(SkImageInfo const&, SkSurfaceProps co
nst&) { | 459 sk_sp<SkSurface> SkBaseDevice::makeSurface(SkImageInfo const&, SkSurfaceProps co
nst&) { |
456 return nullptr; | 460 return nullptr; |
457 } | 461 } |
OLD | NEW |