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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 405 |
406 void SkBaseDevice::drawBitmapAsSprite(const SkDraw& draw, const SkBitmap& bitmap
, int x, int y, | 406 void SkBaseDevice::drawBitmapAsSprite(const SkDraw& draw, const SkBitmap& bitmap
, int x, int y, |
407 const SkPaint& paint) { | 407 const SkPaint& paint) { |
408 SkImageFilter* filter = paint.getImageFilter(); | 408 SkImageFilter* filter = paint.getImageFilter(); |
409 if (filter && !this->canHandleImageFilter(filter)) { | 409 if (filter && !this->canHandleImageFilter(filter)) { |
410 SkImageFilter::DeviceProxy proxy(this); | 410 SkImageFilter::DeviceProxy proxy(this); |
411 SkBitmap dst; | 411 SkBitmap dst; |
412 SkIPoint offset = SkIPoint::Make(0, 0); | 412 SkIPoint offset = SkIPoint::Make(0, 0); |
413 SkMatrix matrix = *draw.fMatrix; | 413 SkMatrix matrix = *draw.fMatrix; |
414 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 414 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
415 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS | |
416 const SkIRect clipBounds = bitmap.bounds(); | |
417 #else | |
418 const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y); | 415 const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y); |
419 #endif | |
420 SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache()); | 416 SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache()); |
421 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 417 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
422 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { | 418 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { |
423 SkPaint tmpUnfiltered(paint); | 419 SkPaint tmpUnfiltered(paint); |
424 tmpUnfiltered.setImageFilter(nullptr); | 420 tmpUnfiltered.setImageFilter(nullptr); |
425 this->drawSprite(draw, dst, x + offset.x(), y + offset.y(), tmpUnfil
tered); | 421 this->drawSprite(draw, dst, x + offset.x(), y + offset.y(), tmpUnfil
tered); |
426 } | 422 } |
427 } else { | 423 } else { |
428 this->drawSprite(draw, bitmap, x, y, paint); | 424 this->drawSprite(draw, bitmap, x, y, paint); |
429 } | 425 } |
430 } | 426 } |
431 | 427 |
432 uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { | 428 uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { |
433 uint32_t flags = paint.getFlags(); | 429 uint32_t flags = paint.getFlags(); |
434 | 430 |
435 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { | 431 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { |
436 return flags; | 432 return flags; |
437 } | 433 } |
438 | 434 |
439 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() | 435 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() |
440 || this->onShouldDisableLCD(paint)) { | 436 || this->onShouldDisableLCD(paint)) { |
441 | 437 |
442 flags &= ~SkPaint::kLCDRenderText_Flag; | 438 flags &= ~SkPaint::kLCDRenderText_Flag; |
443 flags |= SkPaint::kGenA8FromLCD_Flag; | 439 flags |= SkPaint::kGenA8FromLCD_Flag; |
444 } | 440 } |
445 | 441 |
446 return flags; | 442 return flags; |
447 } | 443 } |
448 | 444 |
OLD | NEW |