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" |
11 #include "SkDrawFilter.h" | 11 #include "SkDrawFilter.h" |
12 #include "SkImage_Base.h" | 12 #include "SkImage_Base.h" |
| 13 #include "SkImageFilter.h" |
| 14 #include "SkImageFilterCache.h" |
13 #include "SkMetaData.h" | 15 #include "SkMetaData.h" |
14 #include "SkNinePatchIter.h" | 16 #include "SkNinePatchIter.h" |
15 #include "SkPatchUtils.h" | 17 #include "SkPatchUtils.h" |
16 #include "SkPathMeasure.h" | 18 #include "SkPathMeasure.h" |
17 #include "SkRasterClip.h" | 19 #include "SkRasterClip.h" |
18 #include "SkRSXform.h" | 20 #include "SkRSXform.h" |
19 #include "SkShader.h" | 21 #include "SkShader.h" |
20 #include "SkSpecialImage.h" | 22 #include "SkSpecialImage.h" |
21 #include "SkTextBlobRunIterator.h" | 23 #include "SkTextBlobRunIterator.h" |
22 #include "SkTextToPathIter.h" | 24 #include "SkTextToPathIter.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm
ap, | 408 void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm
ap, |
407 int x, int y, | 409 int x, int y, |
408 const SkPaint& paint) { | 410 const SkPaint& paint) { |
409 SkImageFilter* filter = paint.getImageFilter(); | 411 SkImageFilter* filter = paint.getImageFilter(); |
410 SkASSERT(filter); | 412 SkASSERT(filter); |
411 | 413 |
412 SkIPoint offset = SkIPoint::Make(0, 0); | 414 SkIPoint offset = SkIPoint::Make(0, 0); |
413 SkMatrix matrix = *draw.fMatrix; | 415 SkMatrix matrix = *draw.fMatrix; |
414 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 416 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
415 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y); | 417 const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y); |
416 SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache()); | 418 SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); |
417 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); | 419 SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); |
418 | 420 |
419 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(bitmap, &this->
surfaceProps())); | 421 sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(bitmap, &this->
surfaceProps())); |
420 if (!srcImg) { | 422 if (!srcImg) { |
421 return; // something disastrous happened | 423 return; // something disastrous happened |
422 } | 424 } |
423 | 425 |
424 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offs
et)); | 426 sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offs
et)); |
425 if (resultImg) { | 427 if (resultImg) { |
426 SkPaint tmpUnfiltered(paint); | 428 SkPaint tmpUnfiltered(paint); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 503 |
502 // Also log filter quality independent scale factor. | 504 // Also log filter quality independent scale factor. |
503 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor, | 505 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor, |
504 kLast_ScaleFactor + 1); | 506 kLast_ScaleFactor + 1); |
505 | 507 |
506 // Also log an overall histogram of filter quality. | 508 // Also log an overall histogram of filter quality. |
507 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali
ty + 1); | 509 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali
ty + 1); |
508 #endif | 510 #endif |
509 } | 511 } |
510 | 512 |
OLD | NEW |