diff options
author | fmalita <fmalita@chromium.org> | 2016-01-07 08:02:25 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-07 08:02:26 -0800 |
commit | 983dc2541a729609037a05eba731b3eb9788c517 (patch) | |
tree | 352e3f143db88ea70b09e5c1893660046edaa44c /src/core/SkMatrixUtils.h | |
parent | c070d1514ace6b672d5dbaaa3090d27698400f1f (diff) |
SkTreatAsSprite should take AA into account
Currently we always call SkTreatAsSprite with 0 subpixel bits, which means
subpixel translations are ignored. This is incorrect for the anti-aliased
case (drawSprite always pixel-snaps, so we lose edge AA).
The CL updates SkTreatAsSprite to take an SkPaint argument and use 8 subpixel
bits when AA is requested.
Also remove unused SkTreatAsSpriteFilter.
BUG=skia:4761
R=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1566943002
Review URL: https://codereview.chromium.org/1566943002
Diffstat (limited to 'src/core/SkMatrixUtils.h')
-rw-r--r-- | src/core/SkMatrixUtils.h | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/src/core/SkMatrixUtils.h b/src/core/SkMatrixUtils.h index d1b6658d07..0e01fbe953 100644 --- a/src/core/SkMatrixUtils.h +++ b/src/core/SkMatrixUtils.h @@ -8,37 +8,20 @@ #ifndef SkMatrixUtils_DEFINED #define SkMatrixUtils_DEFINED -#include "SkMatrix.h" +#include "SkSize.h" -/** - * Number of subpixel bits used in skia's bilerp. - * See SkBitmapProcState_procs.h and SkBitmapProcState_filter.h - */ -#define kSkSubPixelBitsForBilerp 4 +class SkMatrix; +class SkPaint; /** - * Given a matrix and width/height, return true if the computed dst-rect would + * Given a matrix, size and paint, return true if the computed dst-rect would * align such that there is a 1-to-1 coorspondence between src and dst pixels. * This can be called by drawing code to see if drawBitmap can be turned into * drawSprite (which is faster). * - * The src-rect is defined to be { 0, 0, width, height } - * - * The "closeness" test is based on the subpixelBits parameter. Pass 0 for - * round-to-nearest behavior (e.g. nearest neighbor sampling). Pass the number - * of subpixel-bits to simulate filtering. - */ -bool SkTreatAsSprite(const SkMatrix&, int width, int height, - unsigned subpixelBits); - -/** - * Calls SkTreatAsSprite() with default subpixelBits value to match Skia's - * filter-bitmap implementation (i.e. kSkSubPixelBitsForBilerp). + * The src-rect is defined to be { 0, 0, size.width(), size.height() } */ -static inline bool SkTreatAsSpriteFilter(const SkMatrix& matrix, - int width, int height) { - return SkTreatAsSprite(matrix, width, height, kSkSubPixelBitsForBilerp); -} +bool SkTreatAsSprite(const SkMatrix&, const SkISize& size, const SkPaint& paint); /** Decomposes the upper-left 2x2 of the matrix into a rotation (represented by the cosine and sine of the rotation angle), followed by a non-uniform scale, |