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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 m.postConcat(*matrix); | 395 m.postConcat(*matrix); |
396 } | 396 } |
397 morphpath(&tmp, *iterPath, meas, m); | 397 morphpath(&tmp, *iterPath, meas, m); |
398 this->drawPath(draw, tmp, iter.getPaint(), nullptr, true); | 398 this->drawPath(draw, tmp, iter.getPaint(), nullptr, true); |
399 } | 399 } |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 ////////////////////////////////////////////////////////////////////////////////
////////// | 403 ////////////////////////////////////////////////////////////////////////////////
////////// |
404 | 404 |
| 405 bool SkBaseDevice::canCallFilterSprite(const SkMatrix* ctm, const SkPaint& paint
) { |
| 406 if (ctm && (ctm->getType() & ~SkMatrix::kTranslate_Mask)) { |
| 407 return false; |
| 408 } |
| 409 const SkImageFilter* filter = paint.getImageFilter(); |
| 410 return filter && !this->canHandleImageFilter(filter); |
| 411 } |
| 412 |
| 413 void SkBaseDevice::filterSprite(const SkDraw& draw, const SkBitmap& bitmap, int
x, int y, |
| 414 const SkPaint& paint) { |
| 415 SkImageFilter* filter = paint.getImageFilter(); |
| 416 SkASSERT(filter && !this->canHandleImageFilter(filter)); |
| 417 |
| 418 SkImageFilter::DeviceProxy proxy(this); |
| 419 SkBitmap dst; |
| 420 SkIPoint offset = SkIPoint::Make(0, 0); |
| 421 SkMatrix matrix = *draw.fMatrix; |
| 422 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
| 423 const SkIRect clipBounds = bitmap.bounds(); |
| 424 SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache()); |
| 425 SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), |
| 426 SkImageFilter::kApprox_SizeConstraint); |
| 427 if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { |
| 428 SkPaint tmpUnfiltered(paint); |
| 429 tmpUnfiltered.setImageFilter(nullptr); |
| 430 this->drawSprite(draw, dst, x + offset.x(), y + offset.y(), tmpUnfiltere
d); |
| 431 } |
| 432 } |
| 433 |
405 uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { | 434 uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { |
406 uint32_t flags = paint.getFlags(); | 435 uint32_t flags = paint.getFlags(); |
407 | 436 |
408 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { | 437 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { |
409 return flags; | 438 return flags; |
410 } | 439 } |
411 | 440 |
412 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() | 441 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() |
413 || this->onShouldDisableLCD(paint)) { | 442 || this->onShouldDisableLCD(paint)) { |
414 | 443 |
415 flags &= ~SkPaint::kLCDRenderText_Flag; | 444 flags &= ~SkPaint::kLCDRenderText_Flag; |
416 flags |= SkPaint::kGenA8FromLCD_Flag; | 445 flags |= SkPaint::kGenA8FromLCD_Flag; |
417 } | 446 } |
418 | 447 |
419 return flags; | 448 return flags; |
420 } | 449 } |
421 | 450 |
OLD | NEW |